diff --git a/ubx.cc b/ubx.cc index 1bf8847..1f379a2 100644 --- a/ubx.cc +++ b/ubx.cc @@ -88,7 +88,8 @@ basic_string getInavFromSFRBXMsg(std::basic_string_view msg) return inav; } -basic_string getGPSFromSFRBXMsg(int sv, std::basic_string_view msg) +// XXX this should do the parity check +basic_string getGPSFromSFRBXMsg(std::basic_string_view msg) { // byte order adjustment std::basic_string payload; @@ -100,3 +101,28 @@ basic_string getGPSFromSFRBXMsg(int sv, std::basic_string_view return payload; } +// note, this returns the fourth UBX specific word with derived data, feel free to ignore! +basic_string getGlonassFromSFRBXMsg(std::basic_string_view msg) +{ + // byte order adjustment + std::basic_string payload; + for(unsigned int i = 0 ; i < (msg.size() - 8) / 4; ++i) + for(int j=1; j <= 4; ++j) + payload.append(1, msg[8 + (i+1) * 4 -j]); + + + return payload; +} + +// note, this returns the fourth UBX specific word with derived data, feel free to ignore! +basic_string getBeidouFromSFRBXMsg(std::basic_string_view msg) +{ + // byte order adjustment + std::basic_string payload; + for(unsigned int i = 0 ; i < (msg.size() - 8) / 4; ++i) + for(int j=1; j <= 4; ++j) + payload.append(1, msg[8 + (i+1) * 4 -j]); + + + return payload; +} diff --git a/ubx.hh b/ubx.hh index 2d5eaa9..775c185 100644 --- a/ubx.hh +++ b/ubx.hh @@ -6,5 +6,7 @@ std::basic_string buildUbxMessage(uint8_t ubxClass, uint8_t ubxType, st std::basic_string buildUbxMessage(uint8_t ubxClass, uint8_t ubxType, const std::initializer_list& str); std::basic_string getInavFromSFRBXMsg(std::basic_string_view msg); -std::basic_string getGPSFromSFRBXMsg(int sv, std::basic_string_view msg); +std::basic_string getGPSFromSFRBXMsg(std::basic_string_view msg); +std::basic_string getGlonassFromSFRBXMsg(std::basic_string_view msg); +std::basic_string getBeidouFromSFRBXMsg(std::basic_string_view msg); struct CRCMismatch{};