/* FIXME: Should not be global. */
SR_PRIV GIOChannel *channels[2];
-struct databag {
+struct context {
int pipe_fds[2];
uint8_t sample_generator;
uint8_t thread_running;
GTimer *timer;
};
-static int hwcaps[] = {
+static const int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_DEMO_DEV,
SR_HWCAP_SAMPLERATE,
case SR_DI_CUR_SAMPLERATE:
info = &cur_samplerate;
break;
- case SR_DI_PATTERNMODES:
+ case SR_DI_PATTERNS:
info = &pattern_strings;
break;
}
return SR_ST_ACTIVE;
}
-static int *hw_hwcap_get_all(void)
+static const int *hw_hwcap_get_all(void)
{
return hwcaps;
}
static void samples_generator(uint8_t *buf, uint64_t size, void *data)
{
static uint64_t p = 0;
- struct databag *ctx = data;
+ struct context *ctx = data;
uint64_t i;
/* TODO: Needed? */
/* Thread function */
static void thread_func(void *data)
{
- struct databag *ctx = data;
+ struct context *ctx = data;
uint8_t buf[BUFSIZE];
uint64_t nb_to_send = 0;
int bytes_written;
if (!thread_running && z <= 0) {
/* Make sure we don't receive more packets. */
- g_io_channel_close(channels[0]);
+ g_io_channel_shutdown(channels[0], FALSE, NULL);
/* Send last packet. */
packet.type = SR_DF_END;
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
- struct databag *ctx;
+ struct sr_datafeed_meta_logic meta;
+ struct context *ctx;
/* TODO: 'ctx' is never g_free()'d? */
- if (!(ctx = g_try_malloc(sizeof(struct databag)))) {
+ if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("demo: %s: ctx malloc failed", __func__);
return SR_ERR_MALLOC;
}
packet->payload = header;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
- header->samplerate = cur_samplerate;
- header->num_logic_probes = NUM_PROBES;
sr_session_send(ctx->session_dev_id, packet);
+
+ /* Send metadata about the SR_DF_LOGIC packets to come. */
+ packet->type = SR_DF_META_LOGIC;
+ packet->payload = &meta;
+ meta.samplerate = cur_samplerate;
+ meta.num_probes = NUM_PROBES;
+ sr_session_send(ctx->session_dev_id, packet);
+
g_free(header);
g_free(packet);