Everett Wang wrote: > Thanks. I looked my code again, which is modified from example > cross-link.c. The section looks like: > > ... > irq_time = rx_event.rxpend_timestamp; > read = rt_dev_read(read_fd, &write_time, sz); > if (read == sz) { > read_time = rt_timer_read(); > printf("%3d |%16llu |%16llu |%16llu\n", nr, > irq_time - write_time, > read_time - irq_time, > read_time - write_time); > nr++; > } else if (read < 0 ) { > printf(RTASK_PREFIX "error on rt_dev_read, code %s\n", > strerror(-err)); <<<<<<<=========== > break; > } else { > printf(RTASK_PREFIX "only %d / %d byte received \n", > read, sz); > break; > } > ... > I guess I should change the strerror(-err) to strerror(-read). Indeed, the example suffers from some copy&paste mistakes. Same for the write path. And closing in a loop is no longer required. A cleanup is needed. > If I do > that, I some > times get a " code input/output error". That is better. What can cause > input/output error? Try RTSER_RTIOC_GET_STATUS to learn more. > I get my serial port in that state consistently > when I > finish running my GPS program. I can reset it to a usable serial port > again by remove and re-load xeno-16550A module. Re-opening the rtser port, ie. restarting your program doesn't help? Does re-plugging the GPS mouse change the picture? If yes, you may have to reset its hardware somehow. If no, there might be a sticky state in our serial driver, ie. a bug. > But setserial -G can't > see anything unusual. Could it be some unclosed serial port? > > My simple code is attached. > > Thanks, > > Everett > Jan