Simon wrote:
So my thought now is somehow Basic goes wrong when parsing some line of code. Perhaps that line has errors in it due to overrun errors and it's some combination of bytes in that line that makes it all go wrong. How the heck I will work out what that is I don't know!
Simon,
I had similar problems when uploading large programs to EhBASIC through the RS232 connection. Not crashing like in your case but corrupting the uploaded program.
With 38400 Baud and 256 bytes of FIFO it would work O.K. if the BASIC program would contain ascending line numbers only and a NEW command was issued prior to upload, so no lines would have to be inserted. Just loading a modified program over an existing one would corrupt some lines. On insertion BASIC has to move all higher numbered lines and needs to rebuild the next line address chain, which may take too much time.
So I played with some modifications to the FIFO. I added x-off/x-on flow control and set the high watermark (x-off) at 192 bytes, the low watermark (x-on) at 128 bytes. That would work O.K. when using the PC's built in serial port, but still not O.K. with a USB to serial converter. USB converters seem to have a higher latency.
Now I changed the watermarks to 128 and 64. Then it would work O.K. over USB with Tera Term but still not with PUTTY. PUTTY seems to have a larger block size and probably requires a larger FIFO.
So it makes a big difference how you feed the beast. Even after flow control stops the other side, it will still send its remaining hardware buffer. If you can't fix it from this side, you need to log what is sent to BASIC in order to make it corrupt memory and then try to find the bad combination of characters causing BASIC to crash. Good luck!