As discussed in IRC I had put D in place of P for Korad. And the ISET? sixth byte was fixed with Velleman but here is more generic workaround.
Hannu 2015-11-27 2:26 GMT+02:00 Uwe Hermann <u...@hermann-uwe.de>: > Hi, > > On Wed, Nov 25, 2015 at 01:06:54AM +0200, Hannu Vuolasaho wrote: >> I got one *IDN? reply in IRC and here's patch for supporting real >> Korad power supply. > > Merged, thanks! > > I also renamed the driver to korad-kaxxxxp as discussed recently. > > > Cheers, Uwe. > -- > http://hermann-uwe.de | http://randomprojects.org | http://sigrok.org
From b44104ce2f62c0a792fd7228ef03dbdb297533cf Mon Sep 17 00:00:00 2001 From: Hannu Vuolasaho <vuokkose...@gmail.com> Date: Fri, 27 Nov 2015 20:10:14 +0200 Subject: [PATCH] Fixes for Korad driver First change change is the enum value for Korad KA3005P. Cosmetic and coherency issue. Second change is workaround for device bug. The sixth character from ISET? read and discarded. If device is turned off and again on, 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 *IDN? command has to be issued before ISET?. --- src/hardware/korad-kaxxxxp/api.c | 2 +- src/hardware/korad-kaxxxxp/protocol.c | 15 ++++----------- src/hardware/korad-kaxxxxp/protocol.h | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index 7eca205..07fc9b4 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -52,7 +52,7 @@ static const struct korad_kaxxxxp_model models[] = { /* Device enum, vendor, model, ID reply, channels, voltage, current */ {VELLEMAN_LABPS_3005D, "Velleman", "LABPS3005D", "VELLEMANLABPS3005DV2.0", 1, {0, 31, 0.01}, {0, 5, 0.001}}, - {KORAD_KA3005D, "Korad", "KA3005P", + {KORAD_KA3005P, "Korad", "KA3005P", "KORADKA3005PV2.0", 1, {0, 31, 0.01}, {0, 5, 0.001}}, ALL_ZERO }; diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index c01d3ca..93f1414 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; diff --git a/src/hardware/korad-kaxxxxp/protocol.h b/src/hardware/korad-kaxxxxp/protocol.h index 5df3fce..0e727c7 100644 --- a/src/hardware/korad-kaxxxxp/protocol.h +++ b/src/hardware/korad-kaxxxxp/protocol.h @@ -38,7 +38,7 @@ enum { VELLEMAN_LABPS_3005D, - KORAD_KA3005D, + KORAD_KA3005P, /* Support for future devices with this protocol. */ }; -- 2.6.2
------------------------------------------------------------------------------
_______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel