allow devices without a plugin
this is needed to support file loading: we want a device struct so we can enumerate probes from the file, but there is no plugin since the data come in from a device.
This commit is contained in:
parent
e273a9040e
commit
873080cc03
17
device.c
17
device.c
|
@ -29,7 +29,7 @@ void device_scan(void)
|
||||||
{
|
{
|
||||||
GSList *plugins, *l;
|
GSList *plugins, *l;
|
||||||
struct device_plugin *plugin;
|
struct device_plugin *plugin;
|
||||||
int num_devices, i;
|
int num_devices, num_probes, i;
|
||||||
|
|
||||||
plugins = list_hwplugins();
|
plugins = list_hwplugins();
|
||||||
|
|
||||||
|
@ -42,8 +42,10 @@ void device_scan(void)
|
||||||
plugin = l->data;
|
plugin = l->data;
|
||||||
g_message("initializing %s plugin", plugin->name);
|
g_message("initializing %s plugin", plugin->name);
|
||||||
num_devices = plugin->init(NULL);
|
num_devices = plugin->init(NULL);
|
||||||
for (i = 0; i < num_devices; i++)
|
for (i = 0; i < num_devices; i++) {
|
||||||
device_new(plugin, i);
|
num_probes = (int)plugin->get_device_info(i, DI_NUM_PROBES);
|
||||||
|
device_new(plugin, i, num_probes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +55,8 @@ void device_close_all(void)
|
||||||
|
|
||||||
while (devices) {
|
while (devices) {
|
||||||
device = devices->data;
|
device = devices->data;
|
||||||
device->plugin->close(device->plugin_index);
|
if (device->plugin)
|
||||||
|
device->plugin->close(device->plugin_index);
|
||||||
device_destroy(device);
|
device_destroy(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +66,10 @@ GSList *device_list(void)
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct device *device_new(struct device_plugin *plugin, int plugin_index)
|
struct device *device_new(struct device_plugin *plugin, int plugin_index, int num_probes)
|
||||||
{
|
{
|
||||||
struct device *device;
|
struct device *device;
|
||||||
int num_probes, i;
|
int i;
|
||||||
char probename[16];
|
char probename[16];
|
||||||
|
|
||||||
device = g_malloc0(sizeof(struct device));
|
device = g_malloc0(sizeof(struct device));
|
||||||
|
@ -74,8 +77,6 @@ struct device *device_new(struct device_plugin *plugin, int plugin_index)
|
||||||
device->plugin_index = plugin_index;
|
device->plugin_index = plugin_index;
|
||||||
devices = g_slist_append(devices, device);
|
devices = g_slist_append(devices, device);
|
||||||
|
|
||||||
num_probes = (int)device->plugin->get_device_info(device->plugin_index,
|
|
||||||
DI_NUM_PROBES);
|
|
||||||
for (i = 0; i < num_probes; i++) {
|
for (i = 0; i < num_probes; i++) {
|
||||||
snprintf(probename, 16, "%d", i + 1);
|
snprintf(probename, 16, "%d", i + 1);
|
||||||
device_probe_add(device, probename);
|
device_probe_add(device, probename);
|
||||||
|
|
2
sigrok.h
2
sigrok.h
|
@ -222,7 +222,7 @@ extern GSList *devices;
|
||||||
void device_scan(void);
|
void device_scan(void);
|
||||||
void device_close_all(void);
|
void device_close_all(void);
|
||||||
GSList *device_list(void);
|
GSList *device_list(void);
|
||||||
struct device *device_new(struct device_plugin *plugin, int plugin_index);
|
struct device *device_new(struct device_plugin *plugin, int plugin_index, int num_probes);
|
||||||
void device_clear(struct device *device);
|
void device_clear(struct device *device);
|
||||||
void device_destroy(struct device *dev);
|
void device_destroy(struct device *dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue