uint8_t thread_running;
uint64_t samples_counter;
int dev_index;
- gpointer session_data;
+ void *session_dev_id;
GTimer *timer;
};
NULL,
};
+/* We name the probes 0-7 on our demo driver. */
static const char *probe_names[NUM_PROBES + 1] = {
"0",
"1",
0xbe, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
+/* Private, per-device-instance driver context. */
+/* 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;
static uint64_t cur_samplerate = SR_KHZ(200);
static GThread *my_thread;
static int thread_running;
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
+static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
static int hw_init(const char *devinfo)
{
}
/* Callback handling data */
-static int receive_data(int fd, int revents, void *session_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
logic.length = z;
logic.unitsize = 1;
logic.data = c;
- sr_session_bus(session_data, &packet);
+ sr_session_send(cb_data, &packet);
samples_received += z;
}
} while (z > 0);
/* Send last packet. */
packet.type = SR_DF_END;
- sr_session_bus(session_data, &packet);
+ sr_session_send(cb_data, &packet);
return FALSE;
}
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *cb_data)
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
}
mydata->sample_generator = default_pattern;
- mydata->session_data = session_data;
+ mydata->session_dev_id = cb_data;
mydata->dev_index = dev_index;
mydata->samples_counter = 0;
g_io_channel_set_buffered(channels[1], FALSE);
sr_source_add(mydata->pipe_fds[0], G_IO_IN | G_IO_ERR, 40,
- receive_data, session_data);
+ receive_data, mydata->session_dev_id);
/* Run the demo thread. */
g_thread_init(NULL);
gettimeofday(&header->starttime, NULL);
header->samplerate = cur_samplerate;
header->num_logic_probes = NUM_PROBES;
- sr_session_bus(session_data, packet);
+ sr_session_send(mydata->session_dev_id, packet);
g_free(header);
g_free(packet);
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
+/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
+static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
{
/* Avoid compiler warnings. */
(void)dev_index;
- (void)session_data;
+ (void)cb_data;
/* Stop generate thread. */
thread_running = 0;
return SR_OK;
}
-SR_PRIV struct sr_dev_plugin demo_plugin_info = {
+SR_PRIV struct sr_dev_driver demo_driver_info = {
.name = "demo",
.longname = "Demo driver and pattern generator",
.api_version = 1,