-char ReadChar()
-{
- fd_set readfs;
- char ch = 0;
- int ret;
- struct timeval timeout;
-
- timeout.tv_sec = READ_TIMEOUT;
- timeout.tv_usec = 0;
-
- FD_ZERO(&readfs);
- FD_SET(giCoke_SerialFD, &readfs);
-
- ret = select(giCoke_SerialFD+1, &readfs, NULL, NULL, &timeout);
- if( ret == 0 ) return 0; // Timeout
- if( ret != 1 ) {
- printf("readchar return %i\n", ret);
- return 0;
- }
-
- ret = read(giCoke_SerialFD, &ch, 1);
- if( ret != 1 ) {
- printf("ret = %i\n", ret);
- return 0;
- }
-
- return ch;