From: Frank Stettner Date: Fri, 5 Jan 2018 20:09:47 +0000 (+0100) Subject: korad-kaxxxxp: Add two channels "V" and "I", remove channel "CH1" X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=23165d7bb2cc2ff0538eecc1c5f78b3edd85ea14;p=libsigrok.git korad-kaxxxxp: Add two channels "V" and "I", remove channel "CH1" --- diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index d33373e2..667df154 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -134,7 +134,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial; - sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "V"); + sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "I"); devc = g_malloc0(sizeof(struct dev_context)); sr_sw_limits_init(&devc->limits); diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index 4aacd7cd..ff575962 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -333,6 +333,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data) struct sr_analog_meaning meaning; struct sr_analog_spec spec; uint64_t elapsed_us; + GSList *l; (void)fd; @@ -354,9 +355,11 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data) /* Send the value forward. */ packet.type = SR_DF_ANALOG; packet.payload = &analog; - analog.meaning->channels = sdi->channels; analog.num_samples = 1; + l = g_slist_copy(sdi->channels); if (devc->target == KAXXXXP_CURRENT) { + l = g_slist_remove_link(l, g_slist_nth(l, 0)); + analog.meaning->channels = l; analog.meaning->mq = SR_MQ_CURRENT; analog.meaning->unit = SR_UNIT_AMPERE; analog.meaning->mqflags = 0; @@ -365,7 +368,9 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data) analog.data = &devc->current; sr_session_send(sdi, &packet); } - if (devc->target == KAXXXXP_VOLTAGE) { + else if (devc->target == KAXXXXP_VOLTAGE) { + l = g_slist_remove_link(l, g_slist_nth(l, 1)); + analog.meaning->channels = l; analog.meaning->mq = SR_MQ_VOLTAGE; analog.meaning->unit = SR_UNIT_VOLT; analog.meaning->mqflags = SR_MQFLAG_DC;