How do I read all the data from a serial port?
All,
I'm trying to talk to a modem through a usb2serial port interface. I managed to open a port, send commands to the modem and read back data.
Currently, i'm doing a simple read of responses using
read (int fd, char *response, 8)
Essentially, i'm reading 8 bytes at a time (note that the modem init was done at 1152000 8n1). Also, note that i'm monitoring for responses from the serial port using "select".
However, the response from the modem is of varying length. And, a fixed number of byte reads seems to be either missing some of the bytes or adding garbage to the "response" string.
How can i effectively read the exact number of bytes (no more no less) from the modem?
Appreciate help!
|