python-validity/validitysensor/util.py
Arvid Norlander 9dc0c14aed
Automated formatting with YAPF.
PEP8 settings are used except the low 80 column limit has be increased
to a more reasonable 100 columns.
2020-08-06 11:46:19 +02:00

16 lines
330 B
Python

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