]> sigrok.org Git - libsigrok.git/commitdiff
korad-kaxxxxp: Add two channels "V" and "I", remove channel "CH1"
authorFrank Stettner <redacted>
Fri, 5 Jan 2018 20:09:47 +0000 (21:09 +0100)
committerUwe Hermann <redacted>
Sun, 11 Feb 2018 22:15:52 +0000 (23:15 +0100)
src/hardware/korad-kaxxxxp/api.c
src/hardware/korad-kaxxxxp/protocol.c

index d33373e2b88e94c26147de3cb635fd580fb04821..667df154f0fea9013eec39dc889c735064ddd194 100644 (file)
@@ -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);
index 4aacd7cd1868270b926dac075b5e7366aec14901..ff5759623a4746d762203e20381f4b1d1b9ddc94 100644 (file)
@@ -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;