structures
structures copied to clipboard
Raspberry Pi EEPROM example - how to calculate lengths and checksums
Hi, this is a great project!
I have a question (and contributions maybe?)
Please see the added examples/rpi_eeprom.py
file. There are certain fields that can only be computed after the build (numatoms
, eeplen
) and others that additionally need to parse the raw value of various fields (crc
). The CRC is especially bad, since I have to do a lot of work that duplicates knowledge of the CRC:
crc_data = atom_built[:-2]
crc = crcmod.predefined.mkCrcFun('crc-16')(crc_data)
atom.update(dict(crc=crc.to_bytes(2, 'little')))
Am I missing an easier way to do this?
Why not just to use Contextual (to choose the data) and Adapted (For crc calculation)?