Home/Support/Support Forum/Pyserial reads data but does not write
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Pyserial reads data but does not write

0 votes
I have a Digi Transport WR41 router. The router has a serial port (RJ45) that I've connected to a serial port (DB9) on a Windows 7 PC. Based on the article found here, the cable wiring is a straight through configuration.

On the PC, I've installed RealTerm Serial Capture program and connected it to COM1.

I want to be able to read/write data through the serial connection using python (and the "Digi approved" pyserial port for SarOS).

My python script is very very basic:
import serial ser = serial.Serial(port=0, baudrate=9600, parity=serial.PARITY_EVEN, timeout=1) ser.write(‘hello world’) #ser.read(1000)

When I send data from RealTerm, I can read it just fine in python via ser.read(1000). This works all day long.

However, when I try to send data from python via ser.write('hello world'), I am unable to see it in RealTerm.

Thinking it might be a RealTerm issue, I tried other emulator/capture programs on the PC: TeraTerm and Serial Port Monitor 6 (by Eltima), but I never saw the data show up.

Serial Port Monitor 6 was the only program to show some sort activity, but I still never saw my data. I don't know enough about serial communication to make any sense of the output, but here is an excerpt:
[19/02/2015 07:58:21] 435 IRP_MJ_DEVICE_CONTROL - Request operates a serial port (COM1) STATUS_SUCCESS IOCTL_SERIAL_WAIT_ON_MASK - Request is used to wait for the occurrence of any wait event specified by using an IOCTL_SERIAL_SET_WAIT_MASK request Mask - 0x00000010 (EV_DSR) ---------------------------------------------------------------------------------- [19/02/2015 07:58:21] 437 IRP_MJ_DEVICE_CONTROL - Request operates a serial port (COM1) STATUS_SUCCESS IOCTL_SERIAL_GET_WAIT_MASK - Request returns the event wait mask that is currently set on a COM port Mask - 0x00000119 (EV_CTS | EV_DSR | EV_RING | EV_RXCHAR) ---------------------------------------------------------------------------------- [19/02/2015 07:58:21] 439 IRP_MJ_DEVICE_CONTROL - Request operates a serial port (COM1) STATUS_SUCCESS IOCTL_SERIAL_GET_MODEMSTATUS - Request updates the modem status, and returns the value of the modem status register before the update Modem Status - 0x00000080 (MS_RLSD_ON) ----------------------------------------------------------------------------------

The router has a counter for Bytes Sent. Every time I call ser.write('hello world'), I see it increment by the correct number of bytes.

I've verified that the device, RealTerm and the python code have consistent settings for the baudrate, parity, stopbits, control flow, etc.

Any other ideas why serial communication with pyserial would only work one way? Why would reads be allowed but not writes?
asked Feb 19, 2015 in 3rd Party Python and API development in other Languages by jrussell New to the Community (1 point)
edited Feb 19, 2015 by jrussell
hi  jrussell...i am new here and new to python as-well
i can't find a way to make my digi wr44 to work with serial module and i found your post saying :
"the serial connection using python (and the "Digi approved" pyserial port for SarOS)."

can u share how did u manage to import serial module as i can't seem to find a way to do it


Please log in or register to answer this question.