};
static const char *dc_coupling[] = {
- "DC", "DC",
+ "DC",
};
static const char *acdc_coupling[] = {
static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
{
struct sr_dev_inst *sdi;
}
devc->coupling_vals = prof->coupling_vals;
devc->coupling_tab_size = prof->coupling_tab_size;
+ devc->has_coupling = prof->has_coupling;
devc->sample_buf = NULL;
devc->sample_buf_write = 0;
return SR_OK;
}
-static void clear_dev_context(void *priv)
+static void clear_helper(struct dev_context *devc)
{
- struct dev_context *devc;
-
- devc = priv;
g_slist_free(devc->enabled_channels);
- g_free(devc);
}
static int dev_clear(const struct sr_dev_driver *di)
{
- return std_dev_clear(di, clear_dev_context);
+ return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
}
static GSList *scan(struct sr_dev_driver *di, GSList *options)
*data = g_variant_new("(tt)", vdiv[0], vdiv[1]);
break;
case SR_CONF_COUPLING:
- *data = g_variant_new_string(devc->coupling_vals[devc->coupling[ch_idx]]);
+ *data = g_variant_new_string((devc->coupling[ch_idx] \
+ == COUPLING_DC) ? "DC" : "AC");
break;
}
}
{
struct dev_context *devc;
uint64_t p, q;
- int tmp_int, ch_idx, ret;
+ int tmp_int, ch_idx;
unsigned int i;
const char *tmp_str;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
- ret = SR_OK;
devc = sdi->priv;
if (!cg) {
switch (key) {
devc->limit_samples = g_variant_get_uint64(data);
break;
default:
- ret = SR_ERR_NA;
- break;
+ return SR_ERR_NA;
}
} else {
if (sdi->channel_groups->data == cg)
devc->voltage[ch_idx] = tmp_int;
hantek_6xxx_update_vdiv(sdi);
} else
- ret = SR_ERR_ARG;
+ return SR_ERR_ARG;
break;
case SR_CONF_COUPLING:
tmp_str = g_variant_get_string(data, NULL);
}
}
if (i == devc->coupling_tab_size)
- ret = SR_ERR_ARG;
+ return SR_ERR_ARG;
break;
default:
- ret = SR_ERR_NA;
- break;
+ return SR_ERR_NA;
}
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
PRIu64 " <= %" PRIu64, devc->limit_samples,
devc->samp_received);
send_data(sdi, devc->sample_buf, devc->limit_samples);
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
} else if (devc->limit_msec && (g_get_monotonic_time() -
devc->aq_started) / 1000 >= devc->limit_msec) {
sr_info("Requested time limit reached, stopping. %d <= %d",
send_data(sdi, devc->sample_buf, devc->samp_received);
g_free(devc->sample_buf);
devc->sample_buf = NULL;
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
} else {
read_channel(sdi, data_amount(sdi));
}
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->context;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
if (configure_channels(sdi) != SR_OK) {
{
struct dev_context *devc;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
-
devc = sdi->priv;
devc->dev_state = STOPPING;
- g_free(devc->sample_buf); devc->sample_buf = NULL;
+ g_free(devc->sample_buf);
+ devc->sample_buf = NULL;
return SR_OK;
}