struct sr_scpi_dev_inst *scpi;
GVariant *beeper;
- if (sdi->status != SR_ST_INACTIVE)
- return SR_ERR;
-
scpi = sdi->conn;
if (sr_scpi_open(scpi) < 0)
return SR_ERR;
- sdi->status = SR_ST_ACTIVE;
-
devc = sdi->priv;
scpi_cmd(sdi, devc->device->commands, SCPI_CMD_REMOTE);
devc->beeper_was_set = FALSE;
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
scpi = sdi->conn;
- if (scpi) {
- if (devc->beeper_was_set)
- scpi_cmd(sdi, devc->device->commands, SCPI_CMD_BEEPER_ENABLE);
- scpi_cmd(sdi, devc->device->commands, SCPI_CMD_LOCAL);
- sr_scpi_close(scpi);
- sdi->status = SR_ST_INACTIVE;
- }
- return SR_OK;
+ if (!scpi)
+ return SR_ERR_BUG;
+
+ if (devc->beeper_was_set)
+ scpi_cmd(sdi, devc->device->commands, SCPI_CMD_BEEPER_ENABLE);
+ scpi_cmd(sdi, devc->device->commands, SCPI_CMD_LOCAL);
+
+ return sr_scpi_close(scpi);
}
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
{
- struct dev_context *devc;
-
- devc = priv;
g_free(devc->channels);
g_free(devc->channel_groups);
- g_free(devc);
}
static int dev_clear(const struct sr_dev_driver *di)
{
- return std_dev_clear(di, clear_helper);
+ return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
}
static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
if (!sdi)
return SR_ERR_ARG;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
if (cg)
/* Channel group specified. */
select_channel(sdi, cg->channels->data);
const struct channel_spec *ch_spec;
GVariant *gvar;
GVariantBuilder gvb;
- int ret, i;
+ int i;
const char *s[16];
- /* Always available, even without sdi. */
- if (key == SR_CONF_SCAN_OPTIONS) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
- return SR_OK;
- } else if (key == SR_CONF_DEVICE_OPTIONS && !sdi) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
- return SR_OK;
- }
-
- if (!sdi)
- return SR_ERR_ARG;
- devc = sdi->priv;
+ devc = (sdi) ? sdi->priv : NULL;
- ret = SR_OK;
if (!cg) {
/* No channel group: global options. */
switch (key) {
+ case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devc->device->devopts, devc->device->num_devopts,
- sizeof(uint32_t));
+ return std_opts_config_list(key, data, sdi, cg,
+ scanopts, ARRAY_SIZE(scanopts),
+ drvopts, ARRAY_SIZE(drvopts),
+ (devc) ? devc->device->devopts : NULL,
+ (devc) ? devc->device->num_devopts : 0);
break;
case SR_CONF_CHANNEL_CONFIG:
/* Not used. */
}
}
- return ret;
+ return SR_OK;
}
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct pps_channel *pch;
int cmd, ret;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
scpi = sdi->conn;