Hello,

I'm working on a project using the arduino board that connects to my computer via USB. Anyway, I opened the "file" (FYI using linux) for the board using the fopen call and I'm wonder if there's a way to check if there's data ready to read in.

Also I know that the appropriate way to read from a serial port is to use the open() call and setup the baud rate, but is fopen() still good to use? So far I'm able to read in data accurately (when there is data sent).

Recommended Answers

Use the select() call to indicate when there is data ready to be read on a socket/file-descriptor.

Jump to Post

All 3 Replies

Use the select() call to indicate when there is data ready to be read on a socket/file-descriptor.

Do you use sockets to read from USB port???

Please see USB Design By Example

If you open a USB port and get a file descriptor, that can be used just like a socket in select() calls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.