SR_CONF_CONN,
};
-static const uint32_t devopts[] = {
+static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
+};
+
+static const uint32_t devopts[] = {
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
SR_CONF_CONN | SR_CONF_GET,
SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
};
-static const int32_t soft_trigger_matches[] = {
+static const int32_t trigger_matches[] = {
SR_TRIGGER_ZERO,
SR_TRIGGER_ONE,
SR_TRIGGER_RISING,
SR_MHZ(10),
SR_KHZ(12500),
SR_MHZ(16),
+ SR_MHZ(20),
SR_MHZ(25),
SR_MHZ(32),
SR_MHZ(40),
+ SR_MHZ(50),
SR_MHZ(80),
SR_MHZ(100),
};
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup("Saleae");
sdi->model = g_strdup("Logic16");
- sdi->driver = di;
sdi->connection_id = g_strdup(connection_id);
for (j = 0; j < ARRAY_SIZE(channel_names); j++)
sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
- channel_names[j]);
+ channel_names[j]);
devc = g_malloc0(sizeof(struct dev_context));
devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
sdi->priv = devc;
- drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
if (check_conf_profile(devlist[i])) {
libusb_free_device_list(devlist, 1);
g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
- return devices;
+ return std_scan_complete(di, devices);
}
static int logic16_dev_open(struct sr_dev_inst *sdi)
struct sr_usb_dev_inst *usb;
struct libusb_device_descriptor des;
struct drv_context *drvc;
- int ret, i, device_count;
+ int ret = SR_ERR, i, device_count;
char connection_id[64];
di = sdi->driver;
drvc = di->context;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* Device is already in use. */
- return SR_ERR;
-
device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
if (device_count < 0) {
sr_err("Failed to get device list: %s.",
} else {
sr_err("Failed to open device: %s.",
libusb_error_name(ret));
+ ret = SR_ERR;
break;
}
if (ret == LIBUSB_ERROR_BUSY) {
sr_err("Unable to claim USB interface. Another "
"program or driver has already claimed it.");
+ ret = SR_ERR;
break;
} else if (ret == LIBUSB_ERROR_NO_DEVICE) {
sr_err("Device has been disconnected.");
+ ret = SR_ERR;
break;
} else if (ret != 0) {
sr_err("Unable to claim interface: %s.",
libusb_error_name(ret));
+ ret = SR_ERR;
break;
}
break;
}
- sdi->status = SR_ST_ACTIVE;
sr_info("Opened device on %d.%d (logical) / %s (physical), interface %d.",
usb->bus, usb->address, sdi->connection_id, USB_INTERFACE);
+ ret = SR_OK;
+
break;
}
+
libusb_free_device_list(devlist, 1);
- if (sdi->status != SR_ST_ACTIVE) {
+ if (ret != SR_OK) {
if (usb->devhdl) {
libusb_release_interface(usb->devhdl, USB_INTERFACE);
libusb_close(usb->devhdl);
struct sr_usb_dev_inst *usb;
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_release_interface(usb->devhdl, USB_INTERFACE);
libusb_close(usb->devhdl);
usb->devhdl = NULL;
- sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
-static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
- const struct sr_channel_group *cg)
+static int config_get(uint32_t key, GVariant **data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
return ret;
}
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
- const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
gdouble low, high;
(void)cg;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
ret = SR_OK;
return ret;
}
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
- const struct sr_channel_group *cg)
+static int config_list(uint32_t key, GVariant **data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
GVariant *gvar, *range[2];
GVariantBuilder gvb;
- int ret;
unsigned int i;
- (void)sdi;
- (void)cg;
-
- ret = SR_OK;
switch (key) {
case SR_CONF_SCAN_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
- break;
case SR_CONF_DEVICE_OPTIONS:
- *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, scanopts, drvopts, devopts);
case SR_CONF_SAMPLERATE:
- g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
- gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
- samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
- g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
- *data = g_variant_builder_end(&gvb);
+ *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
break;
case SR_CONF_VOLTAGE_THRESHOLD:
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
break;
default:
return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static void abort_acquisition(struct dev_context *devc)
unsigned char *buf;
size_t size, convsize;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
drvc = di->context;
devc = sdi->priv;
usb = sdi->conn;
usb_source_add(sdi->session, devc->ctx, timeout, receive_data, (void *)sdi);
- std_session_send_df_header(sdi, LOG_PREFIX);
+ std_session_send_df_header(sdi);
if ((ret = logic16_start_acquisition(sdi)) != SR_OK) {
abort_acquisition(devc);
{
int ret;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
ret = logic16_abort_acquisition(sdi);
abort_acquisition(sdi->priv);
.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,