Blocked Read N bytes from UART
Hello,
I want to read from ttyS0 TBD bytes. I need that my thread will be blocked for TBD seconds till I receive all N bytes.
So I used the following code:
m_Handle = open( "ttyS0", O_RDWR);
fd_set set;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
FD_ZERO(&set); // clear the set
FD_SET(m_Handle, &set); // add our file descriptor to the set
rc = select(m_Handle + 1, &set, NULL, NULL, &timeout);
rc = read(m_Handle, pData, Size);
Will this do the work ?
Thank you,
Zvika
|