I have some questions regarding the using of the following functions:
I want to use readcond() function to read the data from /dev/ser3, for 100
times. The data arrives at serial port every 50ms. So I call the function
for (i=0; i<100; i++)
n = 0;
n = readcond("/dev/ser3",ptrData,20,20,5);
…; //other work, data re-organization, blablabla
} while(0 == n)
The basic idea is to force to re-read the serial port if there is no fresh
data availible (0==n).
But I’m not sure if there is no fresh data availible in the ser port buffer,
ie. no data arrives, what value does the readcond() function returns. That
equals to say, does readcond() only return a value great than 0 when there
is fresh data in the ser buffer? Anyone gives me an advice?
Another question is about the using write() function. I need to call the
write() every 2.5ms. Is there any timing mechanism that I can use to
synchronize the write() with the external event?
The 3rd one. In my application, I want to poll a keystroke to terminate a
process. By which function can I catch a keystroke. Meanwhile, if a key is
stroken, is the key character stored in a buffer? I think this is the case,
for, otherwise I cannot catch the keystroke unless I call the function
exactly when the key is stroken. Can anyone explain clearly?