Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TX buffer of ttyS

Tags:

linux

I am writing a program in C, but I have no idea how I can check the output buffer for ttyS. I would like to know how many characters I can yet write to it or if the trasmitter in that moment still working

like image 729
user1052573 Avatar asked Dec 21 '25 07:12

user1052573


1 Answers

Most serial drivers support

int  count = 0;
ioctl (fd, TIOCOUTQ, &count);

where TIOCOUTQ returns the number of characters in the output buffer. It does not make much sense to find out how many bytes can be written since most Linux serial drivers will dynamically allocate buffer space as needed.

See the tty_ioctl summary.

like image 140
wallyk Avatar answered Dec 22 '25 21:12

wallyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!