blob: 4ea449f69be1318742d641e045a1b38799d196a1 [file] [log] [blame]
Uwe Hermann43e57472011-12-30 11:23:22 +01001/*
Uwe Hermann630293b2013-04-23 22:10:41 +02002 * This file is part of the sigrok-cli project.
Uwe Hermann43e57472011-12-30 11:23:22 +01003 *
4 * Copyright (C) 2011 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
Uwe Hermann60e19732012-02-04 10:41:30 +010020#ifndef SIGROK_CLI_SIGROK_CLI_H
21#define SIGROK_CLI_SIGROK_CLI_H
Uwe Hermann43e57472011-12-30 11:23:22 +010022
Bert Vermeulen2be182e2013-11-17 13:15:38 +010023#include "config.h"
Bert Vermeulen2be182e2013-11-17 13:15:38 +010024#ifdef HAVE_SRD
Uwe Hermann20fb52e2013-11-19 11:48:06 +010025/* First, so we avoid a _POSIX_C_SOURCE warning. */
Bert Vermeulen2be182e2013-11-17 13:15:38 +010026#include <libsigrokdecode/libsigrokdecode.h>
27#endif
Uwe Hermann20fb52e2013-11-19 11:48:06 +010028#include <libsigrok/libsigrok.h>
Bert Vermeulen2be182e2013-11-17 13:15:38 +010029
30#define DEFAULT_OUTPUT_FORMAT "bits:width=64"
Bert Vermeulen6ea663a2014-03-12 19:12:20 +010031#define SAVE_CHUNK_SIZE 524288
Bert Vermeulen2be182e2013-11-17 13:15:38 +010032
33/* main.c */
Uwe Hermann029d73f2014-03-24 22:32:47 +010034int select_channels(struct sr_dev_inst *sdi);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010035
36/* show.c */
37void show_version(void);
38void show_dev_list(void);
39void show_dev_detail(void);
40void show_pd_detail(void);
Bert Vermeulena8b40412014-08-10 16:58:36 +020041void show_input(void);
Bert Vermeulenad6520c2014-07-25 22:39:48 +020042void show_output(void);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010043
44/* device.c */
45GSList *device_scan(void);
Uwe Hermannca50f4b2014-03-14 21:46:10 +010046struct sr_channel_group *select_channel_group(struct sr_dev_inst *sdi);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010047
48/* session.c */
Bert Vermeulen2be182e2013-11-17 13:15:38 +010049void datafeed_in(const struct sr_dev_inst *sdi,
50 const struct sr_datafeed_packet *packet, void *cb_data);
Bert Vermeulenad54a1a2013-12-26 12:08:34 +010051int opt_to_gvar(char *key, char *value, struct sr_config *src);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010052int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args);
53void run_session(void);
Bert Vermeulen4bf77ec2014-07-17 22:49:20 +020054void save_chunk_logic(struct sr_session *session, uint8_t *data,
55 uint64_t data_len, int unitsize);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010056
57/* input.c */
58void load_input_file(void);
59
60/* decode.c */
Dan Horák8d52f782014-01-25 14:15:24 +010061#ifdef HAVE_SRD
Bert Vermeulen26c63752013-11-17 18:51:15 +010062int register_pds(const char *opt_pds, char *opt_pd_annotations);
63int setup_pd_stack(char *opt_pds, char *opt_pd_stack, char *opt_pd_annotations);
64int setup_pd_annotations(char *opt_pd_annotations);
65int setup_pd_meta(char *opt_pd_meta);
66int setup_pd_binary(char *opt_pd_binary);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010067void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data);
68void show_pd_meta(struct srd_proto_data *pdata, void *cb_data);
69void show_pd_binary(struct srd_proto_data *pdata, void *cb_data);
Uwe Hermann3dfbfbc2014-04-12 13:42:30 +020070void map_pd_channels(struct sr_dev_inst *sdi);
Dan Horák8d52f782014-01-25 14:15:24 +010071#endif
Uwe Hermann43e57472011-12-30 11:23:22 +010072
73/* parsers.c */
Uwe Hermann029d73f2014-03-24 22:32:47 +010074struct sr_channel *find_channel(GSList *channellist, const char *channelname);
75GSList *parse_channelstring(struct sr_dev_inst *sdi, const char *channelstring);
Bert Vermeulen4bf77ec2014-07-17 22:49:20 +020076int parse_triggerstring(const struct sr_dev_inst *sdi, const char *s,
77 struct sr_trigger **trigger);
Bert Vermeulen63bb4542012-07-16 01:03:30 +020078GHashTable *parse_generic_arg(const char *arg, gboolean sep_first);
Bert Vermeulen87e24fe2014-08-20 17:31:17 +020079GHashTable *generic_arg_to_opt(const struct sr_option **opts, GHashTable *genargs);
Uwe Hermannd2ee5ee2012-05-30 22:15:29 +020080int canon_cmp(const char *str1, const char *str2);
Bert Vermeulend75c8522014-10-27 21:29:17 +010081int parse_driver(char *arg, struct sr_dev_driver **driver, GSList **drvopts);
Uwe Hermann43e57472011-12-30 11:23:22 +010082
83/* anykey.c */
Bert Vermeulen4bf77ec2014-07-17 22:49:20 +020084void add_anykey(struct sr_session *session);
Uwe Hermann43e57472011-12-30 11:23:22 +010085void clear_anykey(void);
86
Jens Steinhausercd62e022014-07-15 17:14:03 +020087/* options.c */
88extern gboolean opt_version;
89extern gint opt_loglevel;
90extern gboolean opt_scan_devs;
91extern gboolean opt_wait_trigger;
92extern gchar *opt_input_file;
93extern gchar *opt_output_file;
94extern gchar *opt_drv;
95extern gchar *opt_config;
96extern gchar *opt_channels;
97extern gchar *opt_channel_group;
98extern gchar *opt_triggers;
99extern gchar *opt_pds;
100#ifdef HAVE_SRD
101extern gchar *opt_pd_stack;
102extern gchar *opt_pd_annotations;
103extern gchar *opt_pd_meta;
104extern gchar *opt_pd_binary;
105#endif
106extern gchar *opt_input_format;
107extern gchar *opt_output_format;
108extern gchar *opt_show;
109extern gchar *opt_time;
110extern gchar *opt_samples;
111extern gchar *opt_frames;
112extern gchar *opt_continuous;
Bert Vermeulen62a64762014-09-10 17:57:01 +0200113extern gchar *opt_get;
Jens Steinhausercd62e022014-07-15 17:14:03 +0200114extern gchar *opt_set;
115int parse_options(int argc, char **argv);
116void show_help(void);
117
Uwe Hermann43e57472011-12-30 11:23:22 +0100118#endif