From: Benjamin Larsson Date: Sat, 23 Apr 2016 19:48:05 +0000 (+0200) Subject: hantek-6xxx: only show DC coupling for the Hantek device X-Git-Tag: libsigrok-0.5.0~281 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5eb4ba29d06ed4155ec684117d2bb4a5ed268bb7;p=libsigrok.git hantek-6xxx: only show DC coupling for the Hantek device --- diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index 29d5f6e2..cbcd15bf 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -50,7 +50,11 @@ static const char *channel_names[] = { "CH1", "CH2", }; -static const char *coupling[] = { +static const char *dc_coupling[] = { + "DC", "DC", +}; + +static const char *acdc_coupling[] = { "AC", "DC", }; @@ -58,10 +62,12 @@ static const struct hantek_6xxx_profile dev_profiles[] = { { 0x04b4, 0x6022, 0x04b5, 0x6022, "Hantek", "6022BE", "hantek-6022be.fw", + dc_coupling, ARRAY_SIZE(dc_coupling), }, { 0x8102, 0x8102, 0x1D50, 0x608E, "Sainsmart", "DDS120", "sainsmart-dds120.fw", + acdc_coupling, ARRAY_SIZE(acdc_coupling), }, ALL_ZERO }; @@ -106,6 +112,8 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile devc->voltage[i] = DEFAULT_VOLTAGE; devc->coupling[i] = DEFAULT_COUPLING; } + devc->coupling_vals = prof->coupling_vals; + devc->coupling_tab_size = prof->coupling_tab_size; devc->sample_buf = NULL; devc->sample_buf_write = 0; @@ -369,7 +377,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s *data = g_variant_new("(tt)", vdiv[0], vdiv[1]); break; case SR_CONF_COUPLING: - *data = g_variant_new_string(coupling[devc->coupling[ch_idx]]); + *data = g_variant_new_string(devc->coupling_vals[devc->coupling[ch_idx]]); break; } } @@ -432,13 +440,13 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_COUPLING: tmp_str = g_variant_get_string(data, NULL); - for (i = 0; coupling[i]; i++) { - if (!strcmp(tmp_str, coupling[i])) { + for (i = 0; devc->coupling_vals[i]; i++) { + if (!strcmp(tmp_str, devc->coupling_vals[i])) { devc->coupling[ch_idx] = i; break; } } - if (coupling[i] == 0) + if (devc->coupling_vals[i] == 0) ret = SR_ERR_ARG; break; default: @@ -457,6 +465,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * GVariantBuilder gvb; unsigned int i; GVariant *gvar; + struct dev_context *devc; + + devc = sdi->priv; if (key == SR_CONF_SCAN_OPTIONS) { *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, @@ -495,7 +506,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t)); break; case SR_CONF_COUPLING: - *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling)); + *data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size); break; case SR_CONF_VDIV: g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY); diff --git a/src/hardware/hantek-6xxx/protocol.h b/src/hardware/hantek-6xxx/protocol.h index 530bd67d..0c54ec92 100644 --- a/src/hardware/hantek-6xxx/protocol.h +++ b/src/hardware/hantek-6xxx/protocol.h @@ -97,6 +97,8 @@ struct hantek_6xxx_profile { const char *vendor; const char *model; const char *firmware; + const char **coupling_vals; + uint8_t coupling_tab_size; }; struct dev_context { @@ -123,6 +125,8 @@ struct dev_context { gboolean ch_enabled[NUM_CHANNELS]; int voltage[NUM_CHANNELS]; int coupling[NUM_CHANNELS]; + const char **coupling_vals; + uint8_t coupling_tab_size; uint64_t samplerate; uint64_t limit_msec;