From: Gerhard Sittig Date: Fri, 18 Aug 2017 19:11:05 +0000 (+0200) Subject: lsr/es51919: support channel selection (enable/disable P1/P2) X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=503519b70a2644851807a7a403f980443d47ac44;p=libsigrok.git lsr/es51919: support channel selection (enable/disable P1/P2) 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. --- diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index 715c25cd..2dc5e648 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -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);