]> sigrok.org Git - libsigrok.git/commitdiff
ols: Symbolic name for magic value, reflect units in variable names
authorv1ne <redacted>
Tue, 31 Mar 2020 16:48:30 +0000 (18:48 +0200)
committerGerhard Sittig <redacted>
Mon, 24 Aug 2020 05:26:43 +0000 (07:26 +0200)
Reviewed-By: Wolfram Sang <redacted>
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/openbench-logic-sniffer/protocol.h

index 5cf415df8ac95fe33f2df21e0895ba376b1fa9e2..c8915fbbed3e316e1fbc8a14e363f9a200570bf6 100644 (file)
@@ -440,7 +440,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                        return SR_ERR;
 
                delaycount = readcount * (1 - devc->capture_ratio / 100.0);
-               devc->trigger_at = (readcount - delaycount) * 4 - devc->num_stages;
+               devc->trigger_at_smpl = (readcount - delaycount) * 4 - devc->num_stages;
                for (i = 0; i <= devc->num_stages; i++) {
                        sr_dbg("Setting OLS stage %d trigger.", i);
                        if ((ret = set_trigger(sdi, i)) != SR_OK)
index 36a091c731d83ff2b7b9f4582dee87db7524e856..a1b168062fb3bef990b39a2e77d22a1ffa091087 100644 (file)
@@ -134,7 +134,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
        struct dev_context *devc;
 
        devc = g_malloc0(sizeof(struct dev_context));
-       devc->trigger_at = -1;
+       devc->trigger_at_smpl = OLS_NO_TRIGGER;
 
        return devc;
 }
@@ -491,16 +491,16 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
                sr_dbg("Received %d bytes, %d samples, %d decompressed samples.",
                                devc->cnt_bytes, devc->cnt_samples,
                                devc->cnt_samples_rle);
-               if (devc->trigger_at != -1) {
+               if (devc->trigger_at_smpl != OLS_NO_TRIGGER) {
                        /*
                         * A trigger was set up, so we need to tell the frontend
                         * about it.
                         */
-                       if (devc->trigger_at > 0) {
+                       if (devc->trigger_at_smpl > 0) {
                                /* There are pre-trigger samples, send those first. */
                                packet.type = SR_DF_LOGIC;
                                packet.payload = &logic;
-                               logic.length = devc->trigger_at * 4;
+                               logic.length = devc->trigger_at_smpl * 4;
                                logic.unitsize = 4;
                                logic.data = devc->raw_sample_buf +
                                        (devc->limit_samples - devc->num_samples) * 4;
@@ -513,9 +513,9 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
                        /* Send post-trigger samples. */
                        packet.type = SR_DF_LOGIC;
                        packet.payload = &logic;
-                       logic.length = (devc->num_samples * 4) - (devc->trigger_at * 4);
+                       logic.length = (devc->num_samples * 4) - (devc->trigger_at_smpl * 4);
                        logic.unitsize = 4;
-                       logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
+                       logic.data = devc->raw_sample_buf + devc->trigger_at_smpl * 4 +
                                (devc->limit_samples - devc->num_samples) * 4;
                        sr_session_send(sdi, &packet);
                } else {
index eb7478c562c5586c9788256c97913e112ad766e9..2303c3fd21998f0c8dc03d325a6e9808e0cd7285 100644 (file)
@@ -65,6 +65,9 @@
 #define FLAG_FILTER                (1 << 1)
 #define FLAG_DEMUX                 (1 << 0)
 
+/* Capture context magic numbers */
+#define OLS_NO_TRIGGER (-1)
+
 struct dev_context {
        /* constant device properties: */
        int max_channels;
@@ -77,7 +80,7 @@ struct dev_context {
        uint32_t cur_samplerate_divider;
        uint64_t limit_samples;
        uint64_t capture_ratio;
-       int trigger_at;
+       int trigger_at_smpl;
        uint32_t channel_mask;
        uint32_t trigger_mask[NUM_TRIGGER_STAGES];
        uint32_t trigger_value[NUM_TRIGGER_STAGES];