serial.c: Re-enable serial_read() error reporting.
libserialport now returns 0 (not SP_ERR_FAIL) as return value when a non-blocking read would return EAGAIN. This fixes bug #188.
This commit is contained in:
parent
25b66c3c61
commit
c4d85a4026
|
@ -234,7 +234,7 @@ SR_PRIV int serial_read(struct sr_serial_dev_inst *serial, void *buf,
|
||||||
size_t count)
|
size_t count)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
//char *error;
|
char *error;
|
||||||
|
|
||||||
if (!serial) {
|
if (!serial) {
|
||||||
sr_dbg("Invalid serial port.");
|
sr_dbg("Invalid serial port.");
|
||||||
|
@ -253,15 +253,14 @@ SR_PRIV int serial_read(struct sr_serial_dev_inst *serial, void *buf,
|
||||||
case SP_ERR_ARG:
|
case SP_ERR_ARG:
|
||||||
sr_err("Attempted serial port read with invalid arguments.");
|
sr_err("Attempted serial port read with invalid arguments.");
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
// Temporarily disabled, will come back later.
|
case SP_ERR_FAIL:
|
||||||
// case SP_ERR_FAIL:
|
error = sp_last_error_message();
|
||||||
// error = sp_last_error_message();
|
sr_err("Read error: %s.", error);
|
||||||
// sr_err("Read error: %s.", error);
|
sp_free_error_message(error);
|
||||||
// sp_free_error_message(error);
|
return SR_ERR;
|
||||||
// return SR_ERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret > 0)
|
||||||
sr_spew("Read %d/%d bytes (fd %d).", ret, count, serial->fd);
|
sr_spew("Read %d/%d bytes (fd %d).", ret, count, serial->fd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue