python-validity/validitysensor/util.py
Arvid Norlander a17ad52102
Use optimise imports in PyCharm for cleanup.
This sorts imports into sections:
* From standard library
* From other libraries
* From the current project

Each section is sorted alphabetically.
2020-08-06 11:48:19 +02:00

16 lines
330 B
Python

import re
from binascii import unhexlify
from struct import unpack
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))