Python 2.7.6 on Mint, pySerial 2.6

I'm trying to write a console app to control a certain device via a usb com 
port.

In miniterm (-p /dev/ttyUSB0 -e -b 19200), I can communicate correctly with 
this configuration:

--- Settings: /dev/ttyUSB0  19200,8,N,1
--- RTS: inactive  DTR: inactive  BREAK: inactive
--- CTS: inactive  DSR: inactive  RI: inactive  CD: inactive
--- software flow control: inactive
--- hardware flow control: inactive
--- data escaping: raw  linefeed: CR

sw o01 + <--- I send this
sw o01 + Command OK <--- device does what it should *and* I receive this


Now my code:

----
import serial

s = serial.serial_for_url(
        '/dev/ttyUSB0',
        19200,
        bytesize = 8,
        parity   = 'N',
        stopbits = 1,
        rtscts   = False,
        dsrdtr   = False,
        xonxoff  = False,
        timeout  = 1 # tried without
)
s.close() # tried without
s.open()
s.write('sw o01 +\r')
s.flush() # tried without
s.close() # tried with a sleep before close
----

With this I don't receive anything (tried with readline etc, omitted for 
readability), and the device doesn't react. Also, if I connect again with 
miniterm and issue the command, I first receive a "wrong command" message, as 
if some garbage was actually sent by my app, then it works again.

Isn't my config equivalent to the one in miniterm? Anything missing?

Thanks

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to