python-validity/validitysensor/util.py
Viktor Dragomiretskyy 75c6ddb5b3 * Roll back async changes for enroll & identify.
* Add a couple of tweaks to stop the sensor from crashing.
* A few more comments and TODOs
2020-07-16 23:13:46 +12:00

17 lines
329 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))