X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Flcr%2Fes51919.c;h=eeb724ec20cef49de7992374d84c0860cafa33f6;hp=8d9d9d96476c8e22870baeb06eb4219936484f2b;hb=05199c0ac9f15f229d43e50e86c4c1eadc55deac;hpb=4bf93988023b2428129c8145ef9ea7121400f195 diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index 8d9d9d96..eeb724ec 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -251,32 +251,6 @@ static int serial_stream_check(struct sr_serial_dev_inst *serial, is_valid, timeout_ms, baudrate); } -struct std_opt_desc { - const uint32_t *scanopts; - const int num_scanopts; - const uint32_t *devopts; - const int num_devopts; -}; - -static int std_config_list(uint32_t key, GVariant **data, - const struct std_opt_desc *d) -{ - switch (key) { - case SR_CONF_SCAN_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - d->scanopts, d->num_scanopts, sizeof(uint32_t)); - break; - case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - d->devopts, d->num_devopts, sizeof(uint32_t)); - break; - default: - return SR_ERR_NA; - } - - return SR_OK; -} - static int send_config_update(struct sr_dev_inst *sdi, struct sr_config *cfg) { struct sr_datafeed_packet packet; @@ -731,7 +705,7 @@ static int receive_data(int fd, int revents, void *cb_data) if (dev_limit_counter_limit_reached(&devc->frame_count) || dev_time_limit_reached(&devc->time_count)) - sdi->driver->dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); return TRUE; } @@ -800,8 +774,7 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options, scan_cleanup: es51919_serial_clean(devc); sr_dev_inst_free(sdi); - if (serial) - sr_serial_dev_inst_free(serial); + sr_serial_dev_inst_free(serial); return NULL; } @@ -866,8 +839,11 @@ static const uint32_t scanopts[] = { SR_CONF_SERIALCOMM, }; -static const uint32_t devopts[] = { +static const uint32_t drvopts[] = { SR_CONF_LCRMETER, +}; + +static const uint32_t devopts[] = { SR_CONF_CONTINUOUS, SR_CONF_LIMIT_FRAMES | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_SET, @@ -875,22 +851,14 @@ static const uint32_t devopts[] = { SR_CONF_EQUIV_CIRCUIT_MODEL | SR_CONF_GET | SR_CONF_LIST, }; -static const struct std_opt_desc opts = { - scanopts, ARRAY_SIZE(scanopts), - devopts, ARRAY_SIZE(devopts), -}; - SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - (void)sdi; - (void)cg; - - if (std_config_list(key, data, &opts) == SR_OK) - return SR_OK; - switch (key) { + case SR_CONF_SCAN_OPTIONS: + case SR_CONF_DEVICE_OPTIONS: + return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_OUTPUT_FREQUENCY: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_DOUBLE, frequencies, ARRAY_SIZE(frequencies), sizeof(double)); @@ -910,9 +878,6 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi) struct dev_context *devc; struct sr_serial_dev_inst *serial; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) return SR_ERR_BUG;