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 to read/write space-padded fixed-length strings #378

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

vmsh0
Copy link
Contributor

@vmsh0 vmsh0 commented Aug 1, 2022

Following the discussion in issue #375, I'm offering this PR with the modifications we are using internally to support the datatype.

A recap of what this is, adapted from the commit message:

These strings are not part of the official s7comm specification, but
they are commonly found in real-world systems. They simply consist of a
byte array that contains characters forming a string, padded on the
right with spaces (ascii 32) when the string length is shorter than the
array.

This commit adds support for reading and writing, as well as usage in
tables (snap7.util.DB), and unit tests.

@vmsh0
Copy link
Contributor Author

vmsh0 commented Aug 1, 2022

I kept this separate from #377 in case you only want that fix (and not this feature), but if you wish I can both changes on your last master and offer a single pull request with both things.

Copy link
Owner

@gijzelaerr gijzelaerr left a comment

Choose a reason for hiding this comment

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

i don't think this affects any existing usage, so I don't object adding this to the lib. one small comment about type checking.

snap7/util.py Outdated Show resolved Hide resolved
@vmsh0 vmsh0 force-pushed the add-fstring-type branch 3 times, most recently from 59cfd2c to 0756e5f Compare August 3, 2022 13:12
these strings are not part of the official s7comm specification, but
they are commonly found in real-world systems. they simply consist of a
byte array that contains characters forming a string, padded on the
right with spaces (ascii 32) when the string length is shorter than the
array.

this commit adds support for reading and writing, as well as usage in
tables (snap7.util.DB), and unit tests.
@vmsh0 vmsh0 force-pushed the add-fstring-type branch from 0756e5f to b210c9c Compare August 3, 2022 13:18
@vmsh0
Copy link
Contributor Author

vmsh0 commented Aug 3, 2022

I have made the requested change as well as fixed the reported linting issues.

@gijzelaerr gijzelaerr merged commit 38d6576 into gijzelaerr:master Aug 3, 2022
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