From: Bert Vermeulen Date: Sat, 4 Oct 2014 00:30:27 +0000 (+0200) Subject: agilent-dmm: Fix blocking serial write timeout. X-Git-Tag: libsigrok-0.4.0~888 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=95779b43b882bff8ce36828f812482d69c0cfa0a;p=libsigrok.git agilent-dmm: Fix blocking serial write timeout. --- diff --git a/src/hardware/agilent-dmm/agilent-dmm.h b/src/hardware/agilent-dmm/agilent-dmm.h index 3b320f5c..77a4a3dc 100644 --- a/src/hardware/agilent-dmm/agilent-dmm.h +++ b/src/hardware/agilent-dmm/agilent-dmm.h @@ -24,6 +24,9 @@ #define AGDMM_BUFSIZE 256 +/* Always USB-serial, 1ms is plenty. */ +#define SERIAL_WRITE_TIMEOUT_MS 1 + /* Supported models */ enum { AGILENT_U1231 = 1, diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index 96b10d41..084f9b4d 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -116,7 +116,7 @@ static GSList *scan(GSList *options) return NULL; serial_flush(serial); - if (serial_write_blocking(serial, "*IDN?\r\n", 7, 0) < 7) { + if (serial_write_blocking(serial, "*IDN?\r\n", 7, SERIAL_WRITE_TIMEOUT_MS) < 7) { sr_err("Unable to send identification string."); return NULL; } diff --git a/src/hardware/agilent-dmm/sched.c b/src/hardware/agilent-dmm/sched.c index cb50c88a..46f4ade2 100644 --- a/src/hardware/agilent-dmm/sched.c +++ b/src/hardware/agilent-dmm/sched.c @@ -140,7 +140,7 @@ static int agdmm_send(const struct sr_dev_inst *sdi, const char *cmd) strcat(buf, "\r\n"); else strcat(buf, "\n\r\n"); - if (serial_write_blocking(serial, buf, strlen(buf), 0) < (int)strlen(buf)) { + if (serial_write_blocking(serial, buf, strlen(buf), SERIAL_WRITE_TIMEOUT_MS) < (int)strlen(buf)) { sr_err("Failed to send."); return SR_ERR; }