LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-11-2017, 10:29 AM   #1
BrainLock
LQ Newbie
 
Registered: Mar 2017
Posts: 3

Rep: Reputation: Disabled
Serial RTS/CTS handshake problems (loosing data)


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
 
Old 03-13-2017, 06:31 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
You need to enable flow control using stty.
 
Old 03-13-2017, 10:09 AM   #3
BrainLock
LQ Newbie
 
Registered: Mar 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
I've worked with enabled hardware flow control.
 
Old 03-17-2017, 11:08 AM   #4
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
Are both ends able to use the rate you are setting?
 
Old 03-17-2017, 11:34 AM   #5
BrainLock
LQ Newbie
 
Registered: Mar 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Yes. There is no problem with baud rate.

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:
Code:
root@sysresccd /root % setserial -G /dev/ttyS4
/dev/ttyS4 uart 16550A port 0x9400 irq 17 baud_base 921600 spd_normal skip_test
2) "disable" uart device ttyS4:
Code:
root@sysresccd /root % setserial /dev/ttyS4 uart unknown port 0x0000 irq 0
3) get free unused tty:
Code:
root@sysresccd /root % setserial -g /dev/ttyS*
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3
/dev/ttyS10, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS11, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS12, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS13, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS14, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS15, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS16, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS17, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS18, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS19, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS20, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS21, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS22, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS23, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS24, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS25, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS26, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS27, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS28, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS29, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
/dev/ttyS30, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS31, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS4, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS5, UART: 16550A, Port: 0x9408, IRQ: 17
/dev/ttyS6, UART: 16550A, Port: 0x9c00, IRQ: 18
/dev/ttyS7, UART: 16550A, Port: 0xa000, IRQ: 18
/dev/ttyS8, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS9, UART: unknown, Port: 0x0000, IRQ: 0
Let's take ttyS10;


4) Configure ttyS10 as fifoless UART 16450 with parameters received from ttyS4:
Code:
setserial /dev/ttyS10 uart 16450 port 0x9400 irq 17 baud_base 921600 spd_normal skip_test
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...).

Last edited by BrainLock; 03-17-2017 at 11:37 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable RTS/CTS in ns2.1b9a? haiying7 Programming 0 11-23-2011 11:36 PM
rts cts nivea_jmd Linux - Newbie 1 01-28-2008 11:21 AM
rts / cts handshaking serial ports nivea_jmd Programming 1 01-28-2008 06:06 AM
manually controlling RTS/CTS pappsynz Programming 4 05-25-2005 04:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration