X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fserial-dmm%2Fprotocol.c;h=5e8912bf3d21c61906b25b0b21e7bd23b084c8dd;hb=03f169b36b1e91d15b3bc292d1dcd2b03c9b50c6;hp=e5f50ff7a1de7bf3587d755a68bc770d9480f0f5;hpb=556a926d432dd21a1d911daec13c6a6bbc49cdbb;p=libsigrok.git diff --git a/src/hardware/serial-dmm/protocol.c b/src/hardware/serial-dmm/protocol.c index e5f50ff7..5e8912bf 100644 --- a/src/hardware/serial-dmm/protocol.c +++ b/src/hardware/serial-dmm/protocol.c @@ -27,15 +27,13 @@ #include "libsigrok-internal.h" #include "protocol.h" -static void log_dmm_packet(const uint8_t *buf) +static void log_dmm_packet(const uint8_t *buf, size_t len) { - sr_dbg("DMM packet: %02x %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x", - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], - buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], - buf[14], buf[15], buf[16], buf[17], buf[18], buf[19], buf[20], - buf[21], buf[22]); + GString *text; + + text = sr_hexdump_new(buf, len); + sr_dbg("DMM packet: %s", text->str); + sr_hexdump_free(text); } static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, @@ -50,11 +48,12 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, struct sr_analog_spec spec; struct dev_context *devc; gboolean sent_sample; + struct sr_channel *channel; size_t ch_idx; dmm = (struct dmm_info *)sdi->driver; - log_dmm_packet(buf); + log_dmm_packet(buf, dmm->packet_size); devc = sdi->priv; sent_sample = FALSE; @@ -63,8 +62,8 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, /* Note: digits/spec_digits will be overridden by the DMM parsers. */ sr_analog_init(&analog, &encoding, &meaning, &spec, 0); - analog.meaning->channels = - g_slist_append(NULL, g_slist_nth_data(sdi->channels, ch_idx)); + channel = g_slist_nth_data(sdi->channels, ch_idx); + analog.meaning->channels = g_slist_append(NULL, channel); analog.num_samples = 1; analog.meaning->mq = 0; @@ -75,7 +74,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, if (dmm->dmm_details) dmm->dmm_details(&analog, info); - if (analog.meaning->mq != 0) { + if (analog.meaning->mq != 0 && channel->enabled) { /* Got a measurement. */ packet.type = SR_DF_ANALOG; packet.payload = &analog;