structures icon indicating copy to clipboard operation
structures copied to clipboard

Raspberry Pi EEPROM example - how to calculate lengths and checksums

Open uSpike opened this issue 6 years ago • 1 comments

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?

uSpike avatar Jul 16 '18 22:07 uSpike

Why not just to use Contextual (to choose the data) and Adapted (For crc calculation)?

YonatanRubin avatar Oct 22 '19 05:10 YonatanRubin