Still corrupt:
[removed / not working correctly]
and called by
Code:
import serial
import time
def read_rom_data(serial_port, baud_rate, output_file):
ser = serial.Serial(serial_port, baud_rate)
time.sleep(2) # wait for the serial connection to initialize ( sleep 1 fails)
ser.write(b'R') # Send the read command Arduino P1
with open(output_file, 'wb') as file:
for i in range(1024 * 1024): # double?
data = ser.read(1)
file.write(data)
ser.close()
print(f"ROM dumped to {output_file}")
if __name__ == "__main__":
serial_port = 'COM3' # using PS to USB port 2
baud_rate = 115200
output_file = 'rom_dump.bin'
read_rom_data(serial_port, baud_rate, output_file)
last attempt:
Code:
import serial
import time
import os
def read_rom_data(serial_port, baud_rate):
ser = serial.Serial(serial_port, baud_rate)
time.sleep(2) # Wait for the serial connection to initialize
ser.write(b'R') # Send the read command to the Arduino
data = ser.read(1024 * 1024)
ser.close()
return data
def compare_rom_reads(reads):
reference = reads[0]
for read in reads[1:]:
if read != reference:
return False
return True
if __name__ == "__main__":
serial_port = 'COM4' # try 2nd adapter
baud_rate = 115200
reads = []
for i in range(10):
print(f"Reading ROM... Attempt {i+1}")
rom_data = read_rom_data(serial_port, baud_rate)
reads.append(rom_data)
time.sleep(1) # Wait a second between reads
if compare_rom_reads(reads):
print("All ROM reads are identical.")
output_file = 'rom_dump.bin'
with open(output_file, 'wb') as file:
file.write(reads[0])
print(f"ROM data dumped {output_file}")
else:
print("ROM reads are not identical.")
for idx, data in enumerate(reads):
output_file = f'rom_dump_attempt_{idx + 1}.bin'
with open(output_file, 'wb') as file:
file.write(data)
print(f"ROM data from attempt {idx + 1} has been written to {output_file}")