55 {
57
58
60 for (; data_start !=
data_; --data_start) {
61 if (*data_start == '$') {
62 break;
63 }
64 }
65 if (data_start !=
data_) {
66 AINFO <<
"BroadGnss message has been truncated: " <<
data_;
67 }
68
69 if (*data_start != '$') {
70 input_str_.append(reinterpret_cast<const char *>(data_start),
72 } else {
73 input_str_.assign(reinterpret_cast<const char *>(data_start),
75 }
76
78 AINFO <<
"BroadGnss ASCII message is not complete: " << data_start;
79 return false;
80 } else {
81 ADEBUG <<
"BroadGnss ASCII message is complete";
82 }
83
84
85 std::stringstream ss(input_str_.substr(0, input_str_.rfind('*')));
86 std::vector<std::string> fields;
87 for (std::string field; std::getline(ss, field, ',');) {
88 fields.push_back(field);
89 }
90 if (fields.empty()) {
91 return false;
92 }
93 auto valid_fields = [&]() -> bool {
94 for (size_t i = 1; i < fields.size(); ++i) {
95 if (fields[i].empty()) {
96 fields[i] = "0";
97 } else if (fields[i].find_first_not_of("0123456789.- ") !=
98 std::string::npos) {
99 AERROR <<
"BroadGnss ASCII message field error: " << fields[i]
100 << ", input str: " << input_str_;
101 return false;
102 }
103 }
104 return true;
105 };
106 if (fields[0] == protocol_.
GIAVP) {
108 AERROR <<
"BroadGnss GIAVP message format error: " <<
data_;
109 return false;
110 }
111 if (!valid_fields()) {
112 return false;
113 }
114 PrepareMessageGIAVP(fields);
115 return true;
116 }
else if (fields[0] == protocol_.
GPINS) {
118 AERROR <<
"BroadGnss GPINS message format error:" <<
data_;
119 return false;
120 }
121 if (!valid_fields()) {
122 return false;
123 }
124 PrepareMessageGPINS(fields);
125 return true;
126 }
127 return false;
128}
const uint8_t * data_end_