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

Don't thow an error when string can't be decoded to ascii #170

Merged
merged 4 commits into from
Jan 30, 2025

Conversation

ekaats
Copy link
Contributor

@ekaats ekaats commented Jan 27, 2025

Possible solution for Issue #80. Instead of throwing an exception when input from serial can't be parsed, it passes the current step while the loop keeps going. This will mean one 'row' is missing from the telegram. The user should keep this in mind and not expect every telegram to be formed the same way.

Another option is to yield None, which I tried first. On second thought, it is not that helpful because there is nothing to return (though we could give the 'raw' bytestring, but that would complicate things for the user as well.

Erwin Kaats and others added 3 commits January 27, 2025 23:12
Copy link
Owner

@ndokter ndokter left a comment

Choose a reason for hiding this comment

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

Looks good, but maybe we should add some logging? Else it silently fails and you wouldn't get a any signals of it doing so

try:
decoded_data = data.decode('ascii')
except:
pass
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe put a logger statement here:
logger.warning('Failed to decode telegram data: %s', e)

try:
decoded_data = data.decode('ascii')
except:
pass
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe put a logger statement here:
logger.warning('Failed to decode telegram data: %s', e)

try:
decoded_data = data.decode('ascii')
except:
pass
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe put a logger statement here:
logger.warning('Failed to decode telegram data: %s', e)

@ekaats
Copy link
Contributor Author

ekaats commented Jan 29, 2025

Makes sense, tough I'd consider outputting data rather than e. The former would just output the same information as given now. Outputting data would give the unconverted bytestring which may be more helpful.

@ndokter ndokter merged commit fa56ee1 into ndokter:master Jan 30, 2025
0 of 6 checks passed
@ndokter
Copy link
Owner

ndokter commented Jan 30, 2025

Alright the python 3.7 doesnt seem to run, but your change looks good. Thanks! I will try to make a new build soon!

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.

2 participants