-
-
Notifications
You must be signed in to change notification settings - Fork 243
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 more getter methods for utils #357
Conversation
@@ -451,7 +451,7 @@ def set_string(bytearray_: bytearray, byte_index: int, value: str, max_size: int | |||
bytearray_[byte_index + 2 + r] = ord(' ') | |||
|
|||
|
|||
def get_string(bytearray_: bytearray, byte_index: int, max_size: int) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this breaks backwards compatibility, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right with that.
Imo. max_size
is irrelevant for this kind of function.
Both sizes are in the first to bytes of the bytearray.
Byte 0 is for the max. string length (that's why a string can only be 255 (ascii) chars long, x\FF).
Byte 1 is the amount of used chars in the string.
Byte 0: 0x07
Byte 1: 0x05
[H] [E] [L] [L] [O] [ ] ][ ]
So all informations have already to be in that bytestring and the max amount is 255 as default. Otherwise it wouldn't be s7comm conform.
If sb. wants to shorten the string, it should be done outside this function, since this function is only for transforming bytearrays (form an s7) to string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_size
is important for set/write methods, where you also have to be aware of the max. length.
If you get an already read bytearray, the information is already in the bytearray.
fix shadow declarations like min and type add S-1200 compatible getter functions add missing, but not testable datatype getters
fix pycodestyle
add getter tests
add some set methods
cf0c1d9
to
6cd103c
Compare
add documentation to get_ulint add documentation to some (future) methods
fix shadow declarations like min and type
add S-1200 compatible getter functions
add missing, but not testable datatype getters
Tests will be added soon. This is a sneak-peak for now. Tested with a S1200 and supported datatypes.
Stuff, like LINT, can't be verified with a real device from me.