PySerial Baud Rate anomaly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pyserial (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
I have an instrument I am trying to drive from the serial port under Linux Mint 8. The instrument runs fine using it's application on an old Win98 machine (P2-350) which initializes the port baud rate to 2400, and I can functionally test the interface using W98 HyperTerm set to 2400 baud.
I set up the instrument on a different machine and proceeded to test under Python in a Mint 8 LiveCD system. Once I figured out the port arrangement, I got the device to communicate, but only with ~3 garbage characters at 2400 baud. I tried different baud rate settings and discovered that I got proper messages when the baud rate was set to 19200. ??? When I run WinXP HyperTerm on this machine, I have to set the baud rate to 2400, which I believe is the correct speed. The instrument would not communicate when the baud rate was set to 19200.
Here are the details of the system:
HP Compaq dx2400 Core 2 Duo
1 Serial Port - Win XP recognizes it as COM3 at address hex 3E8 and HyperTerm communicates with the instrument at 2400 baud (19200 baud does NOT work). The reassignment of COM3 hardware to Linux /dev/ttyS0 may be significant.
Linux Mint 8 LiveCD Python/PySerial recognizes the serial port as /dev/ttyS0
Python v2.6.4rc2
PySerial from pyserial-2.5.tar.gz
miniterm.py downloaded from the pyserial.
getattr(serial, 'VERSION', 'unknown') returns 1.35
miniterm.py communicates with the instrument, but only if I set the baud rate to 19200 - only ~3 garbage characters are received if the baud rate is set to 2400.
I wrote a primitive application in python which I got to work. The initialization code is:
import serial
ser = serial.Serial(port = '/dev/ttyS0', baudrate = 19200, bytesize = 7, parity = 'N', stopbits = 1, timeout = 1)
This initialization allows proper communication with the instrument. If I change the "baudrate" to 2400, I get ~3 garbage characters back from the instrument.
I believe that the real baud rate for the instrument is 2400 baud, not 19200. I believe that the pyserial library is setting the baud rate incorrectly ... setting 19200 on my configuration actually results in a baud rate of 2400 baud.
FYI: the instrument is a primitive Metex ME-22 multimeter with a 9 pin RS-232 interface. The protocol is as follows:
2400, 8, 1, No parity. DTS must be asserted. RTS must be UNasserted or disconnected. Any single character sent from the computer commands a reply from the meter. The response message is a 14 character text string with the measurement value and meter settings.
Thank you for your gracious assistance with this issue.
Art in Carlisle PA USA
Minor error above in the last paragraph - correction changes "8" to "7":
RS-232 interface. The protocol is as follows:
2400, 7, 1, No parity.