X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ftondaj-sl-814%2Fprotocol.c;h=44d12ec4f40866f61e477493d6c8974cac93ea26;hb=8e2d6c9db788785466d61fdac4d8fdc1535bc20c;hp=b4deee1364f5b6fafdec8eeef16ee1a3de687927;hpb=47d98603e706e8c4f2da2b031f31c6dd2cc3b246;p=libsigrok.git diff --git a/src/hardware/tondaj-sl-814/protocol.c b/src/hardware/tondaj-sl-814/protocol.c index b4deee13..44d12ec4 100644 --- a/src/hardware/tondaj-sl-814/protocol.c +++ b/src/hardware/tondaj-sl-814/protocol.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #include "protocol.h" @@ -108,7 +109,7 @@ static void decode_packet(struct sr_dev_inst *sdi) devc->num_samples++; } -int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data) +SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data) { struct sr_dev_inst *sdi; struct dev_context *devc; @@ -133,14 +134,15 @@ int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data) buf[2] = 0x0d; sr_spew("Sending init command: %02x %02x %02x.", buf[0], buf[1], buf[2]); - if ((ret = serial_write(serial, buf, 3)) < 0) { + if ((ret = serial_write_blocking(serial, buf, 3, + serial_timeout(serial, 3))) < 0) { sr_err("Error sending init command: %d.", ret); return FALSE; } devc->state = GET_INIT_REPLY; } else if (devc->state == GET_INIT_REPLY) { /* If we just sent the "init" command, get its reply. */ - if ((ret = serial_read(serial, buf, 2)) < 0) { + if ((ret = serial_read_blocking(serial, buf, 2, 0)) < 0) { sr_err("Error reading init reply: %d.", ret); return FALSE; } @@ -159,7 +161,8 @@ int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data) buf[2] = 0x0d; sr_spew("Sending data request command: %02x %02x %02x.", buf[0], buf[1], buf[2]); - if ((ret = serial_write(serial, buf, 3)) < 0) { + if ((ret = serial_write_blocking(serial, buf, 3, + serial_timeout(serial, 3))) < 0) { sr_err("Error sending request command: %d.", ret); return FALSE; }