Making progress. Finally got my Python code running on my OrangePI to reliably talk to the Arduino GPIB. After powering up the Arduino, the first communication always failed, but if I used a terminal, it always worked first time.
I had the scope out, then the logic analyser which all showed no problem at all.
Finally worked out that the Arduino Duemilanove has the lovely property that before you connect to the serial port, the DTR is 5V. The first time you connect to the USB serial port, the DTR goes low which resets the Arduino via a capacitor coupling. Stays low after that.
The reason why the terminal always worked was I always took more then 1.5 seconds to send a command after opening.
I gather the FTDI rs232 behaviour is well known - I just didn't know.
I guess the CH340 boards I have on order will do the same thing. It is OK - just needs a 2 second delay after opening the serial port - but it probably means I should just leave the port open all the time while the python code is running.
I may do some changes to Emanuele's code and I will just use Linux diff and patch to record the changes to get around the NoDerivative license. Is that legal?
Here is the words from the CC nonderivative license:
NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material.
It is OK to freely distribute unmodified CC NoDerivative-licensed source code. Not sure about a diff file that can modify this source. Any opinions?
I have got my up-to-date Cygwin
diff and
patch for use on Windows, but the other thing I discovered is I had to rename
patch.exe, since if a program contains the word "patch", Windows insists it has to be run under administrative permissions. If you rename any program
patch.exe or
somethingpatch.exe, it will suddenly only run under Administrative permissions. If it is renamed to
pa_tch.exe, it is fine.