Commit ca6a8058 authored by Giuseppe Carboni's avatar Giuseppe Carboni
Browse files

Some minor fixes for the SRTMinorServoCommandLibrary

parent 749441dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@

#define CLOSER std::string("\r\n")

using SRTMinorServoAnswerMap = std::map<std::string, std::variant<int, double, std::string> >;
using SRTMinorServoAnswerMap = std::map<std::string, std::variant<long, double, std::string> >;

/**
 * SRT Minor Servo Command Library
+11 −7
Original line number Diff line number Diff line
@@ -111,15 +111,19 @@ SRTMinorServoAnswerMap SRTMinorServoCommandLibrary::parseAnswer(std::string answ
            std::getline(sss, key, '=');
            std::getline(sss, value);

            // No value, should be the timestamp
            // No value, could be the timestamp
            if(value.empty())
            {
                if(args.find("TIMESTAMP") != args.end())    // Timestamp already found, some other value is missing its key
                    throw std::invalid_argument(std::string("Missing key for value " + value));

                if(args.find("TIMESTAMP") != args.end())    // Timestamp already found, some other value is missing
                {
                    value = "0";
                }
                else
                {
                    value = key;
                    key = "TIMESTAMP";
                }
            }

            if(key == "OUTPUT")
            {
@@ -138,7 +142,7 @@ SRTMinorServoAnswerMap SRTMinorServoCommandLibrary::parseAnswer(std::string answ
            else
            {
                size_t last_char;
                args[key] = std::stoi(value, &last_char);
                args[key] = std::stol(value, &last_char);
                if(last_char != value.size())
                    args[key] = std::stod(value);
            }