gfoot wrote:
... eventually I moved to my own custom terminal program written in Python, as it gave me the most flexibility in configuring the port (arbitrary baud rates) and also allows me to write more bespoke server software, to automatically stream files with checksums in a format that's easy for the 6502 to read and check. ...
I also landed on python with the 'serial' library for serial communication. I was looking for a simple efficient way to send binary data to the 6502 machine from the command line (MacOS) and after trying several different things which had one problem or another, python did the job.
Like George I created a simple data format for transfers, mine comprising a 2 byte length, followed by data, followed by a 2 byte checksum using an
ancient BSD algorithm that is simple to implement.
Python supports manipulating the serial control lines and I have a serial to TTL that exposes a DTR signal which I use to trigger a reset of the 6502 machine prior to starting the transfer. The 6502 machine boots into a state where it's ready to receive a program upload, so I have a single command that will compile code, reset the 6502 machine, upload and then run the binary all within a few seconds. A huge improvement over pulling out and reprogramming the EEPROM every time.
The main challenge I encountered was data getting lost when the python transfer script exited. Despite writing all the data and calling the python serial 'flush' command, if the python script exited before all data had been transferred, remaining data would be lost. I couldn't find a way in python to check whether all data has been sent and I only have one-way data transfer implemented so am not able to send back an acknowledgement from the 6502 machine. In the end I resorted to calculating how long the transfer will take - based on baud rate, number of bytes and bits per byte including start and stop bits - and then waiting until that much time (plus a 2% buffer) has elapsed after starting to send, before exiting the script. This approach to ensure all data is sent has been reliable, but I'd be happy to replace with something that's less of a hack.
-Phil