![TeraBee Evo Thermal 33 User Manual Download Page 19](http://html1.mh-extra.com/html/terabee/evo-thermal-33/evo-thermal-33_user-manual_1088191019.webp)
Appendix
A.1 CRC validation
When using python, you will find a dedicated module named ‘
crcmod
’. Please install the
module using ‘
pip
’ with the following command:
pip install crcmod
A.1.1 How to calculate CRC8 checksum for Evo Thermal
After defining this function:
self.crc8 = crcmod.predefined.mkPredefinedCrcFun(
'crc-8'
)
You will be able to use the above function on any buffer, as illustrated in the code below. In
this case ‘ack’ variable is a 4-byte buffer containing an ACK response.
crc = self.crc8(ack[:
3
])
if
crc == ord(ack[
3
]):
# Check that CRC’s are matching
...
A.1.2 How to calculate CRC32 checksum for Evo Thermal
After defining this function:
self.crc32 = crcmod.predefined.mkPredefinedCrcFun(
'crc-32-mpeg'
)
The following function reads a full frame from the Evo Thermal and validates the CRC32
checksum:
def
get_thermals
(self):
got_frame =
False
while
not
got_frame:
with
self.serial_lock:
### Polls for header ###
header = self.port.read(
2
)
header = unpack(
'H'
, str(header))
if
header[
0
] ==
13
:
Copyright
©
Terabee 2018
Terabee, 90 Rue Henri Fabre
01630, St Genis-Pouilly, France (next to CERN)
19/20