Skip to content

Add support for read/write unsigned value from bytearray#316

Merged
gijzelaerr merged 3 commits into
gijzelaerr:masterfrom
LoicGRENON:utils_unsigned
Nov 19, 2021
Merged

Add support for read/write unsigned value from bytearray#316
gijzelaerr merged 3 commits into
gijzelaerr:masterfrom
LoicGRENON:utils_unsigned

Conversation

@LoicGRENON

Copy link
Copy Markdown
Contributor

Hello,

I added get_uint/set_uint and get_udint/set_udint to add support for read/write for respectively uint (2bytes) and udint (4 bytes) values from bytearray.

get_usint/set_usint already exists.

@LoicGRENON

LoicGRENON commented Oct 4, 2021

Copy link
Copy Markdown
Contributor Author

BTW, I implemented this following the same way get_usint/set_usint was done.
I think it might be maybe clearer and easier to maintain to just add an "unsigned" parameter to get_int, get_dint, get_sint and their respective set_* functions and to set the struct format character (signed or unsigned) accordingly rather than copying the same lines multiple time.

Thus, for example, get_uint(bytearray_: bytearray, byte_index: int, _int: int) would call get_int(bytearray_: bytearray, byte_index: int, _int: int, unsigned: Optional[bool]=True)

Do you want me to do such reformating of the functions ?

@gijzelaerr gijzelaerr merged commit b6481ec into gijzelaerr:master Nov 19, 2021
@LoicGRENON LoicGRENON deleted the utils_unsigned branch November 22, 2021 10:04
@gijzelaerr gijzelaerr added this to the 1.2 milestone May 25, 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