43 void PrepareMessageCommon(
const std::vector<std::string> &fields);
44 void PrepareMessageGIAVP(
const std::vector<std::string> &fields);
45 void PrepareMessageGPINS(
const std::vector<std::string> &fields);
48 std::string input_str_;
60 for (; data_start !=
data_; --data_start) {
61 if (*data_start ==
'$') {
65 if (data_start !=
data_) {
66 AINFO <<
"BroadGnss message has been truncated: " <<
data_;
69 if (*data_start !=
'$') {
70 input_str_.append(
reinterpret_cast<const char *
>(data_start),
73 input_str_.assign(
reinterpret_cast<const char *
>(data_start),
78 AINFO <<
"BroadGnss ASCII message is not complete: " << data_start;
81 ADEBUG <<
"BroadGnss ASCII message is complete";
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);
93 auto valid_fields = [&]() ->
bool {
94 for (
size_t i = 1; i < fields.size(); ++i) {
95 if (fields[i].empty()) {
97 }
else if (fields[i].find_first_not_of(
"0123456789.- ") !=
99 AERROR <<
"BroadGnss ASCII message field error: " << fields[i]
100 <<
", input str: " << input_str_;
106 if (fields[0] == protocol_.
GIAVP) {
108 AERROR <<
"BroadGnss GIAVP message format error: " <<
data_;
111 if (!valid_fields()) {
114 PrepareMessageGIAVP(fields);
116 }
else if (fields[0] == protocol_.
GPINS) {
118 AERROR <<
"BroadGnss GPINS message format error:" <<
data_;
121 if (!valid_fields()) {
124 PrepareMessageGPINS(fields);
130void BroadGnssTextParser::PrepareMessageCommon(
131 const std::vector<std::string> &fields) {
146void BroadGnssTextParser::PrepareMessageGIAVP(
147 const std::vector<std::string> &fields) {
148 PrepareMessageCommon(fields);
149 int solution_type = std::stoi(fields[15]);
150 int solution_status = 0;
151 if (solution_type >= 4) {
163void BroadGnssTextParser::PrepareMessageGPINS(
164 const std::vector<std::string> &fields) {
165 PrepareMessageCommon(fields);
void PrepareMessageStatus(const uint8_t &solution_status, const uint8_t &solution_type)
BroadGnssMessage broadgnss_message_
BroadGnssTextParser(const config::Config &config)
bool PrepareMessage() override
const uint8_t * data_end_
static Parser * CreateBroadGnssText(const config::Config &config)
constexpr double DEG_TO_RAD
constexpr int SECONDS_PER_WEEK