I wanted to transmit some data to an Arduino (choice of MCU is irrelevant here though - needs a UART) - via a com port on a PC.
The Arduino needs to process the data - so must signal the PC to 'stop' whilst it does so. Previously I used a Python script that waited for an acknowledgement after each block (buffer full) of data.
I tried to use XOn and XOff to do the same job with the Windows 'copy' command.
This 'sort' of works well.. However I can only get it to work at 9600 baud with a very specific delay after sending XOff.
Anyone able to give some ideas why this isn't working for other parameters? (for example 19200baud doesn't work)
The code here works well (try sending a file of < 65536 bytes) - I use a glcd1306 i2c to display the number of bytes received (and printNumber works for 16 bits)
After sending 'XOff' there is possibly some 'overrun' before the comms pauses (which I've tried to allow for - here I send XOff after 128 bytes received, I allow for up to 1024 bytes by the time the stop has taken effect..)
In a windows 'cmd' box
Code: Select all
mode com3 baud=9600 parity=n data=8 xon=on to=off
Then
Code: Select all
copy filename /b com3
One problem this doesn't address is 'end of file' - for my needs the Arduino can calculate the length of the file from it's header. For my test file (10795 bytes and others) - it seems to work fine - but I can't see how 'data' is set true to ever display this (but it does - but as far as I can see the final bytes should be lost... I added a crude timeout - but it didn't make a difference..)
I suspect that XOff isn't actually stopping transmission and the buffer is large enough to cope with a 500ms delay.
Anyone any thoughts on this??
Martin