From ce6e3be35b08f3a74e9c84061f5818c639e040f3 Mon Sep 17 00:00:00 2001 From: Daniele Verducci su MatissePenguin Date: Wed, 9 Dec 2020 22:23:12 +0100 Subject: [PATCH] WIP Writing terminal deployer --- .vscode/settings.json | 5 ++ assembly/applications/halt_test.asm | 6 ++ .../hd44780_lcd_test_procedure.asm | 0 python/terminal_deployer.py | 72 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 assembly/applications/halt_test.asm rename assembly/{ => applications}/hd44780_lcd_test_procedure.asm (100%) create mode 100755 python/terminal_deployer.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..96f4f72 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.pythonPath": "/usr/bin/python3", + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/assembly/applications/halt_test.asm b/assembly/applications/halt_test.asm new file mode 100644 index 0000000..f919c16 --- /dev/null +++ b/assembly/applications/halt_test.asm @@ -0,0 +1,6 @@ +nop +nop +nop +nop +nop +halt diff --git a/assembly/hd44780_lcd_test_procedure.asm b/assembly/applications/hd44780_lcd_test_procedure.asm similarity index 100% rename from assembly/hd44780_lcd_test_procedure.asm rename to assembly/applications/hd44780_lcd_test_procedure.asm diff --git a/python/terminal_deployer.py b/python/terminal_deployer.py new file mode 100755 index 0000000..3240de5 --- /dev/null +++ b/python/terminal_deployer.py @@ -0,0 +1,72 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +""" @package docstring +ARDUINO PARALLEL TERMINAL DEPLOYER +This software sends a compiled Z80 binary files to Pat80 monitor via an arduino +with flashed arduino_terminal firmware. + +USAGE: +Connect the arduino to a Pat80 I/O port. +Flash /arduino/arduino_terminal firmware into the Arduino. +Connect the Arduino to a PC via USB and power on Pat80 +In the Pat80 Memory Monitor select I for IMMEDIATE LOAD +Run this program providing the Arduino USB port and a Z80 binary file +The code contained will be copied in Pat80's memory and executed immediately. + +DISCLAIMER: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +import serial +import time + +class TerminalDeployer: + def __init__(self, port, baudRate, fileName): + ser = serial.Serial(port, baudRate) + print "Serial port {} opened with baudrate {}".format(port, str(baudRate)) + + ser.write(73) + while True: + x = ser.read() + print(x) + time.sleep(1) + ser.write(b'v') + + # Open z80 bin file + ''' + with open(fileName, "rb") as f: + print "Sending command IMMEDIATE" + ser.write(b'I') + time.sleep(1) + print "Sending file {}".format(fileName) + byte = f.read(1) + while byte: + print(byte) + ser.write(byte) + byte = f.read(1) + f.close() + + ser.close() + print "Completed" + ''' + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument('port', help="arduino parallel monitor USB port") + parser.add_argument('baudrate', help="arduino parallel monitor USB baudrate") + parser.add_argument('file', help="asm binary file to send") + args = parser.parse_args() + + td = TerminalDeployer(args.port, args.baudrate, args.file)