pySerial works in miniterm but not in my app
d.corti at gmail.com
Sat Nov 1 16:30:43 CET 2014
Il giorno sabato 1 novembre 2014 16:04:06 UTC+1, Dario ha scritto:
> BUT.. plot twist: in Windows XP, the very same python code and usb adapter are working just right (python 2.7 and pySerial 2.7). Also with c#, no issues.
I compared the behaviour of mono and python (2.7 and 3.3) on the same hw and os, I guess something is wrong with pySerial implementation...
Mono code on Mint:
SerialPort s = new SerialPort("/dev/ttyUSB0", 19200, Parity.None, 8, StopBits.One);
s.Write("sw o01 +\r");
Device reacts correctly and I get back what I expect (the first line is because I sent the command via com port, the second is because I pushed a button on the device):
dario at ivymint ~ $ sudo ./Test1.exe
sw o01 + Command OK
Button 1 pushed
Now equivalent Python 3.3 code on Mint:
s = serial.serial_for_url('/dev/ttyUSB0', 19200, bytesize = 8, parity = 'N', stopbits = 1)
s.write(bytearray('sw o01 +\r','ascii'))
In this case, I don't receive anything for my command, and when I press I receive garbage instead of "Button 1 pushed"
dario at ivymint ~ $ sudo python3 ./test2.py
More information about the Python-list