This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Read bytes from a file descriptor
#include <sys/modem.h> int modem_read( int fd, char* buf, int bufsize, int quiet, int timeout, int flags, int (*cancel)(void) );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
This function is in libc.a, but not in libc.so (in order to save space). |
The modem_read() function reads up to bufsize bytes from the device specified by the file descriptor, fd, and places them into the buffer pointed to by buf.
If no characters are received within the given timeout, modem_read() returns with -1.
When at least one character has been received, modem_read() returns if the flow of incoming characters stops for at least the quiet time period. The number of characters saved in buf is returned.
If you provide a cancel function, it's called once each quiet time period while waiting for input. If this function returns a nonzero value, modem_read() returns -1 immediately and sets errno to ETIMEDOUT. You can use the cancel function as a callback in a graphical dialer that needs to support a cancel button to stop a script (see modem_script()).
Zero for success, or -1 on failure (errno is set).
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Read the Caveats |
Thread | Read the Caveats |
Depending on what you do in your cancel function, modem_read() may or not be signal handler or thread-safe.
modem_open(), modem_script(), modem_write()