This repository has been archived by the owner on Mar 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
libserialport.vapi
302 lines (280 loc) · 11.3 KB
/
libserialport.vapi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/* libserialport Vala Bindings
* Copyright 2015 Matrix Zhang <[email protected]>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
[CCode (lower_case_cprefix = "", cheader_filename = "libserialport.h")]
namespace LibSerialPort
{
[CCode (cname = "int", cprefix = "SP_", has_type_id = "false")]
public enum Return
{
OK,
ERR_ARG,
ERR_FAIL,
ERR_MEM,
ERR_SUPP
}
[CCode (cname = "int", cprefix = "SP_BUF_", has_type_id = "false")]
public enum Buffer
{
INPUT,
OUTPUT,
BOTH
}
[CCode (cname = "int", cprefix = "SP_PARITY_", has_type_id = "false")]
public enum Parity
{
INVALID,
NONE,
ODD,
EVEN,
MARK,
SPACE
}
[CCode (cname = "int", cprefix = "SP_RTS_", has_type_id = "false")]
public enum Rts
{
INVALID,
OFF,
ON,
FLOW_CONTROL
}
[CCode (cname = "int", cprefix = "SP_CTS_", has_type_id = "false")]
public enum Cts
{
INVALID,
IGNORE,
FLOW_CONTROL
}
[CCode (cname = "int", cprefix = "SP_DTR_", has_type_id = "false")]
public enum Dtr
{
INVALID,
OFF,
ON,
FLOW_CONTROL
}
[CCode (cname = "int", cprefix = "SP_DSR_", has_type_id = "false")]
public enum Dsr
{
INVALID,
IGNORE,
FLOW_CONTROL
}
[CCode (cname = "int", cprefix = "SP_XONXOFF_", has_type_id = "false")]
public enum XonXoff
{
INVALID,
DISABLED,
IN,
OUT,
INOUT
}
[CCode (cname = "int", cprefix = "SP_FLOWCONTROL_", has_type_id = "false")]
public enum FlowControl
{
NONE,
XONXOFF,
RTSCTS,
DTRDSR
}
[CCode (cname = "int", cprefix = "SP_MODE_", has_type_id = "false")]
public enum OpenMode
{
READ,
WRITE,
READ_WRITE
}
[CCode (cname = "int", cprefix = "SP_EVENT_", has_type_id = "false")]
public enum EventMask
{
RX_READY,
TX_READY,
ERROR
}
[CCode (cname = "enum sp_signal", cprefix = "SP_SIG_", has_type_id = "false")]
public enum Signal
{
CTS,
DSR,
DCD,
RI
}
[CCode (cname = "enum sp_transport", cprefix = "SP_TRANSPORT_", has_type_id = "false")]
public enum Transport
{
NATIVE,
USB,
BLUETOOTH
}
[CCode (cname = "struct sp_port_config", free_function = "sp_free_config", has_type_id = "false")]
[Compact]
public class Config
{
[CCode (cname = "sp_new_config", has_type_id = "false")]
public static Return @new(out Config? config);
[CCode (cname = "sp_get_config_baudrate", has_type_id = "false")]
public Return get_baudrate(out int baudrate);
[CCode (cname = "sp_set_config_baudrate", has_type_id = "false")]
public Return set_baudrate(int baudrate);
[CCode (cname = "sp_get_config_bits", has_type_id = "false")]
public Return get_bits(out int bits);
[CCode (cname = "sp_set_config_bits", has_type_id = "false")]
public Return set_bits(int bits);
[CCode (cname = "sp_get_config_stopbits", has_type_id = "false")]
public Return get_stopbits(out int stopbits);
[CCode (cname = "sp_set_config_stopbits", has_type_id = "false")]
public Return set_stopbits(int stopbits);
[CCode (cname = "sp_get_config_parity", has_type_id = "false")]
public Return get_parity(out Parity parity);
[CCode (cname = "sp_set_config_parity", has_type_id = "false")]
public Return set_parity(Parity parity);
[CCode (cname = "sp_get_config_rts", has_type_id = "false")]
public Return get_rts(out Rts rts);
[CCode (cname = "sp_set_config_rts", has_type_id = "false")]
public Return set_rts(Rts rts);
[CCode (cname = "sp_get_config_cts", has_type_id = "false")]
public Return get_cts(out Cts cts);
[CCode (cname = "sp_set_config_cts", has_type_id = "false")]
public Return set_cts(Cts cts);
[CCode (cname = "sp_get_config_dtr", has_type_id = "false")]
public Return get_dtr(out Dtr dtr);
[CCode (cname = "sp_set_config_dtr", has_type_id = "false")]
public Return set_dtr(Dtr dtr);
[CCode (cname = "sp_get_config_dsr", has_type_id = "false")]
public Return get_dsr(out Dsr dsr);
[CCode (cname = "sp_set_config_dsr", has_type_id = "false")]
public Return set_dsr(Dsr xonxoff);
[CCode (cname = "sp_get_config_xon_xoff", has_type_id = "false")]
public Return get_xonxoff(out XonXoff xonxoff);
[CCode (cname = "sp_set_config_xon_xoff", has_type_id = "false")]
public Return set_xonxoff(XonXoff xonxoff);
[CCode (cname = "sp_set_config_flowcontrol", has_type_id = "false")]
public Return set_flowcontrol(FlowControl flowcontrol);
}
[CCode (cname = "struct sp_event_set", free_function = "sp_free_event_set", has_type_id = "false")]
[Compact]
public class EventSet
{
[CCode (cname = "sp_new_event_set", has_type_id = "false")]
public static Return @new(out EventSet? event_set);
[CCode (cname = "sp_add_port_events", has_type_id = "false")]
public Return add_port(Port port, EventMask mask);
[CCode (cname = "sp_wait", has_type_id = "false")]
public Return wait(uint timeout = 0);
}
[CCode (cname = "struct sp_port", free_function = "sp_free_port", has_type_id = "false")]
[Compact]
public class Port
{
[CCode (cname = "sp_get_port_by_name", has_type_id = "false")]
public static Return new_by_name(string name, out Port? port);
[CCode (cname = "sp_list_ports", has_type_id = "false")]
public static int _enum ([CCode (array_length = false)] out Port[] a);
public static Port[]? @enum ()
{
Port[] temp;
var res = _enum (out temp);
if(null != temp)
{
int i = 0;
while(temp[i] != null)
{
i++;
}
temp.length = i;
return (owned) temp;
}
return null;
}
[CCode (cname = "sp_open", has_type_id = "false")]
public Return open(OpenMode mode);
[CCode (cname = "sp_close", has_type_id = "false")]
public Return close();
[CCode (cname = "sp_get_port_name", has_type_id = "false")]
public unowned string name();
[CCode (cname = "sp_get_port_description", has_type_id = "false")]
public unowned string get_description();
[CCode (cname = "sp_get_port_transport", has_type_id = "false")]
public Transport get_transport();
[CCode (cname = "sp_get_port_usb_bus_address", has_type_id = "false")]
public Return get_usb_bus_address(out int usb_bus, out int usb_address);
[CCode (cname = "sp_get_port_usb_vid_pid", has_type_id = "false")]
public Return get_usb_vid_pid(out int usb_vid, out int usb_pid);
[CCode (cname = "sp_get_port_usb_manufacturer", has_type_id = "false")]
public unowned string get_usb_manufacturer();
[CCode (cname = "sp_get_port_usb_product", has_type_id = "false")]
public unowned string get_usb_product();
[CCode (cname = "sp_get_port_usb_serial", has_type_id = "false")]
public unowned string get_usb_serial();
[CCode (cname = "sp_get_port_bluetooth_address", has_type_id = "false")]
public unowned string get_bluetooth_address();
[CCode (cname = "sp_get_port_handle", has_type_id = "false")]
public Return get_fd(out int fd);
[CCode (cname = "sp_get_config", has_type_id = "false")]
public Return get_config(Config config);
[CCode (cname = "sp_set_config", has_type_id = "false")]
public Return set_config(Config config);
[CCode (cname = "sp_set_baudrate", has_type_id = "false")]
public Return set_baudrate(int baudrate);
[CCode (cname = "sp_set_bits", has_type_id = "false")]
public Return set_bits(int bits);
[CCode (cname = "sp_set_parity", has_type_id = "false")]
public Return set_parity(Parity parity);
[CCode (cname = "sp_set_stopbits", has_type_id = "false")]
public Return set_stopbits(int stopbits);
[CCode (cname = "sp_set_rts", has_type_id = "false")]
public Return set_rts(Rts rts);
[CCode (cname = "sp_set_cts", has_type_id = "false")]
public Return set_cts(Cts cts);
[CCode (cname = "sp_set_dtr", has_type_id = "false")]
public Return set_dtr(Dtr dtr);
[CCode (cname = "sp_set_dsr", has_type_id = "false")]
public Return set_dsr(Dsr dsr);
[CCode (cname = "sp_set_xon_xoff", has_type_id = "false")]
public Return set_xon_xoff(XonXoff xon_xoff);
[CCode (cname = "sp_set_flowcontrol", has_type_id = "false")]
public Return set_flowcontrol(FlowControl flowControl);
[CCode (cname = "sp_blocking_read", has_type_id = "false")]
public Return blocking_read(uint8[] buffer, uint timeout);
[CCode (cname = "sp_nonblocking_read", has_type_id = "false")]
public Return nonblocking_read(uint8[] buffer);
[CCode (cname = "sp_blocking_write", has_type_id = "false")]
public Return blocking_write(uint8[] buffer, uint timeout);
[CCode (cname = "sp_nonblocking_write", has_type_id = "false")]
public Return nonblocking_write(uint8[] buffer);
[CCode (cname = "sp_input_waiting", has_type_id = "false")]
public Return input_waiting();
[CCode (cname = "sp_output_waiting", has_type_id = "false")]
public Return output_waiting();
[CCode (cname = "sp_get_signals", has_type_id = "false")]
public Return get_signal(out Signal signals);
[CCode (cname = "sp_flush", has_type_id = "false")]
public Return flush(Buffer buffer);
[CCode (cname = "sp_drain", has_type_id = "false")]
public Return drain();
[CCode (cname = "sp_start_break", has_type_id = "false")]
public Return start_break();
[CCode (cname = "sp_end_break", has_type_id = "false")]
public Return end_break();
}
}