]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/korad-kdxxxxp/protocol.c
Support for regulation status and fix for mysterious M
[libsigrok.git] / src / hardware / korad-kdxxxxp / protocol.c
index cd266e2fc718e6c5c02a0882530fb43ed9b1a187..eb5281037b7d6c939a7e39b143007074ad5fc926 100644 (file)
@@ -202,7 +202,7 @@ SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
                                struct dev_context *devc)
 {
        double value;
-       int count, ret;
+       int count, ret, i;
        float *target;
        char status_byte;
 
@@ -241,6 +241,16 @@ SR_PRIV int korad_kdxxxxp_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_kdxxxxp_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);