prof = &zeroplus_models[j];
}
}
- /* Skip if the device was not found. */
+
if (!prof)
continue;
sr_info("Found ZEROPLUS %s.", prof->model_name);
- /* Register the device with libsigrok. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_NAME);
sdi->serial_num = g_strdup(serial_num);
sdi->connection_id = g_strdup(connection_id);
- /* Allocate memory for our private driver context. */
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->prof = prof;
devc->memory_size = MEMORY_SIZE_8K;
// memset(devc->trigger_buffer, 0, NUM_TRIGGER_STAGES);
- /* Fill in channellist according to this device's profile. */
for (j = 0; j < devc->num_channels; j++)
sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
if (ret != SR_OK)
return ret;
- sdi->status = SR_ST_ACTIVE;
-
ret = libusb_set_configuration(usb->devhdl, USB_CONFIGURATION);
if (ret < 0) {
sr_err("Unable to set USB configuration %d: %s.",
usb = sdi->conn;
if (!usb->devhdl)
- return SR_ERR;
+ return SR_ERR_BUG;
sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.",
usb->bus, usb->address, sdi->connection_id, USB_INTERFACE);
libusb_reset_device(usb->devhdl);
libusb_close(usb->devhdl);
usb->devhdl = NULL;
- sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
double v;
GVariant *range[2];
- (void)cg;
-
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- if (!sdi) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
- } else {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
- }
- break;
+ return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
case SR_CONF_SAMPLERATE:
devc = sdi->priv;
- g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
- if (devc->prof->max_sampling_freq == 100) {
- gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
- samplerates_100, ARRAY_SIZE(samplerates_100),
- sizeof(uint64_t));
- } else if (devc->prof->max_sampling_freq == 200) {
- gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
- samplerates_200, ARRAY_SIZE(samplerates_200),
- sizeof(uint64_t));
- } else {
+ if (devc->prof->max_sampling_freq == 100)
+ *data = std_gvar_samplerates(samplerates_100, ARRAY_SIZE(samplerates_100));
+ else if (devc->prof->max_sampling_freq == 200)
+ *data = std_gvar_samplerates(samplerates_200, ARRAY_SIZE(samplerates_200));
+ else {
sr_err("Internal error: Unknown max. samplerate: %d.",
devc->prof->max_sampling_freq);
return SR_ERR_ARG;
}
- g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
- *data = g_variant_builder_end(&gvb);
break;
case SR_CONF_TRIGGER_MATCH:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
return SR_OK;
}
-/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_usb_dev_inst *usb;
.cleanup = std_cleanup,
.scan = scan,
.dev_list = std_dev_list,
- .dev_clear = NULL,
+ .dev_clear = std_dev_clear,
.config_get = config_get,
.config_set = config_set,
.config_list = config_list,