GENMODE_INC,
};
+/* FIXME: Should not be global. */
GIOChannel *channels[2];
struct databag {
static int capabilities[] = {
SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_SAMPLERATE,
SR_HWCAP_PATTERN_MODE,
SR_HWCAP_LIMIT_SAMPLES,
SR_HWCAP_LIMIT_MSEC,
SR_HWCAP_CONTINUOUS,
};
+static struct sr_samplerates samplerates = {
+ 1,
+ GHZ(1),
+ 1,
+ NULL,
+};
+
static const char *patternmodes[] = {
"random",
"incremental",
static void hw_stop_acquisition(int device_index, gpointer session_device_id);
-static int hw_init(char *deviceinfo)
+static int hw_init(const char *deviceinfo)
{
struct sr_device_instance *sdi;
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_SAMPLERATES:
+ info = &samplerates;
+ break;
case SR_DI_CUR_SAMPLERATE:
info = &cur_samplerate;
break;
device_index = device_index;
if (capability == SR_HWCAP_PROBECONFIG) {
- /* Nothing to do. */
+ /* Nothing to do, but must be supported */
+ ret = SR_OK;
+ } else if (capability == SR_HWCAP_SAMPLERATE) {
+ tmp_u64 = value;
+ cur_samplerate = *tmp_u64;
ret = SR_OK;
} else if (capability == SR_HWCAP_LIMIT_SAMPLES) {
tmp_u64 = value;
static void samples_generator(uint8_t *buf, uint64_t size, void *data)
{
+ static uint64_t p = 0;
struct databag *mydata = data;
- uint64_t p, i;
+ uint64_t i;
memset(buf, 0, size);
switch (mydata->sample_generator) {
case GENMODE_DEFAULT:
- p = 0;
for (i = 0; i < size; i++) {
*(buf + i) = ~(genmode_default[p] >> 1);
if (++p == 64)
packet.length = z;
packet.unitsize = 1;
packet.payload = c;
- session_bus(user_data, &packet);
+ sr_session_bus(user_data, &packet);
}
} while (z > 0);
/* Send last packet. */
packet.type = SR_DF_END;
- session_bus(user_data, &packet);
+ sr_session_bus(user_data, &packet);
return FALSE;
}
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);
+ sr_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 =
header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
- session_bus(session_device_id, packet);
+ sr_session_bus(session_device_id, packet);
free(header);
free(packet);