X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fkorad-kaxxxxp%2Fprotocol.c;h=60c4545581fbe92e6675dcc441059683823fd62f;hb=803db07a1af036a5da65581ddbac23b7f84a4388;hp=c01d3ca636089ba4b846e4703f16ddf224fdc524;hpb=16fc7ee29ffa196d29a20fddd81234792f88b12c;p=libsigrok.git diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index c01d3ca6..60c45455 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -88,7 +88,7 @@ SR_PRIV int korad_kaxxxxp_set_value(struct sr_serial_dev_inst *serial, give_device_time_to_process(devc); msg[20] = 0; - switch(devc->target){ + switch (devc->target) { case KAXXXXP_CURRENT: case KAXXXXP_VOLTAGE: case KAXXXXP_STATUS: @@ -158,7 +158,7 @@ SR_PRIV int korad_kaxxxxp_query_value(struct sr_serial_dev_inst *serial, give_device_time_to_process(devc); - switch(devc->target){ + switch (devc->target) { case KAXXXXP_CURRENT: /* Read current from device. */ ret = korad_kaxxxxp_send_cmd(serial, "IOUT1?"); @@ -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;