fluke-dmm: Fix blocking serial write timeout.
This commit is contained in:
parent
95779b43b8
commit
204014007f
|
@ -90,7 +90,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
|
||||||
while (!devices && retry < 3) {
|
while (!devices && retry < 3) {
|
||||||
retry++;
|
retry++;
|
||||||
serial_flush(serial);
|
serial_flush(serial);
|
||||||
if (serial_write_blocking(serial, "ID\r", 3, 0) < 0) {
|
if (serial_write_blocking(serial, "ID\r", 3, SERIAL_WRITE_TIMEOUT_MS) < 0) {
|
||||||
sr_err("Unable to send ID string");
|
sr_err("Unable to send ID string");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
||||||
fluke_receive_data, (void *)sdi);
|
fluke_receive_data, (void *)sdi);
|
||||||
|
|
||||||
if (serial_write_blocking(serial, "QM\r", 3, 0) < 0) {
|
if (serial_write_blocking(serial, "QM\r", 3, SERIAL_WRITE_TIMEOUT_MS) < 0) {
|
||||||
sr_err("Unable to send QM.");
|
sr_err("Unable to send QM.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
|
|
||||||
#define FLUKEDMM_BUFSIZE 256
|
#define FLUKEDMM_BUFSIZE 256
|
||||||
|
|
||||||
|
/* Always USB-serial, 1ms is plenty. */
|
||||||
|
#define SERIAL_WRITE_TIMEOUT_MS 1
|
||||||
|
|
||||||
/* Supported models */
|
/* Supported models */
|
||||||
enum {
|
enum {
|
||||||
FLUKE_187 = 1,
|
FLUKE_187 = 1,
|
||||||
|
|
|
@ -456,7 +456,7 @@ static void handle_line(const struct sr_dev_inst *sdi)
|
||||||
/* Slip the request in now, before the main
|
/* Slip the request in now, before the main
|
||||||
* timer loop asks for metadata again. */
|
* timer loop asks for metadata again. */
|
||||||
n = sprintf(cmd, "QM %d\r", devc->meas_type);
|
n = sprintf(cmd, "QM %d\r", devc->meas_type);
|
||||||
if (serial_write_blocking(serial, cmd, n, 0) < 0)
|
if (serial_write_blocking(serial, cmd, n, SERIAL_WRITE_TIMEOUT_MS) < 0)
|
||||||
sr_err("Unable to send QM (measurement).");
|
sr_err("Unable to send QM (measurement).");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -525,7 +525,7 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
|
||||||
* out-of-sync or temporary disconnect issues. */
|
* out-of-sync or temporary disconnect issues. */
|
||||||
if ((devc->expect_response == FALSE && elapsed > devc->profile->poll_period)
|
if ((devc->expect_response == FALSE && elapsed > devc->profile->poll_period)
|
||||||
|| elapsed > devc->profile->timeout) {
|
|| elapsed > devc->profile->timeout) {
|
||||||
if (serial_write_blocking(serial, "QM\r", 3, 0) < 0)
|
if (serial_write_blocking(serial, "QM\r", 3, SERIAL_WRITE_TIMEOUT_MS) < 0)
|
||||||
sr_err("Unable to send QM.");
|
sr_err("Unable to send QM.");
|
||||||
devc->cmd_sent_at = now;
|
devc->cmd_sent_at = now;
|
||||||
devc->expect_response = TRUE;
|
devc->expect_response = TRUE;
|
||||||
|
|
Loading…
Reference in New Issue