In order to improve the diagnostics for serial connected devices, I would like to add the possibility to differentiate between errors and timeouts.
For the ser_get_char() and ser_get_buf_len() we might do this by changing the return value. For the first, return value -1 would be an error, 0 a timeout and 1 success. The latter could return -1 on error, between 0 and (buflen-1) for a timeout and buflen for success. Unfortunately, the ser_get_line_alert() and ser_get_line() functions don't have a fixed number of bytes (this is determined by the endchar). So we can no longer check if an endchar was received. Bad idea. I'd prefer to add a couple of upsdebug statements in the serial.c library instead. This would leave the interface intact, at the cost of possibly redundant upsdebug statements (if the drivers already provide these). Before bailing out with -1 on error or timeout, the ser_get_*() functions would tell why (error with errno or mention timeout) at debug level 4 and show what they have received so far at debug level 5. Any objections? Best regards, Arjen -- Please keep list traffic on the list _______________________________________________ Nut-upsdev mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev
