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

fix: the format for comparison between RTCM packet preamble and current byte(#14) #15

Closed
wants to merge 1 commit into from

Conversation

JeffYoung17
Copy link

As mention in #14,
the parsed RTCM packets are empty, by debugging, in rtcm_parser.py we found that combined_buffer[index] is str but _RTCM_3_2_PREAMBLE is int which make this judgment unsuccessful.
if combined_buffer[index] == _RTCM_3_2_PREAMBLE:

@robbiefish robbiefish linked an issue Jun 24, 2022 that may be closed by this pull request
Copy link
Contributor

@robbiefish robbiefish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for providing this fix. One change is required before merging.

@@ -64,19 +64,22 @@ def parse(self, buffer):
rtcm_packets = []
while index < len(combined_buffer):
# Find the start of the RTCM 3.2 packet
if combined_buffer[index] == _RTCM_3_2_PREAMBLE:
ascii_values = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me the buffer still comes in as a byte array by default, and this causes the node to crash for me. so we should have some logic in here to handle both cases. Also I think that you could use the encode function instead of looping. I had success with the following implementation, but as I said, my buffer is already bytes, so please let me know if this works for you

if isinstance(combined_buffer, str):
  ascii_values = combined_buffer.encode('utf-8')
elif isinstance(combined_buffer, bytes):
  ascii_values = combined_buffer
else:
  raise Exception('Buffer type is "{}" not a string or bytes, so we cannot parse it.'.format(type(combined_buffer)))

Also I think a better name for ascii_values would be combined_buffer_bytes

@robbiefish
Copy link
Contributor

Closing this for now. If this is a problem for anyone else feel free to reopen

@robbiefish robbiefish closed this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

the parsed RTCM packets are empty
2 participants