interpretation of empty value strings in json
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Jakob Meier 2021-12-13 09:40:37 +01:00
parent 9c42b861f4
commit 86581d81c9
3 changed files with 13 additions and 1 deletions

View File

@ -17,12 +17,19 @@ ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string&
for (json::iterator it = set.begin(); it != set.end(); ++it) { for (json::iterator it = set.begin(); it != set.end(); ++it) {
if ((*it)[arcseckeys::NAME] == name) { if ((*it)[arcseckeys::NAME] == name) {
value = (*it)[arcseckeys::VALUE]; value = (*it)[arcseckeys::VALUE];
convertEmpty(value);
return RETURN_OK; return RETURN_OK;
} }
} }
return PARAM_NOT_EXISTS; return PARAM_NOT_EXISTS;
} }
void ArcsecJsonParamBase::convertEmpty(std::string& value) {
if (value == "") {
value = "0";
}
}
void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) {
float param = std::stof(value); float param = std::stof(value);
std::memcpy(buffer, &param, sizeof(param)); std::memcpy(buffer, &param, sizeof(param));

View File

@ -66,6 +66,11 @@ protected:
*/ */
ReturnValue_t getParam(const std::string name, std::string& value); ReturnValue_t getParam(const std::string name, std::string& value);
/**
* @brief Converts empty string which is equal to define a value as zero.
*/
void convertEmpty(std::string& value);
/** /**
* @brief This function adds a float represented as string to a buffer * @brief This function adds a float represented as string to a buffer
* *

2
tmtc

@ -1 +1 @@
Subproject commit 7b01165ff937e45e052caeb550e622a8b9df6ee2 Subproject commit bbae8284884ebfd49655e0a806e0d1288f4a7a70