Skip to content

Instantly share code, notes, and snippets.

@andrewdoss-bit
Last active September 2, 2021 02:20
Show Gist options
  • Save andrewdoss-bit/2bbe449553d58d6f81a1e429c5a9ec6f to your computer and use it in GitHub Desktop.
Save andrewdoss-bit/2bbe449553d58d6f81a1e429c5a9ec6f to your computer and use it in GitHub Desktop.
Parse value
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