[SOLVED] Serial RTS/CTS handshake problems (loosing data)
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a small device with microcontroller which is connected to PC with RS232 using null-modem cable. I'm using SystemRescueCD OS. Device uses hardware flow control and one-byte FIFO (it sets asserts RTS line after receiving start bit to block transmission of other bytes). I have a problem with transmitting data to device: when I'm trying to send data to device with hardware flow control enabled, it receives only several bytes from transmitting buffer (first byte of every 16 bytes to transmit). If I'm trying to send bytes slowly (for example, from keyboard using minicom) - there are no problems. Oscilloscrope shows no problems with asserting RTS line. Looks like that it's a problem with serial port FIFO on my PC: by default Linux detects serial port as 16550A with 16-byte fifo and linux tries to fill it and transmission stops only after last 16-byte transmission (first byte is sent while receiver's RTS not asserted, 15 bytes are sent while receiver's RTS is asserted and linux waits for deassertion receiver's RTS). I've tried to change serial port type to 8250 and 16450 with setserial - no changes. I've tried to set serial port parameter xmit_fifo size to 1 - no changes. I've tried to send data byte-by-byte with tcdrain() call after every byte send - transmission works without any problems and data losses (system does not try to fill FIFO and waits for data transmission). Looks like that serial ports on my motherboard are based on Winbond W83627 chip.
So... May be I'm wrong, but looks like it's serial's driver FIFO problem. Is there any way to disable serial port FIFO from userspace?
Last edited by BrainLock; 03-11-2017 at 10:33 AM.
Reason: adding information about serial port types for setserial
I've found a solution to disable 16550A FIFO. Looks like that there is a bug in kernel: there are no changes in tx_loadsz, fifosize and other UART parameters in kernel after changing UART type using ioctl TIOCSSERIAL. To disable FIFO I need to change UART type to 16450/8250, but it does not works: uart parameters does not change! But... There is a way to reregister UART in system with parameters I've need: just move parameters of uart with changes to any free (never used) tty: for example ttyS10.
My solution: for example, I want to disable FIFO on UART with dev ttyS4:
1) get uart parameters:
That's all! Now ttyS10 works as UART without FIFO and without loosing bytes! But there is a problem: if UART uses irq from other device (on PCI boards with serials and parallel port for example), my solution will not work (kernel show messages about IRQ conflict, so... just need additional googling/reading manuals/etc...).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.