File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1515bin_data = bytearray (in_file .read ())
1616in_file .close ()
1717
18+ # Magic number (VID/PID), hard coded for MKR VIDOR 4000 right now
19+ magic_number = bytearray ([0x23 , 0x41 , 0x80 , 0x54 ])
20+ print (magic_number )
21+
22+ # Version field (byte array of size 8)
23+ version = bytearray (8 )
24+ print (version )
25+
26+ # Prepend magic number and version field to payload
27+ bin_data_complete = magic_number + version + bin_data
28+
1829# Calculate length and CRC32
19- bin_data_len = len (bin_data )
20- bin_data_crc = crccheck .crc .Crc32 .calc (bin_data )
30+ bin_data_len = len (bin_data_complete )
31+ bin_data_crc = crccheck .crc .Crc32 .calc (bin_data_complete )
2132
2233# Write to outfile
2334out_file = open (ofile , "wb" )
2435out_file .write ((bin_data_len ).to_bytes (4 ,byteorder = 'little' ))
2536out_file .write ((bin_data_crc ).to_bytes (4 ,byteorder = 'little' ))
26- out_file .write (bin_data )
37+ out_file .write (bin_data_complete )
2738out_file .close ()
You can’t perform that action at this time.
0 commit comments