From: Uwe Hermann Date: Fri, 25 Dec 2015 22:20:00 +0000 (+0100) Subject: korad-kaxxxxp: Add workaround for a Korad KA3005P issue. X-Git-Tag: libsigrok-0.4.0~60 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a078d3ec527c0a8180f59086e62a8905ae79aa65;p=libsigrok.git korad-kaxxxxp: Add workaround for a Korad KA3005P issue. In some situations, the reply to the *IDN? command contains an additional trailing 0x01 byte for unknown reasons. This issue seems to be reproducible by changing the voltage using the knobs on the device, then turning on the output and turning it off again. The next korad-kaxxxxp scan() operation would contain the trailing 0x01 byte, which would lead to the detection of the device in libsigrok no longer working until the next power-cycle. Work around this issue by treating both the ID string with and without the trailing 0x01 byte as valid. --- diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index 4298d730..8753b1a5 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -56,6 +56,9 @@ static const struct korad_kaxxxxp_model models[] = { "VELLEMANLABPS3005DV2.0", 1, {0, 31, 0.01}, {0, 5, 0.001}}, {KORAD_KA3005P, "Korad", "KA3005P", "KORADKA3005PV2.0", 1, {0, 31, 0.01}, {0, 5, 0.001}}, + /* Sometimes the KA3005P has an extra 0x01 after the ID. */ + {KORAD_KA3005P_0X01, "Korad", "KA3005P", + "KORADKA3005PV2.0\x01", 1, {0, 31, 0.01}, {0, 5, 0.001}}, ALL_ZERO }; @@ -135,7 +138,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sr_err("Unknown model ID '%s' detected, aborting.", reply); return NULL; } - sr_dbg("Found: %s %s", models[model_id].vendor, models[model_id].name); + sr_dbg("Found: %s %s (idx %d, ID '%s').", models[model_id].vendor, + models[model_id].name, model_id, models[model_id].id); /* Init device instance, etc. */ sdi = g_malloc0(sizeof(struct sr_dev_inst)); diff --git a/src/hardware/korad-kaxxxxp/protocol.h b/src/hardware/korad-kaxxxxp/protocol.h index 55dbc4c6..77c4eb6f 100644 --- a/src/hardware/korad-kaxxxxp/protocol.h +++ b/src/hardware/korad-kaxxxxp/protocol.h @@ -40,6 +40,7 @@ enum { VELLEMAN_PS3005D, VELLEMAN_LABPS3005D, KORAD_KA3005P, + KORAD_KA3005P_0X01, /* Support for future devices with this protocol. */ };