2 * This file is part of the sigrok-cli project.
4 * Copyright (C) 2011 Bert Vermeulen <bert@biot.com>
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.
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.
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/>.
20 #ifndef SIGROK_CLI_SIGROK_CLI_H
21 #define SIGROK_CLI_SIGROK_CLI_H
24 /* First, so we avoid a _POSIX_C_SOURCE warning. */
25 #include <libsigrokdecode/libsigrokdecode.h>
27 #include <libsigrok/libsigrok.h>
29 #define DEFAULT_OUTPUT_FORMAT_FILE "srzip"
30 #define DEFAULT_OUTPUT_FORMAT_NOFILE "bits:width=64"
33 extern struct sr_context
*sr_ctx
;
34 int select_channels(struct sr_dev_inst
*sdi
);
35 int maybe_config_get(struct sr_dev_driver
*driver
,
36 const struct sr_dev_inst
*sdi
, struct sr_channel_group
*cg
,
37 uint32_t key
, GVariant
**gvar
);
38 int maybe_config_set(struct sr_dev_driver
*driver
,
39 const struct sr_dev_inst
*sdi
, struct sr_channel_group
*cg
,
40 uint32_t key
, GVariant
*gvar
);
41 int maybe_config_list(struct sr_dev_driver
*driver
,
42 const struct sr_dev_inst
*sdi
, struct sr_channel_group
*cg
,
43 uint32_t key
, GVariant
**gvar
);
46 void show_version(void);
47 void show_supported(void);
48 void show_supported_wiki(void);
49 void show_dev_list(void);
50 void show_dev_detail(void);
51 void show_pd_detail(void);
52 void show_input(void);
53 void show_output(void);
54 void show_transform(void);
55 void show_serial_ports(void);
58 GSList
*device_scan(void);
59 struct sr_channel_group
*lookup_channel_group(struct sr_dev_inst
*sdi
);
63 struct sr_session
*session
;
65 struct input_stream_props
{
68 const struct sr_channel
*first_analog_channel
;
70 uint64_t sample_count_logic
;
71 uint64_t sample_count_analog
;
76 void datafeed_in(const struct sr_dev_inst
*sdi
,
77 const struct sr_datafeed_packet
*packet
, void *cb_data
);
78 int opt_to_gvar(char *key
, char *value
, struct sr_config
*src
);
79 int set_dev_options(struct sr_dev_inst
*sdi
, GHashTable
*args
);
80 void run_session(void);
83 void load_input_file(gboolean do_props
);
86 int setup_binary_stdout(void);
90 extern uint64_t pd_samplerate
;
91 int register_pds(gchar
**all_pds
, char *opt_pd_annotations
);
92 int setup_pd_annotations(char *opt_pd_annotations
);
93 int setup_pd_meta(char *opt_pd_meta
);
94 int setup_pd_binary(char *opt_pd_binary
);
95 void show_pd_annotations(struct srd_proto_data
*pdata
, void *cb_data
);
96 void show_pd_meta(struct srd_proto_data
*pdata
, void *cb_data
);
97 void show_pd_binary(struct srd_proto_data
*pdata
, void *cb_data
);
98 void show_pd_prepare(void);
99 void show_pd_close(void);
100 void map_pd_channels(struct sr_dev_inst
*sdi
);
104 struct sr_channel
*find_channel(GSList
*channellist
, const char *channelname
);
105 GSList
*parse_channelstring(struct sr_dev_inst
*sdi
, const char *channelstring
);
106 int parse_triggerstring(const struct sr_dev_inst
*sdi
, const char *s
,
107 struct sr_trigger
**trigger
);
108 GHashTable
*parse_generic_arg(const char *arg
,
109 gboolean sep_first
, const char *key_first
);
110 GHashTable
*generic_arg_to_opt(const struct sr_option
**opts
, GHashTable
*genargs
);
111 GSList
*check_unknown_keys(const struct sr_option
**avail
, GHashTable
*used
);
112 gboolean
warn_unknown_keys(const struct sr_option
**avail
, GHashTable
*used
,
113 const char *caption
);
114 int canon_cmp(const char *str1
, const char *str2
);
115 int parse_driver(char *arg
, struct sr_dev_driver
**driver
, GSList
**drvopts
);
118 void add_anykey(struct sr_session
*session
);
119 void clear_anykey(void);
122 extern gboolean opt_version
;
123 extern gboolean opt_list_supported
;
124 extern gboolean opt_list_supported_wiki
;
125 extern gint opt_loglevel
;
126 extern gboolean opt_scan_devs
;
127 extern gboolean opt_dont_scan
;
128 extern gboolean opt_wait_trigger
;
129 extern gchar
*opt_input_file
;
130 extern gchar
*opt_output_file
;
131 extern gchar
*opt_drv
;
132 extern gchar
*opt_config
;
133 extern gchar
*opt_channels
;
134 extern gchar
*opt_channel_group
;
135 extern gchar
*opt_triggers
;
136 extern gchar
**opt_pds
;
138 extern gchar
*opt_pd_annotations
;
139 extern gchar
*opt_pd_meta
;
140 extern gchar
*opt_pd_binary
;
141 extern gboolean opt_pd_samplenum
;
142 extern gboolean opt_pd_jsontrace
;
144 extern gchar
*opt_input_format
;
145 extern gchar
*opt_output_format
;
146 extern gchar
*opt_transform_module
;
147 extern gboolean opt_show
;
148 extern gchar
*opt_time
;
149 extern gchar
*opt_samples
;
150 extern gchar
*opt_frames
;
151 extern gboolean opt_continuous
;
152 extern gchar
*opt_get
;
153 extern gboolean opt_set
;
154 extern gboolean opt_list_serial
;
155 int parse_options(int argc
, char **argv
);
156 void show_help(void);