PySerial Baud Rate anomaly

Bug #712257 reported by Art Durea
6
This bug affects 1 person
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.sourceforge.net/examples.html/#miniterm reports pyserial v1.35 ???
    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

Revision history for this message
Art Durea (imadept) wrote :

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.

Revision history for this message
Art Durea (imadept) wrote :

I borrowed a laptop (a VERY old Win95 system) and connected the serial port to the HP machine (WinXP on the hard drive and Linux Mint 8 on a LiveCD).

I ran HyperTerminal on the Win95 Laptop and configured it to:
2400 8-N-1 with no Flow Control.

On the HP tower I ran miniterm.py and configured the port and sent a few characters.
Here is the miniterm.py screen cut&paste:
===============================================================
--- Baudrate: 2400

--- Settings: /dev/ttyS0 2400,7,N,1
--- RTS active
--- DTR active
--- BREAK inactive
--- software flow control inactive
--- hardware flow control inactive
--- data escaping: raw
--- linefeed: CR/LF
--- CTS: inactive DSR: inactive RI: inactive CD: inactive


===============================================================
Note the garbage characters that were received from the laptop HyperTerminal session. The laptop 2400 baud
HyperTerminal session did not indicate any received characters.

Then I changed the miniterm.py session on the HP tower to 19200 baud. Here is
a cut&paste of the miniterm.py session:
===============================================================
Baudrate: 19200

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

asdfghjkqwertyuip
1234567890
This is a test. This is only a test.
Do not pass "GO". Do not collect $200.
===============================================================
Note the correct characters received from the 2400 baud laptop HyperTerminal session.

I also rebooted the HP tower into WinXP and started HyperTerminal. The connection was made properly with characters transferred legibly in both directions at 2400 baud for both the laptop Win95 and the tower WinXP HyperTerm sessions.

Obviously, we do NOT have a 2400 baud terminal communicating directly with a PySerial 19200 terminal. The 19200 baud indication from the miniterm.py (PySerial) session is in error and is actually 2400 baud.

Blessings in abundance, all the best, and ENJOY!
Art in Carlisle PA USA

Revision history for this message
Art Durea (imadept) wrote :

Excuse me ... again! In the 2nd paragraph of the preceding it should say: 2400 7-N-1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.