Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
I'm trying to query what the size of the buffer is without actually reading it. I currently write to /dev/ttyS0 then query and then read the data. I'm just writing ABC and then receiving the same thing when I read, but the value I get when I query is some random number.
This is my call:
int bytes_avaiable;
ioctl(num, FIONREAD, &bytes_available);
I've found that it may be a timing issue. As I change the time I sleep after my write, but before my query it will return more bytes the longer I wait. When I use usleep(8000) after I have written about 4 bytes to /dev/ttyS0 it will query the right amount of data. I can't use that number however because it won't work for every size written ...
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.