* @return Pointer to the newly allocated device, or NULL upon errors.
*/
struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
- int plugin_index, int num_probes)
+ int plugin_index)
{
struct sr_device *device;
- int i;
-
- if (!plugin) {
- sr_err("dev: %s: plugin was NULL", __func__);
- return NULL; /* TODO: SR_ERR_ARG */
- }
/* TODO: Check if plugin_index valid? */
device->plugin_index = plugin_index;
devices = g_slist_append(devices, device);
- for (i = 0; i < num_probes; i++)
- sr_device_probe_add(device, NULL); /* TODO: Check return value. */
-
return device;
}
int sr_device_probe_add(struct sr_device *device, const char *name)
{
struct sr_probe *p;
- char probename[16]; /* FIXME: Don't hardcode 16? #define? */
int probenum;
if (!device) {
p->enabled = TRUE;
if (name) {
p->name = g_strdup(name);
- } else {
- snprintf(probename, 16, "%d", probenum);
- p->name = g_strdup(probename);
}
p->trigger = NULL;
device->probes = g_slist_append(device->probes, p);
SR_HWCAP_CONTINUOUS,
};
+static const char* probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ NULL,
+};
+
static GSList *device_instances = NULL;
struct alsa {
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_CUR_SAMPLERATE:
info = &alsa->cur_rate;
break;
#define USB_MODEL_NAME "SIGMA"
#define USB_MODEL_VERSION ""
#define TRIGGER_TYPES "rf10"
+#define NUM_PROBES 16
static GSList *device_instances = NULL;
0,
};
+static const char* probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ NULL,
+};
+
static struct sr_samplerates samplerates = {
SR_KHZ(200),
SR_MHZ(200),
info = sdi;
break;
case SR_DI_NUM_PROBES:
- info = GINT_TO_POINTER(16);
+ info = GINT_TO_POINTER(NUM_PROBES);
+ break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
break;
case SR_DI_SAMPLERATES:
info = &samplerates;
static GSList *device_instances = NULL;
+static const char* probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ NULL,
+};
+
struct la8 {
/** FTDI device context (used by libftdi). */
struct ftdi_context *ftdic;
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
fill_supported_samplerates_if_needed();
info = &samplerates;
NULL,
};
+static const char *probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ NULL,
+};
+
static uint8_t pattern_sigrok[] = {
0x4c, 0x92, 0x92, 0x92, 0x64, 0x00, 0x00, 0x00,
0x82, 0xfe, 0xfe, 0x82, 0x00, 0x00, 0x00, 0x00,
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
info = &samplerates;
break;
#define USB_VENDOR "3195"
#define USB_PRODUCT "f190"
+#define NUM_PROBES 8
+
static int capabilities[] = {
SR_HWCAP_LOGIC_ANALYZER,
// SR_HWCAP_OSCILLOSCOPE,
0,
};
+static const char *probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ NULL,
+};
+
static uint64_t supported_samplerates[] = {
SR_HZ(100),
SR_HZ(200),
info = sdi;
break;
case SR_DI_NUM_PROBES: /* FIXME: How to report analog probe? */
- info = GINT_TO_POINTER(8);
+ info = GINT_TO_POINTER(NUM_PROBES);
+ break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
break;
case SR_DI_SAMPLERATES:
info = &samplerates;
0,
};
+static const char* probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19",
+ "20",
+ "21",
+ "22",
+ "23",
+ "24",
+ "25",
+ "26",
+ "27",
+ "28",
+ "29",
+ "30",
+ "31",
+ NULL,
+};
+
/* default supported samplerates, can be overridden by device metadata */
static struct sr_samplerates samplerates = {
SR_HZ(10),
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
info = &samplerates;
break;
0,
};
+static const char* probe_names[] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ NULL,
+};
+
static uint64_t supported_samplerates[] = {
SR_KHZ(200),
SR_KHZ(250),
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(fx2->profile->num_probes);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
info = &samplerates;
break;
0,
};
+static const char* probe_names[] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19",
+ "20",
+ "21",
+ "22",
+ "23",
+ "24",
+ "25",
+ "26",
+ "27",
+ "28",
+ "29",
+ "30",
+ "31",
+ NULL,
+};
+
/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
static GSList *device_instances = NULL;
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(num_channels);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
info = &samplerates;
break;
int sr_init_hwplugins(struct sr_device_plugin *plugin)
{
- int num_devices, num_probes, i;
+ int num_devices, num_probes, i, j;
+ int num_initialized_devices = 0;
+ struct sr_device *device;
+ char **probe_names;
g_message("initializing %s plugin", plugin->name);
num_devices = plugin->init(NULL);
for (i = 0; i < num_devices; i++) {
num_probes = GPOINTER_TO_INT(
plugin->get_device_info(i, SR_DI_NUM_PROBES));
- sr_device_new(plugin, i, num_probes);
+ probe_names = (char**)plugin->get_device_info(i, SR_DI_PROBE_NAMES);
+
+ if (!probe_names) {
+ sr_warn("Plugin %s does not return a list of probe names.", plugin->name);
+ continue;
+ }
+
+ device = sr_device_new(plugin, i);
+ for (j = 0; j < num_probes; j++) {
+ sr_device_probe_add(device, probe_names[j]);
+ }
+ num_initialized_devices++;
}
- return num_devices;
+ return num_initialized_devices;
}
void sr_cleanup_hwplugins(void)
static int init(struct sr_input *in)
{
- int num_probes;
+ int num_probes, i;
+ char name[SR_MAX_PROBENAME_LEN];
if (in->param && in->param[0]) {
num_probes = strtoul(in->param, NULL, 10);
num_probes = DEFAULT_NUM_PROBES;
/* create a virtual device */
- in->vdevice = sr_device_new(NULL, 0, num_probes);
+ in->vdevice = sr_device_new(NULL, 0);
+
+ for (i = 0; i < num_probes; i++)
+ {
+ snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
+ sr_device_probe_add(in->vdevice, name); /* TODO: Check return value. */
+ }
return SR_OK;
}
static int init(struct sr_input *in)
{
- int num_probes;
+ int num_probes, i;
+ char name[SR_MAX_PROBENAME_LEN];
if (in->param && in->param[0]) {
num_probes = strtoul(in->param, NULL, 10);
}
/* Create a virtual device. */
- in->vdevice = sr_device_new(NULL, 0, num_probes);
+ in->vdevice = sr_device_new(NULL, 0);
+
+ for (i = 0; i < num_probes; i++) {
+ snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
+ sr_device_probe_add(in->vdevice, name); /* TODO: Check return value. */
+ }
return SR_OK;
}
int ret, err, probenum, devcnt, i, j;
uint64_t tmp_u64, total_probes, enabled_probes, p;
char **sections, **keys, *metafile, *val, c;
+ char probename[SR_MAX_PROBENAME_LEN];
if (!(archive = zip_open(filename, 0, &err))) {
sr_dbg("Failed to open session file: zip error %d", err);
for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) {
- device = sr_device_new(&session_driver, devcnt, 0);
+ device = sr_device_new(&session_driver, devcnt);
if (devcnt == 0)
/* first device, init the plugin */
device->plugin->init((char *)filename);
} else if (!strcmp(keys[j], "total probes")) {
total_probes = strtoull(val, NULL, 10);
device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes);
- for (p = 1; p <= total_probes; p++)
- sr_device_probe_add(device, NULL);
+ for (p = 0; p < total_probes; p++) {
+ snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
+ sr_device_probe_add(device, probename);
+ }
} else if (!strncmp(keys[j], "probe", 5)) {
if (!device)
continue;
int sr_device_scan(void);
GSList *sr_device_list(void);
struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
- int plugin_index, int num_probes);
+ int plugin_index);
int sr_device_clear(struct sr_device *device);
int sr_device_probe_clear(struct sr_device *device, int probenum);
int sr_device_probe_add(struct sr_device *device, const char *name);
SR_DI_INSTANCE,
/* The number of probes connected to this device */
SR_DI_NUM_PROBES,
+ /* The probe names on this device */
+ SR_DI_PROBE_NAMES,
/* Samplerates supported by this device, (struct sr_samplerates) */
SR_DI_SAMPLERATES,
/* Types of trigger supported, out of "01crf" (char *) */