python-validity/validitysensor/util.py
Viktor Dragomiretskyy 6a24f89a51 Refactor package name
2020-07-09 16:28:38 +12:00

13 lines
235 B
Python

import re
from struct import unpack
from binascii import unhexlify
def assert_status(b):
s,=unpack('<H', b[:2])
if s != 0:
raise Exception('Failed: %04x' % s)
def unhex(x):
return unhexlify(re.sub('\W', '', x))