add more getter methods for utils#357
Conversation
| 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.
this breaks backwards compatibility, right?
There was a problem hiding this comment.
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.
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.