From: Martin Ling Date: Sun, 21 Sep 2014 17:36:00 +0000 (+0100) Subject: gmc-mh-1x-2x: Mark serial read calls as nonblocking. X-Git-Tag: libsigrok-0.4.0~958 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=4a0eda2b701d4ef26dc3f58f4ff00bbbbb21b246;p=libsigrok.git gmc-mh-1x-2x: Mark serial read calls as nonblocking. These calls were already nonblocking since the driver opens the port with the SERIAL_NONBLOCK flag. They only read one byte. A return value of zero is not handled, but should not occur in theory due to the G_IO_IN check. It might be good to add handling of a zero return anyway, since I'm not sure if this is always accurate. --- diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index 06cae38b..e6de8d52 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -1107,7 +1107,7 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data) if (revents == G_IO_IN) { /* Serial data arrived. */ while (GMC_BUFSIZE - devc->buflen - 1 > 0) { - len = serial_read(serial, devc->buf + devc->buflen, 1); + len = serial_read_nonblocking(serial, devc->buf + devc->buflen, 1); if (len < 1) break; buf = *(devc->buf + devc->buflen); @@ -1201,7 +1201,7 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data) if (revents == G_IO_IN) { /* Serial data arrived. */ while (GMC_BUFSIZE - devc->buflen - 1 > 0) { - len = serial_read(serial, devc->buf + devc->buflen, 1); + len = serial_read_nonblocking(serial, devc->buf + devc->buflen, 1); if (len < 1) break; buf = *(devc->buf + devc->buflen);