blob: a3ff81eb2de6205ae91dfb6c4aa0f338cb371876 [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 Vermeulenad6520c2014-07-25 22:39:48 +020041void show_output(void);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010042
43/* device.c */
44GSList *device_scan(void);
Uwe Hermannca50f4b2014-03-14 21:46:10 +010045struct sr_channel_group *select_channel_group(struct sr_dev_inst *sdi);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010046
47/* session.c */
Bert Vermeulen2be182e2013-11-17 13:15:38 +010048void datafeed_in(const struct sr_dev_inst *sdi,
49 const struct sr_datafeed_packet *packet, void *cb_data);
Bert Vermeulenad54a1a2013-12-26 12:08:34 +010050int opt_to_gvar(char *key, char *value, struct sr_config *src);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010051int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args);
52void run_session(void);
Bert Vermeulen4bf77ec2014-07-17 22:49:20 +020053void save_chunk_logic(struct sr_session *session, uint8_t *data,
54 uint64_t data_len, int unitsize);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010055
56/* input.c */
57void load_input_file(void);
58
59/* decode.c */
Dan Horák8d52f782014-01-25 14:15:24 +010060#ifdef HAVE_SRD
Bert Vermeulen26c63752013-11-17 18:51:15 +010061int register_pds(const char *opt_pds, char *opt_pd_annotations);
62int setup_pd_stack(char *opt_pds, char *opt_pd_stack, char *opt_pd_annotations);
63int setup_pd_annotations(char *opt_pd_annotations);
64int setup_pd_meta(char *opt_pd_meta);
65int setup_pd_binary(char *opt_pd_binary);
Bert Vermeulen2be182e2013-11-17 13:15:38 +010066void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data);
67void show_pd_meta(struct srd_proto_data *pdata, void *cb_data);
68void show_pd_binary(struct srd_proto_data *pdata, void *cb_data);
Uwe Hermann3dfbfbc2014-04-12 13:42:30 +020069void map_pd_channels(struct sr_dev_inst *sdi);
Dan Horák8d52f782014-01-25 14:15:24 +010070#endif
Uwe Hermann43e57472011-12-30 11:23:22 +010071
72/* parsers.c */
Uwe Hermann029d73f2014-03-24 22:32:47 +010073struct sr_channel *find_channel(GSList *channellist, const char *channelname);
74GSList *parse_channelstring(struct sr_dev_inst *sdi, const char *channelstring);
Bert Vermeulen4bf77ec2014-07-17 22:49:20 +020075int parse_triggerstring(const struct sr_dev_inst *sdi, const char *s,
76 struct sr_trigger **trigger);
Bert Vermeulen63bb4542012-07-16 01:03:30 +020077GHashTable *parse_generic_arg(const char *arg, gboolean sep_first);
Bert Vermeulen87e24fe2014-08-20 17:31:17 +020078GHashTable *generic_arg_to_opt(const struct sr_option **opts, GHashTable *genargs);
Uwe Hermannd2ee5ee2012-05-30 22:15:29 +020079int canon_cmp(const char *str1, const char *str2);
Uwe Hermann43e57472011-12-30 11:23:22 +010080
81/* anykey.c */
Bert Vermeulen4bf77ec2014-07-17 22:49:20 +020082void add_anykey(struct sr_session *session);
Uwe Hermann43e57472011-12-30 11:23:22 +010083void clear_anykey(void);
84
Jens Steinhausercd62e022014-07-15 17:14:03 +020085/* options.c */
86extern gboolean opt_version;
87extern gint opt_loglevel;
88extern gboolean opt_scan_devs;
89extern gboolean opt_wait_trigger;
90extern gchar *opt_input_file;
91extern gchar *opt_output_file;
92extern gchar *opt_drv;
93extern gchar *opt_config;
94extern gchar *opt_channels;
95extern gchar *opt_channel_group;
96extern gchar *opt_triggers;
97extern gchar *opt_pds;
98#ifdef HAVE_SRD
99extern gchar *opt_pd_stack;
100extern gchar *opt_pd_annotations;
101extern gchar *opt_pd_meta;
102extern gchar *opt_pd_binary;
103#endif
104extern gchar *opt_input_format;
105extern gchar *opt_output_format;
106extern gchar *opt_show;
107extern gchar *opt_time;
108extern gchar *opt_samples;
109extern gchar *opt_frames;
110extern gchar *opt_continuous;
111extern gchar *opt_set;
112int parse_options(int argc, char **argv);
113void show_help(void);
114
Uwe Hermann43e57472011-12-30 11:23:22 +0100115#endif