This will likely break all other devices, since the protocol looks different.
OUT is now OUTPUT. STATUS returns more data, and hack around 0a char being returned on serial. --- src/hardware/korad-kaxxxxp/api.c | 2 ++ src/hardware/korad-kaxxxxp/protocol.c | 21 +++++++++++++++------ src/hardware/korad-kaxxxxp/protocol.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index 21ab6844..5888ef7e 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -82,6 +82,8 @@ static const struct korad_kaxxxxp_model models[] = { "S-LS-31 V2.0", 1, {0, 31, 0.01}, {0, 5.1, 0.001}}, {KORAD_KD6005P, "Korad", "KD6005P", "KORAD KD6005P V2.2", 1, {0, 61, 0.01}, {0, 5.1, 0.001}}, + {VELLEMAN_LABPS3005DN, "Velleman", "PS3005DN", + "QJE3005PV1.0", 1, {0, 31, 0.01}, {0, 5.1, 0.001}}, ALL_ZERO }; diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index 848279d7..41277214 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -29,11 +29,15 @@ SR_PRIV int korad_kaxxxxp_send_cmd(struct sr_serial_dev_inst *serial, { int ret; - sr_dbg("Sending '%s'.", cmd); - if ((ret = serial_write_blocking(serial, cmd, strlen(cmd), 0)) < 0) { + char* newcmd = g_strconcat(cmd, "\\n", NULL); + + sr_dbg("Sending '%s'.", newcmd); + if ((ret = serial_write_blocking(serial, newcmd, strlen(newcmd), 0)) < 0) { sr_err("Error sending command: %d.", ret); + free(newcmd); return ret; } + free(newcmd); return ret; } @@ -60,6 +64,11 @@ SR_PRIV int korad_kaxxxxp_read_chars(struct sr_serial_dev_inst *serial, buf[count] = 0; + int len = strlen(buf); + if (buf[len-1] == '\n') { + buf[len-1] = 0; + } + sr_spew("Received: '%s'.", buf); return ret; @@ -105,7 +114,7 @@ SR_PRIV int korad_kaxxxxp_set_value(struct sr_serial_dev_inst *serial, value = devc->set_voltage_target; break; case KAXXXXP_OUTPUT: - cmd = "OUT%01.0f"; + cmd = "OUTPUT%01.0f"; value = (devc->set_output_enabled) ? 1 : 0; /* Set value back to recognize changes */ devc->output_enabled = devc->set_output_enabled; @@ -169,7 +178,7 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial, int target, struct dev_context *devc) { int ret, count; - char reply[6]; + char reply[7]; float *value; char status_byte; gboolean prev_status; @@ -178,7 +187,7 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial, give_device_time_to_process(devc); value = NULL; - count = 5; + count = 6; switch (target) { case KAXXXXP_CURRENT: @@ -207,7 +216,7 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial, case KAXXXXP_OVP: /* Read status from device. */ ret = korad_kaxxxxp_send_cmd(serial, "STATUS?"); - count = 1; + count = 4; break; default: sr_err("Don't know how to query %d.", target); diff --git a/src/hardware/korad-kaxxxxp/protocol.h b/src/hardware/korad-kaxxxxp/protocol.h index ea28a71c..9c83625b 100644 --- a/src/hardware/korad-kaxxxxp/protocol.h +++ b/src/hardware/korad-kaxxxxp/protocol.h @@ -49,6 +49,7 @@ enum { TENMA_72_2535_V21, STAMOS_SLS31_V20, KORAD_KD6005P, + VELLEMAN_LABPS3005DN, /* Support for future devices with this protocol. */ }; -- 2.24.1 _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel