]> sigrok.org Git - libsigrok.git/blob - sigrok-proto.h
387b228f4ce2f5d01e6d7cf3fe5a6fae3a3be5b6
[libsigrok.git] / sigrok-proto.h
1 /*
2  * This file is part of the sigrok project.
3  *
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
20 #ifndef SIGROK_SIGROK_PROTO_H
21 #define SIGROK_SIGROK_PROTO_H
22
23 /*--- backend.c -------------------------------------------------------------*/
24
25 int sr_init(void);
26 int sr_exit(void);
27
28 /*--- log.c -----------------------------------------------------------------*/
29
30 int sr_set_loglevel(int loglevel);
31 int sr_get_loglevel(void);
32
33 /*--- datastore.c -----------------------------------------------------------*/
34
35 int sr_datastore_new(int unitsize, struct sr_datastore **ds);
36 int sr_datastore_destroy(struct sr_datastore *ds);
37 int sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length,
38                      int in_unitsize, int *probelist);
39
40 /*--- device.c --------------------------------------------------------------*/
41
42 int sr_device_scan(void);
43 int sr_init_hwplugins(struct sr_device_plugin *plugin);
44 GSList *sr_device_list(void);
45 struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
46                                 int plugin_index, int num_probes);
47 int sr_device_clear(struct sr_device *device);
48 void sr_device_destroy(struct sr_device *dev);
49 int sr_device_probe_clear(struct sr_device *device, int probenum);
50 int sr_device_probe_add(struct sr_device *device, const char *name);
51 struct sr_probe *sr_device_probe_find(const struct sr_device *device,
52                                       int probenum);
53 int sr_device_probe_name(struct sr_device *device, int probenum,
54                          const char *name);
55 int sr_device_trigger_clear(struct sr_device *device);
56 int sr_device_trigger_set(struct sr_device *device, int probenum,
57                           const char *trigger);
58 gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap);
59
60 /*--- filter.c --------------------------------------------------------------*/
61
62 int sr_filter_probes(int in_unitsize, int out_unitsize, const int *probelist,
63                      const unsigned char *data_in, uint64_t length_in,
64                      char **data_out, uint64_t *length_out);
65
66 /*--- hwplugin.c ------------------------------------------------------------*/
67
68 GSList *sr_list_hwplugins(void);
69 void sr_cleanup_hwplugins(void);
70
71 /* Generic device instances */
72 struct sr_device_instance *sr_device_instance_new(int index,
73        int status, const char *vendor, const char *model, const char *version);
74 struct sr_device_instance *sr_get_device_instance(GSList *device_instances,
75                                                   int device_index);
76 void sr_device_instance_free(struct sr_device_instance *sdi);
77
78 /* USB-specific instances */
79 #ifdef HAVE_LIBUSB_1_0
80 struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
81                 uint8_t address, struct libusb_device_handle *hdl);
82 void sr_usb_device_instance_free(struct sr_usb_device_instance *usb);
83 #endif
84
85 /* Serial-specific instances */
86 struct sr_serial_device_instance *sr_serial_device_instance_new(
87                                         const char *port, int fd);
88 void sr_serial_device_instance_free(struct sr_serial_device_instance *serial);
89
90 int sr_find_hwcap(int *capabilities, int hwcap);
91 struct sr_hwcap_option *sr_find_hwcap_option(int hwcap);
92 void sr_source_remove(int fd);
93 void sr_source_add(int fd, int events, int timeout,
94                    sr_receive_data_callback rcv_cb, void *user_data);
95
96 /*--- session.c -------------------------------------------------------------*/
97
98 typedef void (*sr_datafeed_callback) (struct sr_device *device,
99                                       struct sr_datafeed_packet *packet);
100
101 /* Session setup */
102 int sr_session_load(const char *filename);
103 struct sr_session *sr_session_new(void);
104 void sr_session_destroy(void);
105 void sr_session_device_clear(void);
106 int sr_session_device_add(struct sr_device *device);
107
108 #if 0
109 /* Protocol analyzers setup */
110 void sr_session_pa_clear(void);
111 void sr_session_pa_add(struct sr_analyzer *pa);
112 #endif
113
114 /* Datafeed setup */
115 void sr_session_datafeed_callback_clear(void);
116 void sr_session_datafeed_callback_add(sr_datafeed_callback callback);
117
118 /* Session control */
119 int sr_session_start(void);
120 void sr_session_run(void);
121 void sr_session_halt(void);
122 void sr_session_stop(void);
123 void sr_session_bus(struct sr_device *device,
124                     struct sr_datafeed_packet *packet);
125 int sr_session_save(const char *filename);
126 void sr_session_source_add(int fd, int events, int timeout,
127                 sr_receive_data_callback callback, void *user_data);
128 void sr_session_source_remove(int fd);
129
130 /*--- input/input.c ---------------------------------------------------------*/
131
132 struct sr_input_format **sr_input_list(void);
133
134 /*--- output/output.c -------------------------------------------------------*/
135
136 struct sr_output_format **sr_output_list(void);
137
138 /*--- output/common.c -------------------------------------------------------*/
139
140 char *sr_samplerate_string(uint64_t samplerate);
141 char *sr_period_string(uint64_t frequency);
142 char **sr_parse_triggerstring(struct sr_device *device,
143                               const char *triggerstring);
144 int sr_parse_sizestring(const char *sizestring, uint64_t *size);
145 uint64_t sr_parse_timestring(const char *timestring);
146 gboolean sr_parse_boolstring(const char *boolstring);
147
148 #endif