]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the sigrok-cli project. | |
3 | * | |
4 | * Copyright (C) 2013 Bert Vermeulen <bert@biot.com> | |
5 | * | |
6 | * This program is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #include "sigrok-cli.h" | |
21 | #include <glib.h> | |
22 | #include <glib/gstdio.h> | |
23 | #include <string.h> | |
24 | #include <stdlib.h> | |
25 | ||
26 | static uint64_t limit_samples = 0; | |
27 | static uint64_t limit_frames = 0; | |
28 | static char *srzip_and_filename = NULL; | |
29 | ||
30 | #ifdef HAVE_SRD | |
31 | extern struct srd_session *srd_sess; | |
32 | #endif | |
33 | ||
34 | static int set_limit_time(const struct sr_dev_inst *sdi) | |
35 | { | |
36 | GVariant *gvar; | |
37 | uint64_t time_msec; | |
38 | uint64_t samplerate; | |
39 | struct sr_dev_driver *driver; | |
40 | ||
41 | driver = sr_dev_inst_driver_get(sdi); | |
42 | ||
43 | if (!(time_msec = sr_parse_timestring(opt_time))) { | |
44 | g_critical("Invalid time '%s'", opt_time); | |
45 | return SR_ERR; | |
46 | } | |
47 | ||
48 | if (config_key_has_cap(driver, sdi, NULL, SR_CONF_LIMIT_MSEC, SR_CONF_SET)) { | |
49 | gvar = g_variant_new_uint64(time_msec); | |
50 | if (sr_config_set(sdi, NULL, SR_CONF_LIMIT_MSEC, gvar) != SR_OK) { | |
51 | g_critical("Failed to configure time limit."); | |
52 | return SR_ERR; | |
53 | } | |
54 | } else if (config_key_has_cap(driver, sdi, NULL, SR_CONF_SAMPLERATE, | |
55 | SR_CONF_GET | SR_CONF_SET)) { | |
56 | /* Convert to samples based on the samplerate. */ | |
57 | sr_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE, &gvar); | |
58 | samplerate = g_variant_get_uint64(gvar); | |
59 | g_variant_unref(gvar); | |
60 | limit_samples = (samplerate) * time_msec / (uint64_t)1000; | |
61 | if (limit_samples == 0) { | |
62 | g_critical("Not enough time at this samplerate."); | |
63 | return SR_ERR; | |
64 | } | |
65 | gvar = g_variant_new_uint64(limit_samples); | |
66 | if (sr_config_set(sdi, NULL, SR_CONF_LIMIT_SAMPLES, gvar) != SR_OK) { | |
67 | g_critical("Failed to configure time-based sample limit."); | |
68 | return SR_ERR; | |
69 | } | |
70 | } else { | |
71 | g_critical("This device does not support time limits."); | |
72 | return SR_ERR; | |
73 | } | |
74 | ||
75 | return SR_OK; | |
76 | } | |
77 | ||
78 | const struct sr_output *setup_output_format(const struct sr_dev_inst *sdi) | |
79 | { | |
80 | const struct sr_output_module *omod; | |
81 | const struct sr_option **options; | |
82 | const struct sr_output *o; | |
83 | GHashTable *fmtargs, *fmtopts; | |
84 | int size; | |
85 | char *fmtspec; | |
86 | ||
87 | if (!opt_output_format) { | |
88 | if (opt_output_file) { | |
89 | size = strlen(opt_output_file) + 32; | |
90 | srzip_and_filename = g_malloc(size); | |
91 | snprintf(srzip_and_filename, size, "srzip:filename=%s", opt_output_file); | |
92 | opt_output_format = srzip_and_filename; | |
93 | } else { | |
94 | opt_output_format = DEFAULT_OUTPUT_FORMAT; | |
95 | } | |
96 | } | |
97 | ||
98 | fmtargs = parse_generic_arg(opt_output_format, TRUE); | |
99 | fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key"); | |
100 | if (!fmtspec) | |
101 | g_critical("Invalid output format."); | |
102 | if (!(omod = sr_output_find(fmtspec))) | |
103 | g_critical("Unknown output module '%s'.", fmtspec); | |
104 | g_hash_table_remove(fmtargs, "sigrok_key"); | |
105 | if ((options = sr_output_options_get(omod))) { | |
106 | fmtopts = generic_arg_to_opt(options, fmtargs); | |
107 | sr_output_options_free(options); | |
108 | } else | |
109 | fmtopts = NULL; | |
110 | o = sr_output_new(omod, fmtopts, sdi); | |
111 | if (fmtopts) | |
112 | g_hash_table_destroy(fmtopts); | |
113 | g_hash_table_destroy(fmtargs); | |
114 | ||
115 | return o; | |
116 | } | |
117 | ||
118 | void datafeed_in(const struct sr_dev_inst *sdi, | |
119 | const struct sr_datafeed_packet *packet, void *cb_data) | |
120 | { | |
121 | const struct sr_datafeed_meta *meta; | |
122 | const struct sr_datafeed_logic *logic; | |
123 | const struct sr_datafeed_analog *analog; | |
124 | struct sr_session *session; | |
125 | struct sr_config *src; | |
126 | static const struct sr_output *o = NULL; | |
127 | static const struct sr_output *oa = NULL; | |
128 | static uint64_t rcvd_samples_logic = 0; | |
129 | static uint64_t rcvd_samples_analog = 0; | |
130 | static uint64_t samplerate = 0; | |
131 | static int triggered = 0; | |
132 | static FILE *outfile = NULL; | |
133 | GSList *l; | |
134 | GString *out; | |
135 | GVariant *gvar; | |
136 | uint64_t end_sample; | |
137 | uint64_t input_len; | |
138 | struct sr_dev_driver *driver; | |
139 | ||
140 | driver = sr_dev_inst_driver_get(sdi); | |
141 | ||
142 | /* If the first packet to come in isn't a header, don't even try. */ | |
143 | if (packet->type != SR_DF_HEADER && o == NULL) | |
144 | return; | |
145 | ||
146 | session = cb_data; | |
147 | switch (packet->type) { | |
148 | case SR_DF_HEADER: | |
149 | g_debug("cli: Received SR_DF_HEADER."); | |
150 | if (!(o = setup_output_format(sdi))) | |
151 | g_critical("Failed to initialize output module."); | |
152 | ||
153 | /* Set up backup analog output module. */ | |
154 | oa = sr_output_new(sr_output_find("analog"), NULL, sdi); | |
155 | ||
156 | if (opt_output_file) | |
157 | outfile = g_fopen(opt_output_file, "wb"); | |
158 | else | |
159 | outfile = stdout; | |
160 | ||
161 | rcvd_samples_logic = rcvd_samples_analog = 0; | |
162 | ||
163 | if (maybe_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE, | |
164 | &gvar) == SR_OK) { | |
165 | samplerate = g_variant_get_uint64(gvar); | |
166 | g_variant_unref(gvar); | |
167 | } | |
168 | ||
169 | #ifdef HAVE_SRD | |
170 | if (opt_pds) { | |
171 | if (samplerate) { | |
172 | if (srd_session_metadata_set(srd_sess, SRD_CONF_SAMPLERATE, | |
173 | g_variant_new_uint64(samplerate)) != SRD_OK) { | |
174 | g_critical("Failed to configure decode session."); | |
175 | break; | |
176 | } | |
177 | } | |
178 | if (srd_session_start(srd_sess) != SRD_OK) { | |
179 | g_critical("Failed to start decode session."); | |
180 | break; | |
181 | } | |
182 | } | |
183 | #endif | |
184 | break; | |
185 | ||
186 | case SR_DF_META: | |
187 | g_debug("cli: Received SR_DF_META."); | |
188 | meta = packet->payload; | |
189 | for (l = meta->config; l; l = l->next) { | |
190 | src = l->data; | |
191 | switch (src->key) { | |
192 | case SR_CONF_SAMPLERATE: | |
193 | samplerate = g_variant_get_uint64(src->data); | |
194 | g_debug("cli: Got samplerate %"PRIu64" Hz.", samplerate); | |
195 | #ifdef HAVE_SRD | |
196 | if (opt_pds) { | |
197 | if (srd_session_metadata_set(srd_sess, SRD_CONF_SAMPLERATE, | |
198 | g_variant_new_uint64(samplerate)) != SRD_OK) { | |
199 | g_critical("Failed to pass samplerate to decoder."); | |
200 | } | |
201 | } | |
202 | #endif | |
203 | break; | |
204 | case SR_CONF_SAMPLE_INTERVAL: | |
205 | samplerate = g_variant_get_uint64(src->data); | |
206 | g_debug("cli: Got sample interval %"PRIu64" ms.", samplerate); | |
207 | break; | |
208 | default: | |
209 | /* Unknown metadata is not an error. */ | |
210 | break; | |
211 | } | |
212 | } | |
213 | break; | |
214 | ||
215 | case SR_DF_TRIGGER: | |
216 | g_debug("cli: Received SR_DF_TRIGGER."); | |
217 | triggered = 1; | |
218 | break; | |
219 | ||
220 | case SR_DF_LOGIC: | |
221 | logic = packet->payload; | |
222 | g_message("cli: Received SR_DF_LOGIC (%"PRIu64" bytes, unitsize = %d).", | |
223 | logic->length, logic->unitsize); | |
224 | if (logic->length == 0) | |
225 | break; | |
226 | ||
227 | /* Don't store any samples until triggered. */ | |
228 | if (opt_wait_trigger && !triggered) | |
229 | break; | |
230 | ||
231 | if (limit_samples && rcvd_samples_logic >= limit_samples) | |
232 | break; | |
233 | ||
234 | end_sample = rcvd_samples_logic + logic->length / logic->unitsize; | |
235 | /* Cut off last packet according to the sample limit. */ | |
236 | if (limit_samples && end_sample > limit_samples) | |
237 | end_sample = limit_samples; | |
238 | input_len = (end_sample - rcvd_samples_logic) * logic->unitsize; | |
239 | ||
240 | if (opt_pds) { | |
241 | #ifdef HAVE_SRD | |
242 | if (srd_session_send(srd_sess, rcvd_samples_logic, end_sample, | |
243 | logic->data, input_len) != SRD_OK) | |
244 | sr_session_stop(session); | |
245 | #endif | |
246 | } | |
247 | ||
248 | rcvd_samples_logic = end_sample; | |
249 | break; | |
250 | ||
251 | case SR_DF_ANALOG: | |
252 | analog = packet->payload; | |
253 | g_message("cli: Received SR_DF_ANALOG (%d samples).", analog->num_samples); | |
254 | if (analog->num_samples == 0) | |
255 | break; | |
256 | ||
257 | if (limit_samples && rcvd_samples_analog >= limit_samples) | |
258 | break; | |
259 | ||
260 | rcvd_samples_analog += analog->num_samples; | |
261 | break; | |
262 | ||
263 | case SR_DF_FRAME_BEGIN: | |
264 | g_debug("cli: Received SR_DF_FRAME_BEGIN."); | |
265 | break; | |
266 | ||
267 | case SR_DF_FRAME_END: | |
268 | g_debug("cli: Received SR_DF_FRAME_END."); | |
269 | break; | |
270 | ||
271 | default: | |
272 | break; | |
273 | } | |
274 | ||
275 | if (o && outfile && !opt_pds) { | |
276 | if (sr_output_send(o, packet, &out) == SR_OK) { | |
277 | if (!out || (out->len == 0 | |
278 | && !opt_output_format | |
279 | && packet->type == SR_DF_ANALOG)) { | |
280 | /* The user didn't specify an output module, | |
281 | * but needs to see this analog data. */ | |
282 | sr_output_send(oa, packet, &out); | |
283 | } | |
284 | if (out && out->len > 0) { | |
285 | fwrite(out->str, 1, out->len, outfile); | |
286 | fflush(outfile); | |
287 | } | |
288 | if (out) | |
289 | g_string_free(out, TRUE); | |
290 | } | |
291 | } | |
292 | ||
293 | /* SR_DF_END needs to be handled after the output module's receive() | |
294 | * is called, so it can properly clean up that module. */ | |
295 | if (packet->type == SR_DF_END) { | |
296 | g_debug("cli: Received SR_DF_END."); | |
297 | ||
298 | if (o) { | |
299 | sr_output_free(o); | |
300 | if (srzip_and_filename) | |
301 | g_free(srzip_and_filename); | |
302 | } | |
303 | o = NULL; | |
304 | ||
305 | sr_output_free(oa); | |
306 | oa = NULL; | |
307 | ||
308 | if (outfile && outfile != stdout) | |
309 | fclose(outfile); | |
310 | ||
311 | if (limit_samples) { | |
312 | if (rcvd_samples_logic > 0 && rcvd_samples_logic < limit_samples) | |
313 | g_warning("Device only sent %" PRIu64 " samples.", | |
314 | rcvd_samples_logic); | |
315 | else if (rcvd_samples_analog > 0 && rcvd_samples_analog < limit_samples) | |
316 | g_warning("Device only sent %" PRIu64 " samples.", | |
317 | rcvd_samples_analog); | |
318 | } | |
319 | } | |
320 | ||
321 | } | |
322 | ||
323 | int opt_to_gvar(char *key, char *value, struct sr_config *src) | |
324 | { | |
325 | const struct sr_config_info *srci; | |
326 | double tmp_double, dlow, dhigh; | |
327 | uint64_t tmp_u64, p, q, low, high; | |
328 | GVariant *rational[2], *range[2]; | |
329 | gboolean tmp_bool; | |
330 | int ret; | |
331 | ||
332 | if (!(srci = sr_config_info_name_get(key))) { | |
333 | g_critical("Unknown device option '%s'.", (char *) key); | |
334 | return -1; | |
335 | } | |
336 | src->key = srci->key; | |
337 | ||
338 | if ((value == NULL) && | |
339 | (srci->datatype != SR_T_BOOL)) { | |
340 | g_critical("Option '%s' needs a value.", (char *)key); | |
341 | return -1; | |
342 | } | |
343 | ||
344 | ret = 0; | |
345 | switch (srci->datatype) { | |
346 | case SR_T_UINT64: | |
347 | ret = sr_parse_sizestring(value, &tmp_u64); | |
348 | if (ret != 0) | |
349 | break; | |
350 | src->data = g_variant_new_uint64(tmp_u64); | |
351 | break; | |
352 | case SR_T_INT32: | |
353 | ret = sr_parse_sizestring(value, &tmp_u64); | |
354 | if (ret != 0) | |
355 | break; | |
356 | src->data = g_variant_new_int32(tmp_u64); | |
357 | break; | |
358 | case SR_T_STRING: | |
359 | src->data = g_variant_new_string(value); | |
360 | break; | |
361 | case SR_T_BOOL: | |
362 | if (!value) | |
363 | tmp_bool = TRUE; | |
364 | else | |
365 | tmp_bool = sr_parse_boolstring(value); | |
366 | src->data = g_variant_new_boolean(tmp_bool); | |
367 | break; | |
368 | case SR_T_FLOAT: | |
369 | tmp_double = strtof(value, NULL); | |
370 | src->data = g_variant_new_double(tmp_double); | |
371 | break; | |
372 | case SR_T_RATIONAL_PERIOD: | |
373 | if ((ret = sr_parse_period(value, &p, &q)) != SR_OK) | |
374 | break; | |
375 | rational[0] = g_variant_new_uint64(p); | |
376 | rational[1] = g_variant_new_uint64(q); | |
377 | src->data = g_variant_new_tuple(rational, 2); | |
378 | break; | |
379 | case SR_T_RATIONAL_VOLT: | |
380 | if ((ret = sr_parse_voltage(value, &p, &q)) != SR_OK) | |
381 | break; | |
382 | rational[0] = g_variant_new_uint64(p); | |
383 | rational[1] = g_variant_new_uint64(q); | |
384 | src->data = g_variant_new_tuple(rational, 2); | |
385 | break; | |
386 | case SR_T_UINT64_RANGE: | |
387 | if (sscanf(value, "%"PRIu64"-%"PRIu64, &low, &high) != 2) { | |
388 | ret = -1; | |
389 | break; | |
390 | } else { | |
391 | range[0] = g_variant_new_uint64(low); | |
392 | range[1] = g_variant_new_uint64(high); | |
393 | src->data = g_variant_new_tuple(range, 2); | |
394 | } | |
395 | break; | |
396 | case SR_T_DOUBLE_RANGE: | |
397 | if (sscanf(value, "%lf-%lf", &dlow, &dhigh) != 2) { | |
398 | ret = -1; | |
399 | break; | |
400 | } else { | |
401 | range[0] = g_variant_new_double(dlow); | |
402 | range[1] = g_variant_new_double(dhigh); | |
403 | src->data = g_variant_new_tuple(range, 2); | |
404 | } | |
405 | break; | |
406 | default: | |
407 | g_critical("Unknown data type specified for option '%s' " | |
408 | "(driver implementation bug?).", key); | |
409 | ret = -1; | |
410 | } | |
411 | ||
412 | return ret; | |
413 | } | |
414 | ||
415 | int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args) | |
416 | { | |
417 | struct sr_config src; | |
418 | struct sr_channel_group *cg; | |
419 | GHashTableIter iter; | |
420 | gpointer key, value; | |
421 | int ret; | |
422 | ||
423 | g_hash_table_iter_init(&iter, args); | |
424 | while (g_hash_table_iter_next(&iter, &key, &value)) { | |
425 | if ((ret = opt_to_gvar(key, value, &src)) != 0) | |
426 | return ret; | |
427 | cg = select_channel_group(sdi); | |
428 | if ((ret = maybe_config_set(sr_dev_inst_driver_get(sdi), sdi, cg, | |
429 | src.key, src.data)) != SR_OK) { | |
430 | g_critical("Failed to set device option '%s'.", (char *)key); | |
431 | return ret; | |
432 | } | |
433 | } | |
434 | ||
435 | return SR_OK; | |
436 | } | |
437 | ||
438 | void run_session(void) | |
439 | { | |
440 | GSList *devices, *real_devices, *sd; | |
441 | GHashTable *devargs; | |
442 | GVariant *gvar; | |
443 | struct sr_session *session; | |
444 | struct sr_trigger *trigger; | |
445 | struct sr_dev_inst *sdi; | |
446 | uint64_t min_samples, max_samples; | |
447 | gsize n_elements, i; | |
448 | const uint32_t *dev_opts; | |
449 | int is_demo_dev; | |
450 | struct sr_dev_driver *driver; | |
451 | ||
452 | devices = device_scan(); | |
453 | if (!devices) { | |
454 | g_critical("No devices found."); | |
455 | return; | |
456 | } | |
457 | ||
458 | real_devices = NULL; | |
459 | for (sd = devices; sd; sd = sd->next) { | |
460 | sdi = sd->data; | |
461 | ||
462 | driver = sr_dev_inst_driver_get(sdi); | |
463 | ||
464 | if (sr_config_list(driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS, &gvar) != SR_OK) { | |
465 | g_critical("Failed to query list device options."); | |
466 | return; | |
467 | } | |
468 | ||
469 | dev_opts = g_variant_get_fixed_array(gvar, &n_elements, sizeof(uint32_t)); | |
470 | ||
471 | is_demo_dev = 0; | |
472 | for (i = 0; i < n_elements; i++) { | |
473 | if (dev_opts[i] == SR_CONF_DEMO_DEV) | |
474 | is_demo_dev = 1; | |
475 | } | |
476 | ||
477 | g_variant_unref(gvar); | |
478 | ||
479 | if (!is_demo_dev) | |
480 | real_devices = g_slist_append(real_devices, sdi); | |
481 | } | |
482 | ||
483 | if (g_slist_length(devices) > 1) { | |
484 | if (g_slist_length(real_devices) != 1) { | |
485 | g_critical("sigrok-cli only supports one device for capturing."); | |
486 | return; | |
487 | } else { | |
488 | /* We only have one non-demo device. */ | |
489 | g_slist_free(devices); | |
490 | devices = real_devices; | |
491 | real_devices = NULL; | |
492 | } | |
493 | } | |
494 | ||
495 | sdi = devices->data; | |
496 | g_slist_free(devices); | |
497 | g_slist_free(real_devices); | |
498 | ||
499 | sr_session_new(&session); | |
500 | sr_session_datafeed_callback_add(session, datafeed_in, NULL); | |
501 | ||
502 | if (sr_dev_open(sdi) != SR_OK) { | |
503 | g_critical("Failed to open device."); | |
504 | return; | |
505 | } | |
506 | ||
507 | if (sr_session_dev_add(session, sdi) != SR_OK) { | |
508 | g_critical("Failed to add device to session."); | |
509 | sr_session_destroy(session); | |
510 | return; | |
511 | } | |
512 | ||
513 | if (opt_config) { | |
514 | if ((devargs = parse_generic_arg(opt_config, FALSE))) { | |
515 | if (set_dev_options(sdi, devargs) != SR_OK) | |
516 | return; | |
517 | g_hash_table_destroy(devargs); | |
518 | } | |
519 | } | |
520 | ||
521 | if (select_channels(sdi) != SR_OK) { | |
522 | g_critical("Failed to set channels."); | |
523 | sr_session_destroy(session); | |
524 | return; | |
525 | } | |
526 | ||
527 | if (opt_triggers) { | |
528 | if (!parse_triggerstring(sdi, opt_triggers, &trigger)) { | |
529 | sr_session_destroy(session); | |
530 | return; | |
531 | } | |
532 | if (sr_session_trigger_set(session, trigger) != SR_OK) { | |
533 | sr_session_destroy(session); | |
534 | return; | |
535 | } | |
536 | } | |
537 | ||
538 | if (opt_continuous) { | |
539 | if (!sr_dev_has_option(sdi, SR_CONF_CONTINUOUS)) { | |
540 | g_critical("This device does not support continuous sampling."); | |
541 | sr_session_destroy(session); | |
542 | return; | |
543 | } | |
544 | } | |
545 | ||
546 | if (opt_time) { | |
547 | if (set_limit_time(sdi) != SR_OK) { | |
548 | sr_session_destroy(session); | |
549 | return; | |
550 | } | |
551 | } | |
552 | ||
553 | if (opt_samples) { | |
554 | if ((sr_parse_sizestring(opt_samples, &limit_samples) != SR_OK)) { | |
555 | g_critical("Invalid sample limit '%s'.", opt_samples); | |
556 | sr_session_destroy(session); | |
557 | return; | |
558 | } | |
559 | if (maybe_config_list(driver, sdi, NULL, SR_CONF_LIMIT_SAMPLES, | |
560 | &gvar) == SR_OK) { | |
561 | /* The device has no compression, or compression is turned | |
562 | * off, and publishes its sample memory size. */ | |
563 | g_variant_get(gvar, "(tt)", &min_samples, &max_samples); | |
564 | g_variant_unref(gvar); | |
565 | if (limit_samples < min_samples) { | |
566 | g_critical("The device stores at least %"PRIu64 | |
567 | " samples with the current settings.", min_samples); | |
568 | } | |
569 | if (limit_samples > max_samples) { | |
570 | g_critical("The device can store only %"PRIu64 | |
571 | " samples with the current settings.", max_samples); | |
572 | } | |
573 | } | |
574 | gvar = g_variant_new_uint64(limit_samples); | |
575 | if (maybe_config_set(sr_dev_inst_driver_get(sdi), sdi, NULL, SR_CONF_LIMIT_SAMPLES, gvar) != SR_OK) { | |
576 | g_critical("Failed to configure sample limit."); | |
577 | sr_session_destroy(session); | |
578 | return; | |
579 | } | |
580 | } | |
581 | ||
582 | if (opt_frames) { | |
583 | if ((sr_parse_sizestring(opt_frames, &limit_frames) != SR_OK)) { | |
584 | g_critical("Invalid sample limit '%s'.", opt_samples); | |
585 | sr_session_destroy(session); | |
586 | return; | |
587 | } | |
588 | gvar = g_variant_new_uint64(limit_frames); | |
589 | if (maybe_config_set(sr_dev_inst_driver_get(sdi), sdi, NULL, SR_CONF_LIMIT_FRAMES, gvar) != SR_OK) { | |
590 | g_critical("Failed to configure frame limit."); | |
591 | sr_session_destroy(session); | |
592 | return; | |
593 | } | |
594 | } | |
595 | ||
596 | if (sr_session_start(session) != SR_OK) { | |
597 | g_critical("Failed to start session."); | |
598 | sr_session_destroy(session); | |
599 | return; | |
600 | } | |
601 | ||
602 | if (opt_continuous) | |
603 | add_anykey(session); | |
604 | ||
605 | sr_session_run(session); | |
606 | ||
607 | if (opt_continuous) | |
608 | clear_anykey(); | |
609 | ||
610 | sr_session_datafeed_callback_remove_all(session); | |
611 | sr_session_destroy(session); | |
612 | ||
613 | } | |
614 |