]> sigrok.org Git - libsigrok.git/commitdiff
yokogawa-dlm: Prevent duplicate channel index
authorSoeren Apel <redacted>
Sun, 7 Jun 2015 09:36:38 +0000 (11:36 +0200)
committerUwe Hermann <redacted>
Mon, 22 Jun 2015 22:15:56 +0000 (00:15 +0200)
src/hardware/yokogawa-dlm/api.c
src/hardware/yokogawa-dlm/protocol.c
src/hardware/yokogawa-dlm/protocol.h

index 1bbab68992fa8fac96b3a7585e66d7ff70558963..11dbfda1bb80a1b6feb378a6db2c3ca30c061fef 100644 (file)
@@ -599,17 +599,18 @@ static int dlm_setup_channels(const struct sr_dev_inst *sdi)
                        setup_changed = TRUE;
                        break;
                case SR_CHANNEL_LOGIC:
+                       i = ch->index - DLM_DIG_CHAN_INDEX_OFFS;
                        if (ch->enabled)
-                               pod_enabled[ch->index / 8] = TRUE;
+                               pod_enabled[i / 8] = TRUE;
 
-                       if (ch->enabled == state->digital_states[ch->index])
+                       if (ch->enabled == state->digital_states[i])
                                break;
 
-                       if (dlm_digital_chan_state_set(scpi, ch->index + 1,
+                       if (dlm_digital_chan_state_set(scpi, i + 1,
                                        ch->enabled) != SR_OK)
                                return SR_ERR;
 
-                       state->digital_states[ch->index] = ch->enabled;
+                       state->digital_states[i] = ch->enabled;
                        setup_changed = TRUE;
                        break;
                default:
index 99129abc16d41b75db159e44b261f3f141d420ef..90e25d4d599e85a0ab6ec6bc1cf4c95af9a24db1 100644 (file)
@@ -791,7 +791,7 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
        devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
                        scope_models[model_index].digital_channels);
 
-       /* Add analog channels. */
+       /* Add analog channels, each in its own group. */
        for (i = 0; i < scope_models[model_index].analog_channels; i++) {
                ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
                                (*scope_models[model_index].analog_names)[i]);
@@ -821,7 +821,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
 
        /* Add digital channels. */
        for (i = 0; i < scope_models[model_index].digital_channels; i++) {
-               ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
+               ch = sr_channel_new(sdi, DLM_DIG_CHAN_INDEX_OFFS + i,
+                               SR_CHANNEL_LOGIC, TRUE,
                                (*scope_models[model_index].digital_names)[i]);
 
                devc->digital_groups[i / 8]->channels = g_slist_append(
index 375d4821ea94c90941075d0d2b89c239d7ea9a1f..18b946b3c0d2e058f3f509b270fbbcd7da738f2a 100644 (file)
@@ -41,6 +41,8 @@
 #define DLM_DIVISION_FOR_WORD_FORMAT 3200
 #define DLM_DIVISION_FOR_BYTE_FORMAT 12.5
 
+#define DLM_DIG_CHAN_INDEX_OFFS (32)
+
 enum trigger_slopes {
        SLOPE_POSITIVE,
        SLOPE_NEGATIVE