Skip to content

Commit b68d500

Browse files
committed
teach ubx tooling about how to extract F/NAV from SFRBX
1 parent 9f91c66 commit b68d500

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

ubx.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,46 @@ basic_string<uint8_t> getInavFromSFRBXMsg(std::basic_string_view<uint8_t> msg,
118118
return inav;
119119
}
120120

121+
basic_string<uint8_t> getFnavFromSFRBXMsg(std::basic_string_view<uint8_t> msg,
122+
basic_string<uint8_t>& crc)
123+
{
124+
// byte order adjustment
125+
std::basic_string<uint8_t> payload;
126+
for(unsigned int i = 0 ; i < (msg.size() - 8) / 4; ++i)
127+
for(int j=1; j <= 4; ++j)
128+
payload.append(1, msg[8 + (i+1) * 4 -j]);
129+
130+
//
131+
132+
// 214 bitsof payload
133+
// 2 bits padding, 214 bits payload, 24 bits ctc
134+
// 216 bits -> 27 bytes
135+
unsigned char crc_buff[27]={0};
136+
unsigned int i,j;
137+
for (i=0,j= 2;i<27;i++,j+=8) setbitu(crc_buff,j,8,getbitu(payload.c_str() ,i*8,8));
138+
139+
if (rtk_crc24q(crc_buff,27) != getbitu(payload.c_str(), 214,24)) {
140+
cerr << "CRC mismatch, " << rtk_crc24q(crc_buff, 27) << " != " << getbitu(payload.c_str(), 214,24) <<endl;
141+
cerr << makeHexDump(payload) << " " << (int) getbitu(payload.c_str(), 0, 6) << endl;
142+
throw CRCMismatch();
143+
}
144+
// cerr << "F/NAV CRC MATCHED!!"<<endl;
145+
146+
crc.clear();
147+
for(i=0; i < 3; ++i)
148+
crc.append(1, getbitu(payload.c_str(), 214+i*8,8));
149+
150+
151+
std::basic_string<uint8_t> fnav;
152+
153+
for (i=0,j=0; i<27; i++, j+=8)
154+
fnav.append(1, (unsigned char)getbitu(payload.c_str() ,j,8));
155+
156+
return fnav;
157+
}
158+
159+
160+
121161
// XXX this should do the parity check
122162
basic_string<uint8_t> getGPSFromSFRBXMsg(std::basic_string_view<uint8_t> msg)
123163
{

ubx.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ std::basic_string<uint8_t> getInavFromSFRBXMsg(std::basic_string_view<uint8_t> m
1515
std::basic_string<uint8_t>& spare,
1616
std::basic_string<uint8_t>& crc, uint8_t* ssp=0);
1717

18+
std::basic_string<uint8_t> getFnavFromSFRBXMsg(std::basic_string_view<uint8_t> msg,
19+
std::basic_string<uint8_t>& crc);
20+
1821
std::basic_string<uint8_t> getGPSFromSFRBXMsg(std::basic_string_view<uint8_t> msg);
1922
std::basic_string<uint8_t> getGlonassFromSFRBXMsg(std::basic_string_view<uint8_t> msg);
2023
std::basic_string<uint8_t> getBeidouFromSFRBXMsg(std::basic_string_view<uint8_t> msg);

0 commit comments

Comments
 (0)