Last active
September 2, 2021 02:20
-
-
Save andrewdoss-bit/2bbe449553d58d6f81a1e429c5a9ec6f to your computer and use it in GitHub Desktop.
Parse value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse_value(message, byte_order, start_byte, num_bytes, scale=None): | |
"""Returns a number from a sequence of bytes.""" | |
value = message[start_byte: start_byte + num_bytes] | |
value = int.from_bytes(value, byteorder=byte_order) | |
value = value * scale if scale else value | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment