From: Soeren Apel Date: Sun, 7 Jun 2015 09:36:38 +0000 (+0200) Subject: yokogawa-dlm: Prevent duplicate channel index X-Git-Tag: libsigrok-0.4.0~482 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6fd78a9fd0fbad97a486225c1e9efd562fa07b7b;p=libsigrok.git yokogawa-dlm: Prevent duplicate channel index --- diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 1bbab689..11dbfda1 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -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: diff --git a/src/hardware/yokogawa-dlm/protocol.c b/src/hardware/yokogawa-dlm/protocol.c index 99129abc..90e25d4d 100644 --- a/src/hardware/yokogawa-dlm/protocol.c +++ b/src/hardware/yokogawa-dlm/protocol.c @@ -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( diff --git a/src/hardware/yokogawa-dlm/protocol.h b/src/hardware/yokogawa-dlm/protocol.h index 375d4821..18b946b3 100644 --- a/src/hardware/yokogawa-dlm/protocol.h +++ b/src/hardware/yokogawa-dlm/protocol.h @@ -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