From 86581d81c98eae1fe5680f9154b54f55f63c931e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 13 Dec 2021 09:40:37 +0100 Subject: [PATCH] interpretation of empty value strings in json --- bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp | 7 +++++++ bsp_q7s/devices/startracker/ArcsecJsonParamBase.h | 5 +++++ tmtc | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp index 38040797..339c3fe7 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -17,12 +17,19 @@ ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& for (json::iterator it = set.begin(); it != set.end(); ++it) { if ((*it)[arcseckeys::NAME] == name) { value = (*it)[arcseckeys::VALUE]; + convertEmpty(value); return RETURN_OK; } } return PARAM_NOT_EXISTS; } +void ArcsecJsonParamBase::convertEmpty(std::string& value) { + if (value == "") { + value = "0"; + } +} + void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { float param = std::stof(value); std::memcpy(buffer, ¶m, sizeof(param)); diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h index dc59c6fc..320eff53 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -66,6 +66,11 @@ protected: */ 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 * diff --git a/tmtc b/tmtc index 7b01165f..bbae8284 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7b01165ff937e45e052caeb550e622a8b9df6ee2 +Subproject commit bbae8284884ebfd49655e0a806e0d1288f4a7a70