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 parse error errors #864

Merged
merged 1 commit into from
Nov 15, 2023
Merged

fix parse error errors #864

merged 1 commit into from
Nov 15, 2023

Conversation

taclane
Copy link
Contributor

@taclane taclane commented Nov 14, 2023

Debug variables s0 and s1 in p25_parser.cc are typed as uint8_t. When displayed in an iostream, these variables will be presented as a character, not a number, since that type is interpreted as an alias for unsigned char.

BOOST_LOG_TRIVIAL(error) << "P25 Parse error, s: " << s << " s0: " << s0 << " s1: " << s1 << " shift: " << shift << " nac: " << nac << " type: " << type << " Len: " << s.length();

This console message can display when conditions are bad or other receiver problems occur, and it does not seem ideal to inject invalid, or random, UTF8 characters into the user's console or log files. Additional examples of this can also be seen in #775.

[2023-11-13 15:14:18.618786] (error)   P25 Parse error, s:  s0:
 s1: � shift: 0 nac: 129 type: 65535 Len: 0

Using a uint16_t or short instead should avoid this in the future, and numerically display values for those variables.

Edit: An example of a "corrected" parse error message is below:

[2023-11-13 22:24:17.747166] (error)   P25 Parse error, s:  s0: 0 s1: 97 shift: 0 nac: 97 type: 65535 Len: 0

@robotastic
Copy link
Owner

That looks much better - thanks!

@robotastic robotastic merged commit f32aa56 into robotastic:master Nov 15, 2023
1 check passed
@tadscottsmith
Copy link
Contributor

FWIW - I've noticed that if the signal is bad enough that this message is displayed, most of the variables in that message are just garbage.

@taclane
Copy link
Contributor Author

taclane commented Nov 15, 2023

FWIW - I've noticed that if the signal is bad enough that this message is displayed, most of the variables in that message are just garbage.

That is my experience too. You almost never see the message when things are working correctly. But the times it does show up probably should not dump random Unicode or unsanitized control characters to console.

@taclane
Copy link
Contributor Author

taclane commented Nov 15, 2023

After checking back on things, #870 is the correct fix for this issue. Changing the type declaration has unhelpful side-effects.

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.

3 participants