Send big binaries with a pause (hack).

This commit is contained in:
giomba 2023-10-16 22:13:55 +02:00
parent 600b1d7ab3
commit 6920bd9bd4
3 changed files with 43 additions and 0 deletions

View File

@ -1,5 +1,7 @@
PROJECT := demo
SERIALPORT = /dev/ttyUSB0
SRC = \
src/ceda_print_a.asm \
src/ceda_print_c.c \
@ -30,9 +32,17 @@ $(OUTDIR)/$(PROJECT)_code_compiler.bin: $(OBJ) | $(OUTDIR)
%.o: %.asm
zcc +z80 -c -o $@ $<
%.pkt: %.prg
script/makepacket.py $< > $@
$(OUTDIR):
mkdir -p $@
.PHONY: send
send: $(OUTDIR)/$(PROJECT).pkt
stty -F $(SERIALPORT) 9600 crtscts
script/sendpacket.py < $<
.PHONY: clean
clean:
$(RM) $(OBJ)

17
script/makepacket.py Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/python3
import sys
import struct
filename = sys.argv[1]
ifile = open(filename, 'rb')
content = ifile.read()
address = content[0] + content[1] * 256
data = content[2:]
size = len(data)
sys.stdout.buffer.write(struct.pack("<HH", address, size))
sys.stdout.buffer.write(data)

16
script/sendpacket.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/python3
import serial
import time
import sys
ser = serial.Serial('/dev/ttyUSB0', 9600)
while True:
c = sys.stdin.buffer.read(1)
if len(c) == 0:
break
ser.write(c)
# sys.stdout.buffer.write(c)
time.sleep(0.001)