From: Hannu Vuolasaho Date: Fri, 27 Nov 2015 18:10:14 +0000 (+0200) Subject: korad-kaxxxxp: Workaround for Korad device bug X-Git-Tag: libsigrok-0.4.0~84 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8abdf0066e4203eafe5b65ed0a995d4588961126;p=libsigrok.git korad-kaxxxxp: Workaround for Korad device bug The sixth character from ISET? is read and discarded. If the device is turned off and on again, this won't be there and causes 10 ms delay in every ISET? Luckily, this value isn't queried that often. To get the sixth byte, the *IDN? command has to be issued before ISET?. --- diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index c01d3ca6..93f14146 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -211,7 +211,7 @@ SR_PRIV int korad_kaxxxxp_get_reply(struct sr_serial_dev_inst *serial, struct dev_context *devc) { double value; - int count, ret, i; + int count, ret; float *target; char status_byte; @@ -250,15 +250,6 @@ SR_PRIV int korad_kaxxxxp_get_reply(struct sr_serial_dev_inst *serial, devc->reply[count] = 0; if (target) { - /* Handle the strange 'M'. */ - if (devc->reply[0] == 'M') { - for (i = 1; i < count; i++) - devc->reply[i - 1] = devc->reply[i]; - /* Get the last character. */ - if ((i = korad_kaxxxxp_read_chars(serial, 1, - &(devc->reply[count]))) < 0) - return i; - } value = g_ascii_strtod(devc->reply, NULL); *target = (float)value; sr_dbg("value: %f",value); @@ -293,7 +284,9 @@ SR_PRIV int korad_kaxxxxp_get_reply(struct sr_serial_dev_inst *serial, (status_byte & (1 << 6)) ? "enabled" : "disabled", (status_byte & (1 << 7)) ? "true" : "false"); } - + /* Read the sixth byte from ISET? BUG workaround. */ + if (devc->target == KAXXXXP_CURRENT_MAX) + serial_read_blocking(serial, &status_byte, 1, 10); devc->reply_pending = FALSE; return ret;