I\'m trying to use pyserial to send data to an arduino. But when I open the COM port it sets DTR low and resets the board. However, I have my arduino code setup such that I
You ought to be able to disable DTR before opening the port, like this:
com = serial.Serial()
com.port = port
com.baudrate = baud
com.timeout = 1
com.setDTR(False)
com.open()
However, doing so on the current release of pyserial (2.6) on Windows throws the following exception:
..., line 315, in setDTR
ValueError: Attempting to use a port that is already open
This seems to be a bug which is fixed in the latest version of the source, SVN revision 445 on 29th December 2011 (see http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyserial/serial/serialwin32.py?view=log) with comment:
allow setRTS, setDTR before opening on Win32 (to set initial state), doc update
Which looks like it may have just missed the 2.6 release (uploaded on 2nd November 2011 see: https://pypi.python.org/pypi/pyserial).
Furthermore, looking at the current implementation of setDTR() for POSIX (in serialposix.py) it looks like this bug is not fixed and an exception is thrown if the port is not open, so a cross-platform solution looks unlikely.