Imtellingtim
Posts: 6
Joined: Thu Feb 13, 2020 8:20 am

enable/disable RS232 flow control

Sun Feb 16, 2020 3:44 pm

Is there a way to enable/disable flow control on a USB to rs232 adapter?

User avatar
jojopi
Posts: 3193
Joined: Tue Oct 11, 2011 8:38 pm

Re: enable/disable RS232 flow control

Sun Feb 16, 2020 5:43 pm

Yes. Linux supports hardware flow control with RTS/CTS, and software flow control with XON/XOFF. These are terminal modes, which can be set using the same interface that you use for the baud and parity settings, etc. Exactly what that looks like depends on the language you are using.

Note that the hardware flow control is the modern bidirectional type, where RTS really means "ready to receive". Half-duplex flow control as used on antique modems is not supported, except perhaps by toggling RTS in your own code.

It is unlikely you will need input flow control, because the Pi is easily fast enough to keep up with serial, and the kernel will buffer around 4KB for you before it loses input.

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: enable/disable RS232 flow control

Sun Feb 16, 2020 6:26 pm

From the command line, you'd use the (horribly confusing) stty command:

Code: Select all

stty -F /dev/ttyUSBx -crtscts
If you're not using RTS/CTS, there's also the ixon setting that enables XON/XOFF flow control, but you may not want that.

To get 9600 bps 8N1 with no flow control:

Code: Select all

stty -F /dev/ttyUSBx 9600 litout -crtscts
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Imtellingtim
Posts: 6
Joined: Thu Feb 13, 2020 8:20 am

Re: enable/disable RS232 flow control

Sun Feb 16, 2020 6:47 pm

Thank you both for the reply!

In the meantime I have tried sending commands over the usb to rs232 interface using termite on a PC. In termite I can choose flow control options like

- none
- xon xoff
- rts/cts
- dtr/dsr

If I call "status ?" to the TV(which I try to control) all off the 4 settings return the status of the TV. This would mean my problem has nothing to do with flow control..?

If I try sending this from the terminal on the rpi using: status ? > /dev/ttyUSB0, also nothing happens. Mostly the terminal freezes up.

Using the terminal command to turn off xon xoff did not change anything. Any idea where to look further?

Imtellingtim
Posts: 6
Joined: Thu Feb 13, 2020 8:20 am

Re: enable/disable RS232 flow control

Sun Feb 16, 2020 7:01 pm

Ok Guys, apparantly it DID work to turn off the flow control. Thanks!!!

Return to “Advanced users”