August 6th, 2013, 02:10 AM
PySerial setRTS() appears to do nothing
I have a USB/tty/RF device that allows for serial communications over an RF channel. I have it working when I use my program written in C# and running on a PC. But using python and pySerial, it doesn't work. Although a call to the write() method does indeed return the correct number of bytes that should have been written, the correpsonding read() method (connected to a separate USB/tty/RF device, never receives the data.
I detected the status of the RTS line on both the outgoing and incoming devices while running my C# program (which uses Microsoft's serial class) and they both show 3.3 volts. But when running the python program, using the pySerial class, the RTS line always shows 0 volts. This leads me to believe that the status of the RTS line is the difference between my C# program (using Microsot serial class) and my python program (using pySerial), and that RTS line difference is what's causing the devices to not operate properly.
I tried including the "rtscts = 1" parameter in the call to serial.Serial() and also tried the MySerialDevice.setRTS(1) method. Neither of those resulted in the RTS line actually getting set to 1, i.e. showing a 3.3 voltage on the physical line.
HOW do I get the RTS line on the device to actually get set to logical True (ie. to 3.3 volts)?
August 6th, 2013, 08:21 PM
I found a HARDWARE SOLUTION !!
I found a HARDWARE SOLUTION.
Looking through the specs for the RF board portion of the USB/tty/RF device I found the description of the EN (enable) pin. The RTS pin from the tty board connects directly to the EN pin of the RF board. Normally the RTS pin is at 3.3 volts, thereby enabling the EN pin on the RF board, which enables the RF board for operation. But when running a python program on a Raspberry Pi and using the pySerial class, that RTS pin is never enabled (no matter how much you might try to pass 'rtscts=1' to the instantiation method of the class or later calling the setRTS() method on the object.
BUT! The specs for the RF board indicate that the board is ALWAYS in enable mode IF the EN pin is UN-connected! So I disconnected the RTS line from the EN pin, and now it works!!!
It's frustrating that the pySerial class doesn't handle the RTS line properly, but at least I ow have a functioning RF link.