(f, row_no, data)
| 118 | return (sum & 0xFF) |
| 119 | |
| 120 | def 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 |
| 137 | def write_cyacd(path, binary1): |
no test coverage detected