I've successfully written a full-disk image sent over the serial port! it was not reliable at 307200 so I bumped the speed down to 19200. probably a higher rate like 115200 would be OK? Or more if the read-loop were re-coded in asm
31 lines
687 B
Python
Executable file
31 lines
687 B
Python
Executable file
#!/usr/bin/python3
|
|
import time
|
|
import sys
|
|
import serial
|
|
|
|
port = serial.serial_for_url('spy:////dev/ttyUSB0',
|
|
19200
|
|
)
|
|
|
|
NUM_TRACKS = 77
|
|
NUM_SECTORS = 26
|
|
SECTOR_SIZE = 128
|
|
TLEN = NUM_SECTORS * SECTOR_SIZE
|
|
XLEN = NUM_TRACKS * TLEN
|
|
|
|
print(f"track len {TLEN}")
|
|
with open(sys.argv[1], 'rb') as f:
|
|
content = f.read()
|
|
|
|
if len(content) != XLEN:
|
|
raise SystemExit(f"Expected {XLEN} bytes but read {len(content)}")
|
|
|
|
print("start rw.exe on xerox")
|
|
for i in range(NUM_TRACKS):
|
|
trackdata = content[i*TLEN:(i+1)*TLEN]
|
|
print(len(trackdata))
|
|
c = port.read(1)
|
|
if c != b'T':
|
|
raise SystemExit(f"Expected b'T' got {c}")
|
|
print(f"sending track {i}")
|
|
port.write(trackdata)
|