X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdemo%2Fapi.c;h=bea35d068f63042a04fd7b27b6d691f3778ad0fb;hb=b1fa9aac740d8fb2d6aaad8974e06680a817524c;hp=4d4b891c651a1886daf01e74757703d7fd05976b;hpb=9618fde4226a7cf1ab891be6d5581b41e071a0af;p=libsigrok.git diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 4d4b891c..bea35d06 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -32,7 +32,7 @@ #define DEFAULT_NUM_LOGIC_CHANNELS 8 #define DEFAULT_LOGIC_PATTERN PATTERN_SIGROK -#define DEFAULT_NUM_ANALOG_CHANNELS 4 +#define DEFAULT_NUM_ANALOG_CHANNELS 5 /* Note: No spaces allowed because of sigrok-cli. */ static const char *logic_pattern_str[] = { @@ -151,14 +151,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) if (num_logic_channels > 0) { /* Logic channels, all in one channel group. */ - cg = g_malloc0(sizeof(struct sr_channel_group)); - cg->name = g_strdup("Logic"); + cg = sr_channel_group_new(sdi, "Logic", NULL); for (i = 0; i < num_logic_channels; i++) { sprintf(channel_name, "D%d", i); ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name); cg->channels = g_slist_append(cg->channels, ch); } - sdi->channel_groups = g_slist_append(NULL, cg); } /* Analog channels, channel groups and pattern generators. */ @@ -173,9 +171,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) pattern = 0; /* An "Analog" channel group with all analog channels in it. */ - acg = g_malloc0(sizeof(struct sr_channel_group)); - acg->name = g_strdup("Analog"); - sdi->channel_groups = g_slist_append(sdi->channel_groups, acg); + acg = sr_channel_group_new(sdi, "Analog", NULL); for (i = 0; i < num_analog_channels; i++) { snprintf(channel_name, 16, "A%d", i); @@ -184,10 +180,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) acg->channels = g_slist_append(acg->channels, ch); /* Every analog channel gets its own channel group as well. */ - cg = g_malloc0(sizeof(struct sr_channel_group)); - cg->name = g_strdup(channel_name); + cg = sr_channel_group_new(sdi, channel_name, NULL); cg->channels = g_slist_append(NULL, ch); - sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); /* Every channel gets a generator struct. */ ag = g_malloc(sizeof(struct analog_gen)); @@ -225,6 +219,8 @@ static void clear_helper(struct dev_context *devc) GHashTableIter iter; void *value; + demo_free_analog_pattern(devc); + /* Analog generators. */ g_hash_table_iter_init(&iter, devc->ch_ag); while (g_hash_table_iter_next(&iter, NULL, &value)) @@ -571,7 +567,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) std_session_send_df_header(sdi); if (devc->limit_frames > 0) - std_session_send_frame_begin(sdi); + std_session_send_df_frame_begin(sdi); /* We use this timestamp to decide how many more samples to send. */ devc->start_us = g_get_monotonic_time(); @@ -589,7 +585,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) devc = sdi->priv; if (devc->limit_frames > 0) - std_session_send_frame_end(sdi); + std_session_send_df_frame_end(sdi); std_session_send_df_end(sdi);