LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-30-2022, 10:16 AM   #1
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Rep: Reputation: 19
Kernel serial API - is there a way to know when all bytes have been clocked out?


Hi all,

I am writing an application that needs to know when all bytes have actually been clocked out of the UART buffer. In my application I can write to the serial port (and even flush it), but that only tells me that the data has been flushed to the buffered hardware. There is still some time afterward during which bytes are being clocked out, and my application doesn't know when that process is done.

I am not aware of a way to check that all bytes are actually done being placed on the wire. Does the kernel's serial API have some way to check how many bytes are in a serial hardware buffer?

Thanks!
 
Old 09-30-2022, 01:00 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,269

Rep: Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314Reputation: 1314
The standard 16550 UART has a TE status bit which means transmit FIFO is empty. Not sure how you could get it from user space. I don't think the hardware provides any indication of the number of bytes in the FIFO, and due to flow control there is no way to predict how long it could take to empty.
 
Old 10-01-2022, 12:00 PM   #3
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Original Poster
Rep: Reputation: 19
Quote:
The standard 16550 UART has a TE status bit which means transmit FIFO is empty. Not sure how you could get it from user space. I don't think the hardware provides any indication of the number of bytes in the FIFO, and due to flow control there is no way to predict how long it could take to empty.
I think you're right. This is a Raspberry Pi 4, and the peripheral documentation (page 15) states that this uart (a "mini-uart" with some 16550-like attributes) has a register (AUX_MU_STAT_REG) that "provides a lot of useful information about the internal status of the mini UART not found on a normal 16550 UART."

In particular, one bit of this register indicates that "the transmitter is idle and the transmit FIFO is empty."

So, I think you're right that the data is available, and you're also right that getting to it from user-space might not be easy. I will look into it further, but please let me know if you have any other guidance.

Thanks!
 
  


Reply

Tags
kernel 5.15, serial port, uart


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] RHEL8 udev & partprob Error: Partition(s):1,2,3.. /dev/sdc1 have been written, but we have been unable to inform the kernel of the change scofieldd Red Hat 5 11-08-2019 12:02 PM
gpg: do_plaintext(): wrote 1210414045 bytes but expected 822504068 bytes MensaWater Linux - Software 6 02-27-2018 09:48 AM
Is it okay if my sector size is "512 bytes / 4096 bytes" Altiris Slackware 5 07-31-2015 04:19 AM
LXer: Benchmarking the ODroid XU: A Fast-Clocked Quad A15 ARM Machine LXer Syndicated Linux News 0 12-17-2013 10:00 PM
TX bytes vs. httpd bytes ovrload Linux - Networking 3 10-12-2005 05:19 PM

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

All times are GMT -5. The time now is 08:35 PM.

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