Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debugging for dropped RTCM packets #54

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dronecan_gui_tool/panels/rtcm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class RTCM3:
def __init__(self, debug=False):
self.crc_table = None
self.debug = debug
self.discarded = []
self.reset()

def get_packet(self):
Expand Down Expand Up @@ -37,6 +38,8 @@ def parse(self):
crc2 = self.crc24(self.pkt[:-3])
if crc1 != crc2:
if self.debug:
# print all the bytes in the packet
print("{",", ".join(["%02x" % b for b in self.pkt]), "}")
print("crc fail len=%u" % len(self.pkt))
# look for preamble
idx = self.pkt[1:].find(bytearray([RTCMv3_PREAMBLE]))
Expand Down Expand Up @@ -67,8 +70,11 @@ def read(self, byte):
byte = ord(byte)
if len(self.pkt) == 0 and byte != RTCMv3_PREAMBLE:
# discard
self.discarded.append(byte)
return False

if len(self.discarded) > 0:
print("{",", ".join(["%02x" % b for b in self.discarded]), "}")
self.discarded = []
self.pkt.append(byte)
if self.pkt_len == 0 and len(self.pkt) >= 3:
self.pkt_len, = struct.unpack('>H', self.pkt[1:3])
Expand Down
Loading