]> sigrok.org Git - libsigrok.git/commitdiff
lsr/es51919: support channel selection (enable/disable P1/P2)
authorGerhard Sittig <redacted>
Fri, 18 Aug 2017 19:11:05 +0000 (21:11 +0200)
committerUwe Hermann <redacted>
Sat, 19 Aug 2017 17:21:53 +0000 (19:21 +0200)
Upon reception of serial data from the ES51919 LCR chipset, the data for
channels P1 and P2 was extracted from the packet, and unconditionally got
sent to the sigrok session.

Do check the channels' enabled state before submission. This fixes for
serial-lcr what recently got reported for a Brymen DMM. Tested with

  $ sigrok-cli -d peaktech-2170:conn=/dev/ttyUSB0 --channels P2

and other --channels specifications.

src/lcr/es51919.c

index 715c25cdbb778ddce81d8758955821482462ff23..2dc5e648159aeddeb6fe73370da6e789a77f72e8 100644 (file)
@@ -593,6 +593,7 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
        unsigned int val;
        float floatval;
        gboolean frame;
+       struct sr_channel *channel;
 
        devc = sdi->priv;
 
@@ -620,10 +621,11 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
        analog.num_samples = 1;
        analog.data = &floatval;
 
-       analog.meaning->channels = g_slist_append(NULL, sdi->channels->data);
+       channel = sdi->channels->data;
+       analog.meaning->channels = g_slist_append(NULL, channel);
 
        parse_measurement(pkt, &floatval, &analog, 0);
-       if (analog.meaning->mq != 0) {
+       if (analog.meaning->mq != 0 && channel->enabled) {
                if (!frame) {
                        packet.type = SR_DF_FRAME_BEGIN;
                        sr_session_send(sdi, &packet);
@@ -637,10 +639,12 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
        }
 
        g_slist_free(analog.meaning->channels);
-       analog.meaning->channels = g_slist_append(NULL, sdi->channels->next->data);
+
+       channel = sdi->channels->next->data;
+       analog.meaning->channels = g_slist_append(NULL, channel);
 
        parse_measurement(pkt, &floatval, &analog, 1);
-       if (analog.meaning->mq != 0) {
+       if (analog.meaning->mq != 0 && channel->enabled) {
                if (!frame) {
                        packet.type = SR_DF_FRAME_BEGIN;
                        sr_session_send(sdi, &packet);