#include <stdlib.h>
#include <string.h>
-static const uint32_t hwopts[] = {
+static const uint32_t scanopts[] = {
SR_CONF_CONN,
};
-static const uint32_t hwcaps[] = {
+static const uint32_t devopts[] = {
SR_CONF_LOGIC_ANALYZER,
- SR_CONF_SAMPLERATE,
- SR_CONF_EXTERNAL_CLOCK,
- SR_CONF_CLOCK_EDGE,
- SR_CONF_TRIGGER_MATCH,
- SR_CONF_TRIGGER_SOURCE,
- SR_CONF_TRIGGER_SLOPE,
- SR_CONF_LIMIT_MSEC,
- SR_CONF_LIMIT_SAMPLES,
+ SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_EXTERNAL_CLOCK | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_CLOCK_EDGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
+ SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
static const int32_t trigger_matches[] = {
return list;
}
-static struct sr_dev_inst *dev_inst_new(int device_index)
+static struct sr_dev_inst *dev_inst_new()
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
}
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new(device_index, SR_ST_INACTIVE,
+ sdi = sr_dev_inst_new(SR_ST_INACTIVE,
VENDOR_NAME, MODEL_NAME, NULL);
if (!sdi) {
sr_err("Failed to instantiate device.");
struct sr_usb_dev_inst *usb;
struct sr_config *src;
const char *conn;
- int device_index;
+ char connection_id[64];
drvc = di->priv;
conn = USB_VID_PID;
}
usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn);
devices = NULL;
- device_index = g_slist_length(drvc->instances);
for (node = usb_devices; node != NULL; node = node->next) {
usb = node->data;
+ usb_get_port_path(libusb_get_device(usb->devhdl),
+ connection_id, sizeof(connection_id));
+
/* Create sigrok device instance. */
- sdi = dev_inst_new(device_index);
+ sdi = dev_inst_new();
if (!sdi) {
sr_usb_dev_inst_free(usb);
continue;
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
+ sdi->connection_id = g_strdup(connection_id);
/* Register device instance with driver. */
drvc->instances = g_slist_append(drvc->instances, sdi);
switch (key) {
case SR_CONF_SCAN_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- hwopts, G_N_ELEMENTS(hwopts), sizeof(uint32_t));
+ scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
break;
case SR_CONF_DEVICE_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- hwcaps, G_N_ELEMENTS(hwcaps), sizeof(uint32_t));
+ devopts, G_N_ELEMENTS(devopts), sizeof(uint32_t));
break;
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));