X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fhameg-hmo%2Fapi.c;h=bd97af8865e75cf17b4a76ba7d607e4217c6b78e;hb=23e1ea7a7d862a8f5173dd12c62d6a4b2e7e9015;hp=9e1d6e1ff2c88cd26feb300fed864b53d2dd2f8e;hpb=66e3219dbd086dc57087281f10fdefbe060ee5c8;p=libsigrok.git diff --git a/hardware/hameg-hmo/api.c b/hardware/hameg-hmo/api.c index 9e1d6e1f..bd97af88 100644 --- a/hardware/hameg-hmo/api.c +++ b/hardware/hameg-hmo/api.c @@ -415,6 +415,7 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, unsigned int i; struct dev_context *devc; struct scope_config *model; + struct scope_state *state; if (!sdi || !(devc = sdi->priv)) return SR_ERR_ARG; @@ -424,6 +425,7 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, ret = SR_ERR_NA; model = devc->model_config; + state = devc->model_state; switch (key) { case SR_CONF_NUM_TIMEBASE: @@ -447,6 +449,10 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, ret = SR_ERR_NA; } break; + case SR_CONF_SAMPLERATE: + *data = g_variant_new_uint64(state->sample_rate); + ret = SR_OK; + break; default: ret = SR_ERR_NA; } @@ -485,6 +491,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, const char *tmp; uint64_t p, q, tmp_u64; double tmp_d; + gboolean update_sample_rate; if (!sdi || !(devc = sdi->priv)) return SR_ERR_ARG; @@ -494,6 +501,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, model = devc->model_config; state = devc->model_state; + update_sample_rate = FALSE; ret = SR_ERR_NA; @@ -531,7 +539,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, for (j = 1; j <= model->analog_channels; ++j) { if (probe_group != &devc->analog_groups[j - 1]) continue; - state->analog_channels[j - 1].vdiv = (float) p / q; + state->analog_channels[j - 1].vdiv = i; g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q); g_snprintf(command, sizeof(command), (*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV], @@ -555,13 +563,14 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, if (p != (*model->timebases)[i][0] || q != (*model->timebases)[i][1]) continue; - state->timebase = (float) p / q; + state->timebase = i; g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q); g_snprintf(command, sizeof(command), (*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE], float_str); ret = sr_scpi_send(sdi->conn, command); + update_sample_rate = TRUE; break; } break; @@ -630,6 +639,9 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, if (ret == SR_OK) ret = sr_scpi_get_opc(sdi->conn); + if (ret == SR_OK && update_sample_rate) + ret = hmo_update_sample_rate(sdi); + return ret; } @@ -758,7 +770,7 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi) { GSList *l; unsigned int i; - gboolean *pod_enabled; + gboolean *pod_enabled, setup_changed; char command[MAX_COMMAND_SIZE]; struct scope_state *state; struct scope_config *model; @@ -770,6 +782,7 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi) scpi = sdi->conn; state = devc->model_state; model = devc->model_config; + setup_changed = FALSE; pod_enabled = g_try_malloc0(sizeof(gboolean) * model->digital_pods); @@ -786,6 +799,7 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi) if (sr_scpi_send(scpi, command) != SR_OK) return SR_ERR; state->analog_channels[probe->index].state = probe->enabled; + setup_changed = TRUE; break; case SR_PROBE_LOGIC: /* @@ -805,6 +819,7 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi) return SR_ERR; state->digital_channels[probe->index] = probe->enabled; + setup_changed = TRUE; break; default: return SR_ERR; @@ -820,10 +835,14 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi) if (sr_scpi_send(scpi, command) != SR_OK) return SR_ERR; state->digital_pods[i - 1] = pod_enabled[i - 1]; + setup_changed = TRUE; } g_free(pod_enabled); + if (setup_changed && hmo_update_sample_rate(sdi) != SR_OK) + return SR_ERR; + return SR_OK; }