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.
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 have a question regarding reading the serial part. Currently, I have opened a serial port and configured it, and then mapped a stream to it using fdopen(). I then use the returned FILE * stream to do all my io (using fread, fwrite). Since my programming basically sits for commands on the serial port, using while fread() is very CPU intensive, taking up nearly 100%. Is there any way to use streams and have it block on reading?
This is my code to open the port.. which calls the code to configure the serial port.
FILE * open_port(void)
fd = open("/dev/ttyS0",O_RDWR | O_NOCTTY | O_NDELAY);
perror("open_port: Unable to open /dev/ttyS0 - ");
printf("Serial Port 1 Open\n");