Reputation: 31
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
Upvotes: 3
Views: 1460
Reputation: 57774
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.
Upvotes: 1