/* TODO: struct context as with the other drivers. */
/* List of struct sr_dev_inst, maintained by dev_open()/dev_close(). */
-static GSList *dev_insts = NULL;
+SR_PRIV struct sr_dev_driver demo_driver_info;
+static struct sr_dev_driver *ddi = &demo_driver_info;
static uint64_t cur_samplerate = SR_KHZ(200);
static uint64_t limit_samples = 0;
static uint64_t limit_msec = 0;
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
-static int hw_init(const char *devinfo)
+static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static GSList *hw_scan(GSList *options)
{
struct sr_dev_inst *sdi;
+ GSList *devices;
- /* Avoid compiler warnings. */
- (void)devinfo;
+ (void)options;
+ devices = NULL;
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
return 0;
}
- dev_insts = g_slist_append(dev_insts, sdi);
+ devices = g_slist_append(devices, sdi);
+ ddi->instances = g_slist_append(ddi->instances, sdi);
- return 1;
+ return devices;
}
static int hw_dev_open(int dev_index)
struct sr_dev_inst *sdi;
const void *info = NULL;
- if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
+ if (!(sdi = sr_dev_inst_get(ddi->instances, dev_index))) {
sr_err("demo: %s: sdi was NULL", __func__);
return NULL;
}
ctx->channels[0] = g_io_channel_unix_new(ctx->pipe_fds[0]);
ctx->channels[1] = g_io_channel_unix_new(ctx->pipe_fds[1]);
+ g_io_channel_set_flags(ctx->channels[0], G_IO_FLAG_NONBLOCK, NULL);
+
/* Set channel encoding to binary (default is UTF-8). */
g_io_channel_set_encoding(ctx->channels[0], NULL, NULL);
g_io_channel_set_encoding(ctx->channels[1], NULL, NULL);
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
+ .scan = hw_scan,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
+ .instances = NULL,
};