MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / write_cyacd_row

Function write_cyacd_row

decode_pcapng.py:120–134  ·  view source on GitHub ↗
(f, row_no, data)

Source from the content-addressed store, hash-verified

118 return (sum & 0xFF)
119
120def write_cyacd_row(f, row_no, data):
121 # No idea what array ID is but it seems fine to keep it 0. Official builds also have that
122 array_id = 0
123 data_len = len(data)
124
125 # Sum all bytes and calc two's complement
126 cs_bytes = bytes([array_id, row_no&0xFF, (row_no&0xFF00)>>8, data_len&0xFF, (data_len&0xFF00)>>8])
127 checksum = checksum_calc(cs_bytes+data)
128
129 if data_len != 0x80:
130 print("Len is {} instead of 0x80", data_len)
131 sys.exit(1)
132 data_hex = ''.join("{:02X}".format(x) for x in data)
133
134 f.write(":{:02X}{:04X}{:04X}{}{:02X}\n".format(array_id, row_no, data_len, data_hex, checksum))
135
136# Write the binary as cyacd file. Can only hold one firmware image per file
137def write_cyacd(path, binary1):

Callers 1

write_cyacdFunction · 0.85

Calls 2

checksum_calcFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected