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 support for byte strings in the device information fields #693

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

sytsereitsma
Copy link
Contributor

I'm trying to emulate a modbus device that has non ASCII data in the vendor name part of the device information. The library cannot correctly encode this, because when encoding this info it is encoded as utf-8. For example, a vendor name of "\xF0\x12\x34" ends up as b"\xC3\xB0\x12\x34" in the encoded payload.

This PR changes the encoding of the device information fields to support both bytes objects and str objects.

The appropriate unit tests have been added.

Iterate over the list of identity values and append the bytes if the field is a byte string, append the encoded string otherwise.
@sonarcloud
Copy link

sonarcloud bot commented Dec 16, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dhoomakethu dhoomakethu merged commit e9e0697 into pymodbus-dev:dev Jan 27, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants