Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware flowcontrol (RTS CTS) does not work #89

Open
ril3y opened this issue Mar 13, 2016 · 7 comments
Open

Hardware flowcontrol (RTS CTS) does not work #89

ril3y opened this issue Mar 13, 2016 · 7 comments
Labels

Comments

@ril3y
Copy link

ril3y commented Mar 13, 2016

No matter what is passed the RTS pin will not go high. We have tested this on windows and osx and its the same. Here is a relevant snippet from the discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?t=51582&p=398290

Since I'm using the pySerial class to do the serial operations I'm not directly accessing any pins on the board at all. In my case the problem seems to be a difference between how the python pySerial class works and the Microsoft serial class works. The Microsoft class works perfectly fine. The pySerial class does not, whether it's running on a PC or on my Raspberry Pi. The difference is that the Microsoft serial class properly sets the RTS line (which feeds into the EN [enable] line of the RF board), but the pySerial class does not. In fact, the pySerial method, setRTS(), doesn't appear to actually set the RTS line. That's why I had to default to essentially cutting off the pin between the RTS and the EN, leaving EN un-connected, which leaves the RF device in a constant enabled state.

@PY1CX
Copy link

PY1CX commented Mar 23, 2018

As by 23 march 2018 this still doesn't work. Testing on Linux Mint and tried on Python 3.5 and 2.7.

@xlgforever
Copy link

As by 23 march 2018 this still doesn't work. Testing on Linux Mint and tried on Python 3.5 and 2.7.

I use setRTS(value=1), but the pin in the fpga is always low. it is seems that the function of setRTS is disable? what show i do to implement the same functionality?

@zsquareplusc
Copy link
Member

if you want to have control over the RTS and DTR pins, do not use the rtscts keyword parameter when creating the Serial instance, because that option enables hardware flow control and any call to setRST() will have no effect...

@diamondman
Copy link

@ril3y Did zsquare's answer solve your problem? Maybe we can get this issue closed out.

@Amulek1416
Copy link

Amulek1416 commented Mar 30, 2021

I'm also having a problem when setting rtscts=True. I'm using an FPDI chip with Python 3.9.1 (the FT232RL) and can't seem to get any change in the RTS or CTS pins when using a logic analyzer.

EDIT: To clarify, I'm not using the RTS and DTR pins and have those set to False

@Amulek1416
Copy link

Amulek1416 commented Apr 1, 2021

I found a solution! (At least to my problems)

Apparently when setting rtscts=True, pyserial won't send any information until the buffer is full. If you want to send information that doesn't fill up the buffer, you need to either fill up the buffer with zeros (and deal with those on the microcontroller's end) or do the logic for the CTS and RTS yourself.

Here is some example code to do the RTS and CTS logic yourself:

import time
import serial

# Since we are doing the RTS and CTS logic ourselves, keep 'rtscts=False'
mySerial = serial.Serial(port='COMX', baudrate=9600, rtscts=False)

# To send some information:

dataToSend = 'HelloWorld!'
mySerial.setRTS(True)

# Wait for CTS signal
while not mySerial.getCTS():
    pass

mySerial.write(bytes(dataToSend, 'ascii'))
time.sleep(0.25) # Wait for the data to have sent before disabling RTS
mySerial.setRTS(False)

@davegravy
Copy link

I'm finding it will write to TX independent of the state of CTS. Strange because underlying termios works fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants