]> sigrok.org Git - libsigrok.git/blobdiff - hardware/tondaj-sl-814/protocol.c
Always interleave analog data with all enabled probes.
[libsigrok.git] / hardware / tondaj-sl-814 / protocol.c
index 57472520aa30313fbf33d9ec96423a5660581864..bdc1e48b6d344c017701e6632c45eb5eb62151fe 100644 (file)
@@ -85,17 +85,20 @@ static void parse_packet(const uint8_t *buf, float *floatval,
        (void)level;
 }
 
-static void decode_packet(struct dev_context *devc)
+static void decode_packet(struct sr_dev_inst *sdi)
 {
        struct sr_datafeed_packet packet;
        struct sr_datafeed_analog analog;
+       struct dev_context *devc;
        float floatval;
 
+       devc = sdi->priv;
        memset(&analog, 0, sizeof(struct sr_datafeed_analog));
 
        parse_packet(devc->buf, &floatval, &analog);
 
        /* Send a sample packet with one analog value. */
+       analog.probes = sdi->probes;
        analog.num_samples = 1;
        analog.data = &floatval;
        packet.type = SR_DF_ANALOG;
@@ -185,7 +188,7 @@ int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
                        return TRUE;
                }
 
-               decode_packet(devc);
+               decode_packet(sdi);
 
                devc->state = SEND_PACKET_REQUEST;
        } else {
@@ -194,11 +197,9 @@ int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
        }
 
        /* Stop acquisition if we acquired enough samples. */
-       if (devc->limit_samples > 0) {
-               if (devc->num_samples >= devc->limit_samples) {
-                       sr_info("Requested number of samples reached.");
-                       sdi->driver->dev_acquisition_stop(sdi, cb_data);
-               }
+       if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
+               sr_info("Requested number of samples reached.");
+               sdi->driver->dev_acquisition_stop(sdi, cb_data);
        }
 
        return TRUE;