Closed jiandong1997 closed 6 years ago
Which platform is this? POSIX? The library was originally written for embedded platforms with hard-wired interfaces. On Win32, it should return -EIO
if there's an error reading from the port -- perhaps we could return something similar on the POSIX platform?
Yes. it is POSIX. it will be great that code could return something similar on POSIX platform which can be checked by application code using the C library.
Revisiting this because I recently worked on the POSIX serial driver. I don't think I fully understood your original bug report, but I have pushed commit c8b0d34a03 with changes to pass xbee_ser_read()
errors up through xbee_dev_tick()
(and wpan_tick()
) so you can know when the serial port goes away.
in the function xbee_ser_read, if the result of read is zero 0 when bufsize isn't 0, it means the device is not readable. but as the the function doesn't show the difference between EAGAIN and ended fd, both of cases return 0. this doesn't give external callers, such as wpan_tick, a chance to know if the device is removed. so I suggest to add some state/flag to indicate if the serial port is readable or not.