kopia lustrzana https://github.com/ukhas/habitat-cpp-connector
Use callsign, not payload in sentence. Also, improve checks
rodzic
b641981709
commit
ff9d343ebb
|
@ -320,18 +320,19 @@ static void attempt_settings(Json::Value &data, const Json::Value &sentence,
|
|||
const string &checksum_name,
|
||||
const vector<string> &parts)
|
||||
{
|
||||
if (!sentence.isObject())
|
||||
throw runtime_error("Invalid configuration (sentence not an object)");
|
||||
if (!sentence.isObject() || !sentence["callsign"].isString() ||
|
||||
!sentence["fields"].isArray() || !sentence["fields"].size())
|
||||
throw runtime_error("Invalid configuration "
|
||||
"(missing callsign or fields)");
|
||||
|
||||
const Json::Value &fields = sentence["fields"];
|
||||
|
||||
const string callsign = sentence["payload"].asString();
|
||||
if (parts[0] != callsign)
|
||||
if (sentence["callsign"] != parts[0])
|
||||
throw runtime_error("Incorrect callsign");
|
||||
|
||||
if (sentence["checksum"] != checksum_name)
|
||||
throw runtime_error("Wrong checksum type");
|
||||
|
||||
const Json::Value &fields = sentence["fields"];
|
||||
|
||||
if (fields.size() != (parts.size() - 1))
|
||||
throw runtime_error("Incorrect number of fields");
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ class TestUKHASExtractor:
|
|||
|
||||
crude_parse_flight_doc = {
|
||||
"sentences": [ {
|
||||
"payload": "TESTING",
|
||||
"callsign": "TESTING",
|
||||
"checksum": "crc16-ccitt",
|
||||
"fields": [
|
||||
{"name": "field_a"},
|
||||
|
@ -281,10 +281,10 @@ class TestUKHASExtractor:
|
|||
|
||||
multi_config_flight_doc = {
|
||||
"sentences": [
|
||||
{ "payload": "AWKWARD",
|
||||
{ "callsign": "AWKWARD",
|
||||
"checksum": "crc16-ccitt",
|
||||
"fields": [ {"name": "fa"}, {"name": "fo"}, {"name": "fc"} ] },
|
||||
{ "payload": "AWKWARD",
|
||||
{ "callsign": "AWKWARD",
|
||||
"checksum": "crc16-ccitt",
|
||||
"fields": [ {"name": "fa"}, {"name": "fb"} ] }
|
||||
]
|
||||
|
@ -312,7 +312,7 @@ class TestUKHASExtractor:
|
|||
|
||||
ddmmmmmm_flight_doc = {
|
||||
"sentences": [ {
|
||||
"payload": "TESTING",
|
||||
"callsign": "TESTING",
|
||||
"checksum": "crc16-ccitt",
|
||||
"fields": [
|
||||
{"sensor":"stdtelem.coordinate","name":"lat_a",
|
||||
|
|
Ładowanie…
Reference in New Issue