+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static int hw_start_acquisition(int device_index, gpointer session_device_id)
+{
+ struct sr_datafeed_packet *packet;
+ struct sr_datafeed_header *header;
+ struct databag *mydata;
+
+ mydata = malloc(sizeof(struct databag));
+ if (!mydata)
+ return SR_ERR_MALLOC;
+
+ mydata->sample_generator = default_genmode;
+ mydata->session_device_id = session_device_id;
+ mydata->device_index = device_index;
+ mydata->samples_counter = 0;
+
+ if (pipe(mydata->pipe_fds))
+ return SR_ERR;
+
+ channels[0] = g_io_channel_unix_new(mydata->pipe_fds[0]);
+ channels[1] = g_io_channel_unix_new(mydata->pipe_fds[1]);
+
+ /* Set channel encoding to binary (default is UTF-8). */
+ g_io_channel_set_encoding(channels[0], NULL, NULL);
+ g_io_channel_set_encoding(channels[1], NULL, NULL);
+
+ /* Make channels to unbuffered. */
+ g_io_channel_set_buffered(channels[0], FALSE);
+ g_io_channel_set_buffered(channels[1], FALSE);
+
+ source_add(mydata->pipe_fds[0], G_IO_IN | G_IO_ERR, 40, receive_data,
+ session_device_id);
+
+ /* Run the demo thread. */
+ g_thread_init(NULL);
+ /* this needs to be done between g_thread_init() and g_thread_create() */
+ mydata->timer = g_timer_new();
+ thread_running = 1;
+ my_thread =
+ g_thread_create((GThreadFunc)thread_func, mydata, TRUE, NULL);
+ if (!my_thread)
+ return SR_ERR;
+
+ packet = malloc(sizeof(struct sr_datafeed_packet));
+ header = malloc(sizeof(struct sr_datafeed_header));
+ if (!packet || !header)
+ return SR_ERR_MALLOC;
+
+ packet->type = SR_DF_HEADER;
+ packet->length = sizeof(struct sr_datafeed_header);
+ packet->payload = (unsigned char *)header;
+ header->feed_version = 1;
+ gettimeofday(&header->starttime, NULL);
+ header->samplerate = cur_samplerate;
+ header->protocol_id = SR_PROTO_RAW;
+ header->num_logic_probes = NUM_PROBES;
+ header->num_analog_probes = 0;
+ sr_session_bus(session_device_id, packet);
+ free(header);
+ free(packet);
+
+ return SR_OK;
+}
+
+static void hw_stop_acquisition(int device_index, gpointer session_device_id)
+{
+ /* Avoid compiler warnings. */
+ device_index = device_index;
+ session_device_id = session_device_id;