]> sigrok.org Git - libserialport.git/blame - libserialport.h.in
doc: Provided channel is binary, not necessarily 8-bit.
[libserialport.git] / libserialport.h.in
CommitLineData
74510d4b
ML
1/*
2 * This file is part of the libserialport project.
3 *
4 * Copyright (C) 2013 Martin Ling <martin-libserialport@earth.li>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (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 Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
cd5f5281 20/**
cf9d365c
UH
21 * @mainpage libserialport API
22 *
23 * Introduction
24 * ============
25 *
26 * libserialport is a minimal library written in C that is intended to take
27 * care of the OS-specific details when writing software that uses serial ports.
28 *
29 * By writing your serial code to use libserialport, you enable it to work
30 * transparently on any platform supported by the library.
31 *
deef6e52 32 * libserialport is an open source project released under the LGPL3+ license.
cf9d365c 33 *
deef6e52
ML
34 * The library is maintained by the [sigrok](http://sigrok.org/) project. See
35 * the [libserialport homepage](http://sigrok.org/wiki/Libserialport) for the
36 * latest information.
cf9d365c 37 *
deef6e52
ML
38 * Source code is maintained in git at
39 * [git://sigrok.org/libserialport](http://sigrok.org/gitweb/?p=libserialport.git).
40 *
41 * Bugs are tracked at http://sigrok.org/bugzilla/.
42 *
43 * The library was conceived and designed by Martin Ling, is maintained by
44 * Uwe Hermann, and has received contributions from several other developers.
45 * See the git history for full credits.
46 *
47 * API information
48 * ===============
49 *
50 * The API has been designed from scratch. It does not exactly resemble the
51 * serial API of any particular operating system. Instead it aims to provide
52 * a set of functions that can reliably be implemented across all operating
53 * systems. These form a sufficient basis for higher level behaviour to
54 * be implemented in a platform independent manner.
55 *
56 * If you are porting code written for a particular OS, you may find you need
57 * to restructure things somewhat, or do without some specialised features.
58 * For particular notes on porting existing code, see @ref Porting.
59 *
60 * The following subsections will help explain the principles of the API.
49fd7b1b
ML
61 *
62 * Headers
63 * -------
64 *
65 * To use libserialport functions in your code, you should include the
66 * libserialport.h header, i.e. "#include <libserialport.h>".
67 *
68 * Namespace
69 * ---------
70 *
71 * All identifiers defined by the public libserialport headers use the prefix
72 * sp_ (for functions and data types) or SP_ (for macros and constants).
73 *
74 * Functions
75 * ---------
76 *
77 * The functions provided by the library are documented in detail in
78 * the following sections:
79 *
80 * - @ref Enumeration (obtaining a list of serial ports on the system)
81 * - @ref Ports (opening, closing and getting information about ports)
82 * - @ref Configuration (baud rate, parity, etc.)
83 * - @ref Signals (modem control lines, breaks, etc.)
84 * - @ref Data (reading and writing data, and buffer management)
85 * - @ref Waiting (waiting for ports to be ready, integrating with event loops)
86 * - @ref Errors (getting error and debugging information)
deef6e52
ML
87 *
88 * Data structures
89 * ---------------
90 *
91 * The library defines three data structures:
cf9d365c 92 *
deef6e52
ML
93 * - @ref sp_port, which represents a serial port.
94 * See @ref Enumeration.
95 * - @ref sp_port_config, which represents a port configuration.
96 * See @ref Configuration.
97 * - @ref sp_event_set, which represents a set of events.
98 * See @ref Waiting.
cf9d365c 99 *
deef6e52
ML
100 * All these structures are allocated and freed by library functions. It is
101 * the caller's responsibility to ensure that the correct calls are made to
102 * free allocated structures after use.
cf9d365c 103 *
deef6e52
ML
104 * Return codes and error handling
105 * -------------------------------
cf9d365c 106 *
0151b157
ML
107 * Most functions have return type @ref sp_return and can return only four
108 * possible error values:
cf9d365c 109 *
6aabf62a
ML
110 * - @ref SP_ERR_ARG means that a function was called with invalid
111 * arguments. This implies a bug in the caller. The arguments passed would
112 * be invalid regardless of the underlying OS or serial device involved.
113 *
114 * - @ref SP_ERR_FAIL means that the OS reported a failure. The error code or
115 * message provided by the OS can be obtained by calling sp_last_error_code()
116 * or sp_last_error_message().
117 *
118 * - @ref SP_ERR_SUPP indicates that there is no support for the requested
119 * operation in the current OS, driver or device. No error message is
120 * available from the OS in this case. There is either no way to request
121 * the operation in the first place, or libserialport does not know how to
122 * do so in the current version.
123 *
124 * - @ref SP_ERR_MEM indicates that a memory allocation failed.
125 *
126 * All of these error values are negative.
cf9d365c 127 *
0151b157
ML
128 * Calls that succeed return @ref SP_OK, which is equal to zero. Some functions
129 * declared @ref sp_return can also return a positive value for a successful
0a1ab8bf 130 * numeric result, e.g. sp_blocking_read() or sp_blocking_write().
deef6e52
ML
131 *
132 * An error message is only available via sp_last_error_message() in the case
133 * where SP_ERR_FAIL was returned by the previous function call. The error
134 * message returned is that provided by the OS, using the current language
135 * settings. It is an error to call sp_last_error_code() or
136 * sp_last_error_message() except after a previous function call returned
137 * SP_ERR_FAIL. The library does not define its own error codes or messages
138 * to accompany other return codes.
139 *
140 * Thread safety
141 * -------------
142 *
143 * Certain combinations of calls can be made concurrently, as follows.
144 *
145 * - Calls using different ports may always be made concurrently, i.e.
146 * it is safe for separate threads to handle their own ports.
147 *
148 * - Calls using the same port may be made concurrently when one call
149 * is a read operation and one call is a write operation, i.e. it is safe
150 * to use separate "reader" and "writer" threads for the same port. See
151 * below for which operations meet these definitions.
152 *
153 * Read operations:
154 *
155 * - sp_blocking_read()
156 * - sp_blocking_read_next()
157 * - sp_nonblocking_read()
158 * - sp_input_waiting()
159 * - sp_flush() with @ref SP_BUF_INPUT only.
160 * - sp_wait() with @ref SP_EVENT_RX_READY only.
161 *
162 * Write operations:
163 *
164 * - sp_blocking_write()
165 * - sp_nonblocking_write()
166 * - sp_output_waiting()
167 * - sp_drain()
168 * - sp_flush() with @ref SP_BUF_OUTPUT only.
169 * - sp_wait() with @ref SP_EVENT_TX_READY only.
170 *
171 * If two calls, on the same port, do not fit into one of these categories
172 * each, then they may not be made concurrently.
173 *
174 * Debugging
175 * ---------
176 *
177 * The library can output extensive tracing and debugging information. The
178 * simplest way to use this is to set the environment variable
179 * LIBSERIALPORT_DEBUG to any value; messages will then be output to the
180 * standard error stream.
181 *
182 * This behaviour is implemented by a default debug message handling
183 * callback. An alternative callback can be set using sp_set_debug_handler(),
184 * in order to e.g. redirect the output elsewhere or filter it.
185 *
186 * No guarantees are made about the content of the debug output; it is chosen
187 * to suit the needs of the developers and may change between releases.
188 *
189 * @anchor Porting
190 * Porting
191 * -------
192 *
193 * The following guidelines may help when porting existing OS-specific code
194 * to use libserialport.
195 *
196 * ### Porting from Unix-like systems ###
197 *
198 * There are two main differences to note when porting code written for Unix.
199 *
200 * The first is that Unix traditionally provides a wide range of functionality
201 * for dealing with serial devices at the OS level; this is exposed through the
202 * termios API and dates to the days when serial terminals were common. If your
203 * code relies on many of these facilities you will need to adapt it, because
56fe6e32 204 * libserialport provides only a raw binary channel with no special handling.
deef6e52
ML
205 *
206 * The second relates to blocking versus non-blocking I/O behaviour. In
207 * Unix-like systems this is normally specified by setting the O_NONBLOCK
208 * flag on the file descriptor, affecting the semantics of subsequent read()
209 * and write() calls.
210 *
211 * In libserialport, blocking and nonblocking operations are both available at
212 * any time. If your existing code Ń•ets O_NONBLOCK, you should use
213 * sp_nonblocking_read() and sp_nonblocking_write() to get the same behaviour
214 * as your existing read() and write() calls. If it does not, you should use
215 * sp_blocking_read() and sp_blocking_write() instead. You may also find
216 * sp_blocking_read_next() useful, which reproduces the semantics of a blocking
217 * read() with VTIME = 0 and VMIN = 1 set in termios.
218 *
219 * Finally, you should take care if your program uses custom signal handlers.
220 * The blocking calls provided by libserialport will restart system calls that
221 * return with EINTR, so you will need to make your own arrangements if you
222 * need to interrupt blocking operations when your signal handlers are called.
223 * This is not an issue if you only use the default handlers.
224 *
225 * ### Porting from Windows ###
226 *
227 * The main consideration when porting from Windows is that there is no
228 * direct equivalent for overlapped I/O operations.
229 *
230 * If your program does not use overlapped I/O, you can simply use
231 * sp_blocking_read() and sp_blocking_write() as direct equivalents for
232 * ReadFile() and WriteFile(). You may also find sp_blocking_read_next()
233 * useful, which reproduces the special semantics of ReadFile() with
234 * ReadIntervalTimeout and ReadTotalTimeoutMultiplier set to MAXDWORD
235 * and 0 < ReadTotalTimeoutConstant < MAXDWORD.
236 *
237 * If your program makes use of overlapped I/O to continue work while a serial
238 * operation is in progress, then you can achieve the same results using
239 * sp_nonblocking_read() and sp_nonblocking_write().
240 *
241 * Generally, overlapped I/O is combined with either waiting for completion
242 * once there is no more background work to do (using WaitForSingleObject() or
243 * WaitForMultipleObjects()), or periodically checking for completion with
244 * GetOverlappedResult(). If the aim is to start a new operation for further
245 * data once the previous one has completed, you can instead simply call the
246 * nonblocking functions again with the next data. If you need to wait for
247 * completion, use sp_wait() to determine when the port is ready to send or
248 * receive further data.
cf9d365c 249 */
cd5f5281 250
8645feda
UH
251#ifndef LIBSERIALPORT_LIBSERIALPORT_H
252#define LIBSERIALPORT_LIBSERIALPORT_H
e8ffaee9 253
5ef8a1ed
UH
254#ifdef __cplusplus
255extern "C" {
256#endif
257
74510d4b 258#include <stddef.h>
74510d4b 259
cd5f5281 260/** Return values. */
eb6ed20f 261enum sp_return {
cd5f5281 262 /** Operation completed successfully. */
74510d4b 263 SP_OK = 0,
cd5f5281 264 /** Invalid arguments were passed to the function. */
e9a2f9c9 265 SP_ERR_ARG = -1,
cfa5af67 266 /** A system error occurred while executing the operation. */
e9a2f9c9 267 SP_ERR_FAIL = -2,
cd5f5281 268 /** A memory allocation failed while executing the operation. */
f92f1f0c 269 SP_ERR_MEM = -3,
6aabf62a 270 /** The requested operation is not supported by this system or device. */
79a80046 271 SP_ERR_SUPP = -4
74510d4b
ML
272};
273
cd5f5281 274/** Port access modes. */
eb6ed20f 275enum sp_mode {
a036341b
ML
276 /** Open port for read access. */
277 SP_MODE_READ = 1,
278 /** Open port for write access. */
276ef1b9 279 SP_MODE_WRITE = 2,
13efecf8 280 /** Open port for read and write access. @since 0.1.1 */
276ef1b9 281 SP_MODE_READ_WRITE = 3
74510d4b
ML
282};
283
6f1186aa
ML
284/** Port events. */
285enum sp_event {
144a598f 286 /** Data received and ready to read. */
6f1186aa 287 SP_EVENT_RX_READY = 1,
144a598f 288 /** Ready to transmit new data. */
6f1186aa 289 SP_EVENT_TX_READY = 2,
144a598f 290 /** Error occurred. */
79a80046 291 SP_EVENT_ERROR = 4
6f1186aa
ML
292};
293
fd8fd11a
ML
294/** Buffer selection. */
295enum sp_buffer {
296 /** Input buffer. */
297 SP_BUF_INPUT = 1,
298 /** Output buffer. */
299 SP_BUF_OUTPUT = 2,
300 /** Both buffers. */
79a80046 301 SP_BUF_BOTH = 3
fd8fd11a
ML
302};
303
cd5f5281 304/** Parity settings. */
eb6ed20f 305enum sp_parity {
c200f5c1 306 /** Special value to indicate setting should be left alone. */
eb6ed20f 307 SP_PARITY_INVALID = -1,
cd5f5281 308 /** No parity. */
74510d4b 309 SP_PARITY_NONE = 0,
cd5f5281 310 /** Odd parity. */
20e63a77
ML
311 SP_PARITY_ODD = 1,
312 /** Even parity. */
313 SP_PARITY_EVEN = 2,
e432ce60
ML
314 /** Mark parity. */
315 SP_PARITY_MARK = 3,
316 /** Space parity. */
79a80046 317 SP_PARITY_SPACE = 4
74510d4b
ML
318};
319
cd5f5281 320/** RTS pin behaviour. */
eb6ed20f 321enum sp_rts {
c200f5c1 322 /** Special value to indicate setting should be left alone. */
eb6ed20f 323 SP_RTS_INVALID = -1,
cd5f5281 324 /** RTS off. */
d514a26f 325 SP_RTS_OFF = 0,
cd5f5281 326 /** RTS on. */
d514a26f 327 SP_RTS_ON = 1,
cd5f5281 328 /** RTS used for flow control. */
79a80046 329 SP_RTS_FLOW_CONTROL = 2
d514a26f
ML
330};
331
cd5f5281 332/** CTS pin behaviour. */
eb6ed20f 333enum sp_cts {
c200f5c1 334 /** Special value to indicate setting should be left alone. */
eb6ed20f 335 SP_CTS_INVALID = -1,
cd5f5281 336 /** CTS ignored. */
d514a26f 337 SP_CTS_IGNORE = 0,
cd5f5281 338 /** CTS used for flow control. */
79a80046 339 SP_CTS_FLOW_CONTROL = 1
d514a26f
ML
340};
341
cd5f5281 342/** DTR pin behaviour. */
eb6ed20f 343enum sp_dtr {
c200f5c1 344 /** Special value to indicate setting should be left alone. */
eb6ed20f 345 SP_DTR_INVALID = -1,
cd5f5281 346 /** DTR off. */
d514a26f 347 SP_DTR_OFF = 0,
cd5f5281 348 /** DTR on. */
d514a26f 349 SP_DTR_ON = 1,
cd5f5281 350 /** DTR used for flow control. */
79a80046 351 SP_DTR_FLOW_CONTROL = 2
d514a26f
ML
352};
353
cd5f5281 354/** DSR pin behaviour. */
eb6ed20f 355enum sp_dsr {
c200f5c1 356 /** Special value to indicate setting should be left alone. */
eb6ed20f 357 SP_DSR_INVALID = -1,
cd5f5281 358 /** DSR ignored. */
d514a26f 359 SP_DSR_IGNORE = 0,
cd5f5281 360 /** DSR used for flow control. */
79a80046 361 SP_DSR_FLOW_CONTROL = 1
d514a26f
ML
362};
363
cd5f5281 364/** XON/XOFF flow control behaviour. */
eb6ed20f 365enum sp_xonxoff {
c200f5c1 366 /** Special value to indicate setting should be left alone. */
eb6ed20f 367 SP_XONXOFF_INVALID = -1,
cd5f5281 368 /** XON/XOFF disabled. */
d514a26f 369 SP_XONXOFF_DISABLED = 0,
cd5f5281 370 /** XON/XOFF enabled for input only. */
d514a26f 371 SP_XONXOFF_IN = 1,
cd5f5281 372 /** XON/XOFF enabled for output only. */
d514a26f 373 SP_XONXOFF_OUT = 2,
cd5f5281 374 /** XON/XOFF enabled for input and output. */
79a80046 375 SP_XONXOFF_INOUT = 3
ac74fdaf
ML
376};
377
cd5f5281 378/** Standard flow control combinations. */
eb6ed20f 379enum sp_flowcontrol {
cd5f5281 380 /** No flow control. */
18fc2dd1 381 SP_FLOWCONTROL_NONE = 0,
cd5f5281 382 /** Software flow control using XON/XOFF characters. */
18fc2dd1 383 SP_FLOWCONTROL_XONXOFF = 1,
cd5f5281 384 /** Hardware flow control using RTS/CTS signals. */
18fc2dd1 385 SP_FLOWCONTROL_RTSCTS = 2,
cd5f5281 386 /** Hardware flow control using DTR/DSR signals. */
79a80046 387 SP_FLOWCONTROL_DTRDSR = 3
18fc2dd1
ML
388};
389
8cf7c697
ML
390/** Input signals. */
391enum sp_signal {
392 /** Clear to send. */
393 SP_SIG_CTS = 1,
394 /** Data set ready. */
395 SP_SIG_DSR = 2,
396 /** Data carrier detect. */
397 SP_SIG_DCD = 4,
398 /** Ring indicator. */
79a80046 399 SP_SIG_RI = 8
8cf7c697
ML
400};
401
13efecf8
UH
402/**
403 * Transport types.
404 *
405 * @since 0.1.1
406 */
a93fb468 407enum sp_transport {
13efecf8 408 /** Native platform serial port. @since 0.1.1 */
a93fb468 409 SP_TRANSPORT_NATIVE,
13efecf8 410 /** USB serial port adapter. @since 0.1.1 */
a93fb468 411 SP_TRANSPORT_USB,
13efecf8 412 /** Bluetooth serial port adapter. @since 0.1.1 */
79a80046 413 SP_TRANSPORT_BLUETOOTH
a93fb468
AJ
414};
415
0a1ab8bf
UH
416/**
417 * @struct sp_port
418 * An opaque structure representing a serial port.
419 */
1c5aae9d 420struct sp_port;
eb6ed20f 421
0a1ab8bf
UH
422/**
423 * @struct sp_port_config
424 * An opaque structure representing the configuration for a serial port.
425 */
9b1502ef 426struct sp_port_config;
eb6ed20f 427
6f1186aa
ML
428/**
429 * @struct sp_event_set
430 * A set of handles to wait on for events.
431 */
432struct sp_event_set {
433 /** Array of OS-specific handles. */
434 void *handles;
435 /** Array of bitmasks indicating which events apply for each handle. */
436 enum sp_event *masks;
437 /** Number of handles. */
438 unsigned int count;
439};
440
091e75fe 441/**
144a598f
UH
442 * @defgroup Enumeration Port enumeration
443 *
444 * Enumerating the serial ports of a system.
445 *
446 * @{
447 */
091e75fe 448
cd5f5281 449/**
cf9d365c
UH
450 * Obtain a pointer to a new sp_port structure representing the named port.
451 *
452 * The user should allocate a variable of type "struct sp_port *" and pass a
453 * pointer to this to receive the result.
454 *
455 * The result should be freed after use by calling sp_free_port().
456 *
35578b06
UH
457 * @param[in] portname The OS-specific name of a serial port. Must not be NULL.
458 * @param[out] port_ptr If any error is returned, the variable pointed to by
459 * port_ptr will be set to NULL. Otherwise, it will be set
460 * to point to the newly allocated port. Must not be NULL.
f36c6395
ML
461 *
462 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
463 *
464 * @since 0.1.0
cf9d365c 465 */
eb6ed20f 466enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr);
cd5f5281
ML
467
468/**
cf9d365c 469 * Free a port structure obtained from sp_get_port_by_name() or sp_copy_port().
1652aa86 470 *
35578b06
UH
471 * @param[in] port Pointer to a port structure. Must not be NULL.
472 *
1652aa86 473 * @since 0.1.0
cf9d365c 474 */
e3b2f7a4 475void sp_free_port(struct sp_port *port);
cd5f5281
ML
476
477/**
cf9d365c
UH
478 * List the serial ports available on the system.
479 *
480 * The result obtained is an array of pointers to sp_port structures,
481 * terminated by a NULL. The user should allocate a variable of type
482 * "struct sp_port **" and pass a pointer to this to receive the result.
483 *
484 * The result should be freed after use by calling sp_free_port_list().
485 * If a port from the list is to be used after freeing the list, it must be
486 * copied first using sp_copy_port().
487 *
35578b06
UH
488 * @param[out] list_ptr If any error is returned, the variable pointed to by
489 * list_ptr will be set to NULL. Otherwise, it will be set
490 * to point to the newly allocated array. Must not be NULL.
f36c6395
ML
491 *
492 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
493 *
494 * @since 0.1.0
cf9d365c 495 */
eb6ed20f 496enum sp_return sp_list_ports(struct sp_port ***list_ptr);
cd5f5281
ML
497
498/**
35578b06 499 * Make a new copy of an sp_port structure.
cf9d365c
UH
500 *
501 * The user should allocate a variable of type "struct sp_port *" and pass a
502 * pointer to this to receive the result.
503 *
504 * The copy should be freed after use by calling sp_free_port().
505 *
35578b06
UH
506 * @param[in] port Pointer to a port structure. Must not be NULL.
507 * @param[out] copy_ptr If any error is returned, the variable pointed to by
508 * copy_ptr will be set to NULL. Otherwise, it will be set
509 * to point to the newly allocated copy. Must not be NULL.
f36c6395
ML
510 *
511 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
512 *
513 * @since 0.1.0
cf9d365c 514 */
eb6ed20f 515enum sp_return sp_copy_port(const struct sp_port *port, struct sp_port **copy_ptr);
cd5f5281
ML
516
517/**
cf9d365c
UH
518 * Free a port list obtained from sp_list_ports().
519 *
520 * This will also free all the sp_port structures referred to from the list;
521 * any that are to be retained must be copied first using sp_copy_port().
1652aa86 522 *
35578b06
UH
523 * @param[in] ports Pointer to a list of port structures. Must not be NULL.
524 *
1652aa86 525 * @since 0.1.0
cf9d365c 526 */
d54e9004 527void sp_free_port_list(struct sp_port **ports);
e96d8bd2 528
091e75fe 529/**
cf9d365c 530 * @}
144a598f
UH
531 * @defgroup Ports Port handling
532 *
533 * Opening, closing and querying ports.
534 *
cf9d365c
UH
535 * @{
536 */
091e75fe 537
cd5f5281 538/**
cf9d365c
UH
539 * Open the specified serial port.
540 *
35578b06
UH
541 * @param[in] port Pointer to a port structure. Must not be NULL.
542 * @param[in] flags Flags to use when opening the serial port.
cf9d365c 543 *
f36c6395 544 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
545 *
546 * @since 0.1.0
cf9d365c 547 */
eb6ed20f 548enum sp_return sp_open(struct sp_port *port, enum sp_mode flags);
cd5f5281
ML
549
550/**
cf9d365c
UH
551 * Close the specified serial port.
552 *
35578b06
UH
553 * @param[in] port Pointer to a port structure. Must not be NULL.
554 *
f36c6395 555 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
556 *
557 * @since 0.1.0
cf9d365c 558 */
eb6ed20f 559enum sp_return sp_close(struct sp_port *port);
e96d8bd2 560
0151b157
ML
561/**
562 * Get the name of a port.
563 *
564 * The name returned is whatever is normally used to refer to a port on the
565 * current operating system; e.g. for Windows it will usually be a "COMn"
566 * device name, and for Unix it will be a device path beginning with "/dev/".
567 *
35578b06 568 * @param[in] port Pointer to a port structure. Must not be NULL.
0151b157
ML
569 *
570 * @return The port name, or NULL if an invalid port is passed. The name
35578b06
UH
571 * string is part of the port structure and may not be used after
572 * the port structure has been freed.
1652aa86
UH
573 *
574 * @since 0.1.0
0151b157
ML
575 */
576char *sp_get_port_name(const struct sp_port *port);
577
a93fb468
AJ
578/**
579 * Get a description for a port, to present to end user.
580 *
35578b06 581 * @param[in] port Pointer to a port structure. Must not be NULL.
a93fb468
AJ
582 *
583 * @return The port description, or NULL if an invalid port is passed.
35578b06
UH
584 * The description string is part of the port structure and may not
585 * be used after the port structure has been freed.
a93fb468 586 *
3f2f48fc 587 * @since 0.1.1
a93fb468 588 */
f1480939 589char *sp_get_port_description(const struct sp_port *port);
a93fb468
AJ
590
591/**
592 * Get the transport type used by a port.
593 *
35578b06 594 * @param[in] port Pointer to a port structure. Must not be NULL.
a93fb468
AJ
595 *
596 * @return The port transport type.
597 *
3f2f48fc 598 * @since 0.1.1
a93fb468 599 */
ad036cc8 600enum sp_transport sp_get_port_transport(const struct sp_port *port);
a93fb468
AJ
601
602/**
603 * Get the USB bus number and address on bus of a USB serial adapter port.
604 *
35578b06 605 * @param[in] port Pointer to a port structure. Must not be NULL.
ff6da776
UH
606 * @param[out] usb_bus Pointer to a variable to store the USB bus.
607 * Can be NULL (in that case it will be ignored).
608 * @param[out] usb_address Pointer to a variable to store the USB address.
609 * Can be NULL (in that case it will be ignored).
a93fb468
AJ
610 *
611 * @return SP_OK upon success, a negative error code otherwise.
612 *
3f2f48fc 613 * @since 0.1.1
a93fb468
AJ
614 */
615enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port,
616 int *usb_bus, int *usb_address);
617
618/**
619 * Get the USB Vendor ID and Product ID of a USB serial adapter port.
620 *
35578b06 621 * @param[in] port Pointer to a port structure. Must not be NULL.
9eb9f071
UH
622 * @param[out] usb_vid Pointer to a variable to store the USB VID.
623 * Can be NULL (in that case it will be ignored).
624 * @param[out] usb_pid Pointer to a variable to store the USB PID.
625 * Can be NULL (in that case it will be ignored).
a93fb468
AJ
626 *
627 * @return SP_OK upon success, a negative error code otherwise.
628 *
3f2f48fc 629 * @since 0.1.1
a93fb468
AJ
630 */
631enum sp_return sp_get_port_usb_vid_pid(const struct sp_port *port, int *usb_vid, int *usb_pid);
632
633/**
634 * Get the USB manufacturer string of a USB serial adapter port.
635 *
35578b06 636 * @param[in] port Pointer to a port structure. Must not be NULL.
a93fb468
AJ
637 *
638 * @return The port manufacturer string, or NULL if an invalid port is passed.
35578b06
UH
639 * The manufacturer string is part of the port structure and may not
640 * be used after the port structure has been freed.
a93fb468 641 *
3f2f48fc 642 * @since 0.1.1
a93fb468
AJ
643 */
644char *sp_get_port_usb_manufacturer(const struct sp_port *port);
645
646/**
647 * Get the USB product string of a USB serial adapter port.
648 *
35578b06 649 * @param[in] port Pointer to a port structure. Must not be NULL.
a93fb468
AJ
650 *
651 * @return The port product string, or NULL if an invalid port is passed.
35578b06
UH
652 * The product string is part of the port structure and may not be
653 * used after the port structure has been freed.
a93fb468 654 *
3f2f48fc 655 * @since 0.1.1
a93fb468
AJ
656 */
657char *sp_get_port_usb_product(const struct sp_port *port);
658
659/**
660 * Get the USB serial number string of a USB serial adapter port.
661 *
35578b06 662 * @param[in] port Pointer to a port structure. Must not be NULL.
a93fb468
AJ
663 *
664 * @return The port serial number, or NULL if an invalid port is passed.
35578b06
UH
665 * The serial number string is part of the port structure and may
666 * not be used after the port structure has been freed.
a93fb468 667 *
3f2f48fc 668 * @since 0.1.1
a93fb468
AJ
669 */
670char *sp_get_port_usb_serial(const struct sp_port *port);
671
672/**
e33dcf90 673 * Get the MAC address of a Bluetooth serial adapter port.
a93fb468 674 *
35578b06 675 * @param[in] port Pointer to a port structure. Must not be NULL.
a93fb468 676 *
e33dcf90 677 * @return The port MAC address, or NULL if an invalid port is passed.
35578b06
UH
678 * The MAC address string is part of the port structure and may not
679 * be used after the port structure has been freed.
a93fb468 680 *
3f2f48fc 681 * @since 0.1.1
a93fb468
AJ
682 */
683char *sp_get_port_bluetooth_address(const struct sp_port *port);
684
0151b157
ML
685/**
686 * Get the operating system handle for a port.
687 *
688 * The type of the handle depends on the operating system. On Unix based
689 * systems, the handle is a file descriptor of type "int". On Windows, the
690 * handle is of type "HANDLE". The user should allocate a variable of the
691 * appropriate type and pass a pointer to this to receive the result.
692 *
693 * To obtain a valid handle, the port must first be opened by calling
694 * sp_open() using the same port structure.
695 *
696 * After the port is closed or the port structure freed, the handle may
697 * no longer be valid.
698 *
699 * @warning This feature is provided so that programs may make use of
700 * OS-specific functionality where desired. Doing so obviously
701 * comes at a cost in portability. It also cannot be guaranteed
702 * that direct usage of the OS handle will not conflict with the
703 * library's own usage of the port. Be careful.
704 *
35578b06
UH
705 * @param[in] port Pointer to a port structure. Must not be NULL.
706 * @param[out] result_ptr If any error is returned, the variable pointed to by
ff6da776
UH
707 * result_ptr will have unknown contents and should not
708 * be used. Otherwise, it will be set to point to the
709 * OS handle. Must not be NULL.
35578b06 710 *
0151b157 711 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
712 *
713 * @since 0.1.0
0151b157
ML
714 */
715enum sp_return sp_get_port_handle(const struct sp_port *port, void *result_ptr);
716
cd5f5281 717/**
cf9d365c 718 * @}
144a598f
UH
719 *
720 * @defgroup Configuration Configuration
721 *
722 * Setting and querying serial port parameters.
cf9d365c
UH
723 * @{
724 */
e96d8bd2 725
9b1502ef
ML
726/**
727 * Allocate a port configuration structure.
728 *
480d750c
ML
729 * The user should allocate a variable of type "struct sp_port_config *" and
730 * pass a pointer to this to receive the result. The variable will be updated
731 * to point to the new configuration structure. The structure is opaque and
732 * must be accessed via the functions provided.
9b1502ef
ML
733 *
734 * All parameters in the structure will be initialised to special values which
735 * are ignored by sp_set_config().
736 *
737 * The structure should be freed after use by calling sp_free_config().
738 *
ff6da776
UH
739 * @param[out] config_ptr If any error is returned, the variable pointed to by
740 * config_ptr will be set to NULL. Otherwise, it will
741 * be set to point to the allocated config structure.
35578b06 742 * Must not be NULL.
9b1502ef
ML
743 *
744 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
745 *
746 * @since 0.1.0
9b1502ef
ML
747 */
748enum sp_return sp_new_config(struct sp_port_config **config_ptr);
749
750/**
751 * Free a port configuration structure.
752 *
35578b06 753 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1652aa86
UH
754 *
755 * @since 0.1.0
9b1502ef
ML
756 */
757void sp_free_config(struct sp_port_config *config);
758
cd5f5281 759/**
cf9d365c
UH
760 * Get the current configuration of the specified serial port.
761 *
9b1502ef
ML
762 * The user should allocate a configuration structure using sp_new_config()
763 * and pass this as the config parameter. The configuration structure will
764 * be updated with the port configuration.
cf9d365c 765 *
9b1502ef
ML
766 * Any parameters that are configured with settings not recognised or
767 * supported by libserialport, will be set to special values that are
768 * ignored by sp_set_config().
cf9d365c 769 *
35578b06
UH
770 * @param[in] port Pointer to a port structure. Must not be NULL.
771 * @param[out] config Pointer to a configuration structure that will hold
ff6da776
UH
772 * the result. Upon errors the contents of the config
773 * struct will not be changed. Must not be NULL.
35578b06 774 *
f36c6395 775 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
776 *
777 * @since 0.1.0
cf9d365c 778 */
eb6ed20f 779enum sp_return sp_get_config(struct sp_port *port, struct sp_port_config *config);
cd5f5281
ML
780
781/**
cf9d365c
UH
782 * Set the configuration for the specified serial port.
783 *
9b1502ef
ML
784 * For each parameter in the configuration, there is a special value (usually
785 * -1, but see the documentation for each field). These values will be ignored
786 * and the corresponding setting left unchanged on the port.
cf9d365c 787 *
ff6da776
UH
788 * Upon errors, the configuration of the serial port is unknown since
789 * partial/incomplete config updates may have happened.
790 *
35578b06
UH
791 * @param[in] port Pointer to a port structure. Must not be NULL.
792 * @param[in] config Pointer to a configuration structure. Must not be NULL.
793 *
f36c6395 794 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
795 *
796 * @since 0.1.0
cf9d365c 797 */
eb6ed20f 798enum sp_return sp_set_config(struct sp_port *port, const struct sp_port_config *config);
cd5f5281
ML
799
800/**
cf9d365c
UH
801 * Set the baud rate for the specified serial port.
802 *
35578b06
UH
803 * @param[in] port Pointer to a port structure. Must not be NULL.
804 * @param[in] baudrate Baud rate in bits per second.
cf9d365c 805 *
f36c6395 806 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
807 *
808 * @since 0.1.0
cf9d365c 809 */
eb6ed20f 810enum sp_return sp_set_baudrate(struct sp_port *port, int baudrate);
cd5f5281
ML
811
812/**
9b1502ef
ML
813 * Get the baud rate from a port configuration.
814 *
35578b06
UH
815 * The user should allocate a variable of type int and
816 * pass a pointer to this to receive the result.
9b1502ef 817 *
35578b06
UH
818 * @param[in] config Pointer to a configuration structure. Must not be NULL.
819 * @param[out] baudrate_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
820 *
821 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
822 *
823 * @since 0.1.0
9b1502ef
ML
824 */
825enum sp_return sp_get_config_baudrate(const struct sp_port_config *config, int *baudrate_ptr);
826
827/**
828 * Set the baud rate in a port configuration.
829 *
35578b06
UH
830 * @param[in] config Pointer to a configuration structure. Must not be NULL.
831 * @param[in] baudrate Baud rate in bits per second, or -1 to retain the current setting.
9b1502ef
ML
832 *
833 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
834 *
835 * @since 0.1.0
9b1502ef
ML
836 */
837enum sp_return sp_set_config_baudrate(struct sp_port_config *config, int baudrate);
838
839/**
840 * Set the data bits for the specified serial port.
cf9d365c 841 *
35578b06
UH
842 * @param[in] port Pointer to a port structure. Must not be NULL.
843 * @param[in] bits Number of data bits.
cf9d365c 844 *
f36c6395 845 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
846 *
847 * @since 0.1.0
cf9d365c 848 */
eb6ed20f 849enum sp_return sp_set_bits(struct sp_port *port, int bits);
cd5f5281
ML
850
851/**
9b1502ef
ML
852 * Get the data bits from a port configuration.
853 *
35578b06
UH
854 * The user should allocate a variable of type int and
855 * pass a pointer to this to receive the result.
9b1502ef 856 *
35578b06
UH
857 * @param[in] config Pointer to a configuration structure. Must not be NULL.
858 * @param[out] bits_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
859 *
860 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
861 *
862 * @since 0.1.0
9b1502ef
ML
863 */
864enum sp_return sp_get_config_bits(const struct sp_port_config *config, int *bits_ptr);
865
866/**
867 * Set the data bits in a port configuration.
868 *
35578b06
UH
869 * @param[in] config Pointer to a configuration structure. Must not be NULL.
870 * @param[in] bits Number of data bits, or -1 to retain the current setting.
9b1502ef
ML
871 *
872 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
873 *
874 * @since 0.1.0
9b1502ef
ML
875 */
876enum sp_return sp_set_config_bits(struct sp_port_config *config, int bits);
877
878/**
879 * Set the parity setting for the specified serial port.
cf9d365c 880 *
35578b06
UH
881 * @param[in] port Pointer to a port structure. Must not be NULL.
882 * @param[in] parity Parity setting.
cf9d365c 883 *
f36c6395 884 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
885 *
886 * @since 0.1.0
cf9d365c 887 */
eb6ed20f 888enum sp_return sp_set_parity(struct sp_port *port, enum sp_parity parity);
cd5f5281
ML
889
890/**
9b1502ef
ML
891 * Get the parity setting from a port configuration.
892 *
35578b06
UH
893 * The user should allocate a variable of type enum sp_parity and
894 * pass a pointer to this to receive the result.
9b1502ef 895 *
35578b06
UH
896 * @param[in] config Pointer to a configuration structure. Must not be NULL.
897 * @param[out] parity_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
898 *
899 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
900 *
901 * @since 0.1.0
9b1502ef
ML
902 */
903enum sp_return sp_get_config_parity(const struct sp_port_config *config, enum sp_parity *parity_ptr);
904
905/**
906 * Set the parity setting in a port configuration.
907 *
35578b06
UH
908 * @param[in] config Pointer to a configuration structure. Must not be NULL.
909 * @param[in] parity Parity setting, or -1 to retain the current setting.
9b1502ef
ML
910 *
911 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
912 *
913 * @since 0.1.0
9b1502ef
ML
914 */
915enum sp_return sp_set_config_parity(struct sp_port_config *config, enum sp_parity parity);
916
917/**
918 * Set the stop bits for the specified serial port.
cf9d365c 919 *
35578b06
UH
920 * @param[in] port Pointer to a port structure. Must not be NULL.
921 * @param[in] stopbits Number of stop bits.
cf9d365c 922 *
f36c6395 923 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
924 *
925 * @since 0.1.0
cf9d365c 926 */
eb6ed20f 927enum sp_return sp_set_stopbits(struct sp_port *port, int stopbits);
cd5f5281
ML
928
929/**
9b1502ef 930 * Get the stop bits from a port configuration.
cf9d365c 931 *
35578b06
UH
932 * The user should allocate a variable of type int and
933 * pass a pointer to this to receive the result.
cf9d365c 934 *
35578b06
UH
935 * @param[in] config Pointer to a configuration structure. Must not be NULL.
936 * @param[out] stopbits_ptr Pointer to a variable to store the result. Must not be NULL.
cf9d365c 937 *
f36c6395 938 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
939 *
940 * @since 0.1.0
cf9d365c 941 */
9b1502ef
ML
942enum sp_return sp_get_config_stopbits(const struct sp_port_config *config, int *stopbits_ptr);
943
944/**
945 * Set the stop bits in a port configuration.
946 *
35578b06
UH
947 * @param[in] config Pointer to a configuration structure. Must not be NULL.
948 * @param[in] stopbits Number of stop bits, or -1 to retain the current setting.
9b1502ef
ML
949 *
950 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
951 *
952 * @since 0.1.0
9b1502ef
ML
953 */
954enum sp_return sp_set_config_stopbits(struct sp_port_config *config, int stopbits);
18fc2dd1 955
cd5f5281 956/**
9b1502ef 957 * Set the RTS pin behaviour for the specified serial port.
cf9d365c 958 *
35578b06
UH
959 * @param[in] port Pointer to a port structure. Must not be NULL.
960 * @param[in] rts RTS pin mode.
cf9d365c 961 *
f36c6395 962 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
963 *
964 * @since 0.1.0
cf9d365c 965 */
eb6ed20f 966enum sp_return sp_set_rts(struct sp_port *port, enum sp_rts rts);
cd5f5281
ML
967
968/**
9b1502ef
ML
969 * Get the RTS pin behaviour from a port configuration.
970 *
35578b06
UH
971 * The user should allocate a variable of type enum sp_rts and
972 * pass a pointer to this to receive the result.
9b1502ef 973 *
35578b06
UH
974 * @param[in] config Pointer to a configuration structure. Must not be NULL.
975 * @param[out] rts_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
976 *
977 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
978 *
979 * @since 0.1.0
9b1502ef
ML
980 */
981enum sp_return sp_get_config_rts(const struct sp_port_config *config, enum sp_rts *rts_ptr);
982
983/**
984 * Set the RTS pin behaviour in a port configuration.
985 *
35578b06
UH
986 * @param[in] config Pointer to a configuration structure. Must not be NULL.
987 * @param[in] rts RTS pin mode, or -1 to retain the current setting.
9b1502ef
ML
988 *
989 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
990 *
991 * @since 0.1.0
9b1502ef
ML
992 */
993enum sp_return sp_set_config_rts(struct sp_port_config *config, enum sp_rts rts);
994
995/**
996 * Set the CTS pin behaviour for the specified serial port.
cf9d365c 997 *
35578b06
UH
998 * @param[in] port Pointer to a port structure. Must not be NULL.
999 * @param[in] cts CTS pin mode.
cf9d365c 1000 *
f36c6395 1001 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1002 *
1003 * @since 0.1.0
cf9d365c 1004 */
eb6ed20f 1005enum sp_return sp_set_cts(struct sp_port *port, enum sp_cts cts);
cd5f5281
ML
1006
1007/**
9b1502ef
ML
1008 * Get the CTS pin behaviour from a port configuration.
1009 *
35578b06
UH
1010 * The user should allocate a variable of type enum sp_cts and
1011 * pass a pointer to this to receive the result.
9b1502ef 1012 *
35578b06
UH
1013 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1014 * @param[out] cts_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
1015 *
1016 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1017 *
1018 * @since 0.1.0
9b1502ef
ML
1019 */
1020enum sp_return sp_get_config_cts(const struct sp_port_config *config, enum sp_cts *cts_ptr);
1021
1022/**
1023 * Set the CTS pin behaviour in a port configuration.
1024 *
35578b06
UH
1025 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1026 * @param[in] cts CTS pin mode, or -1 to retain the current setting.
9b1502ef
ML
1027 *
1028 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1029 *
1030 * @since 0.1.0
9b1502ef
ML
1031 */
1032enum sp_return sp_set_config_cts(struct sp_port_config *config, enum sp_cts cts);
1033
1034/**
1035 * Set the DTR pin behaviour for the specified serial port.
cf9d365c 1036 *
35578b06
UH
1037 * @param[in] port Pointer to a port structure. Must not be NULL.
1038 * @param[in] dtr DTR pin mode.
cf9d365c 1039 *
f36c6395 1040 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1041 *
1042 * @since 0.1.0
cf9d365c 1043 */
eb6ed20f 1044enum sp_return sp_set_dtr(struct sp_port *port, enum sp_dtr dtr);
cd5f5281
ML
1045
1046/**
9b1502ef
ML
1047 * Get the DTR pin behaviour from a port configuration.
1048 *
35578b06
UH
1049 * The user should allocate a variable of type enum sp_dtr and
1050 * pass a pointer to this to receive the result.
9b1502ef 1051 *
35578b06
UH
1052 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1053 * @param[out] dtr_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
1054 *
1055 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1056 *
1057 * @since 0.1.0
9b1502ef
ML
1058 */
1059enum sp_return sp_get_config_dtr(const struct sp_port_config *config, enum sp_dtr *dtr_ptr);
1060
1061/**
1062 * Set the DTR pin behaviour in a port configuration.
1063 *
35578b06
UH
1064 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1065 * @param[in] dtr DTR pin mode, or -1 to retain the current setting.
9b1502ef
ML
1066 *
1067 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1068 *
1069 * @since 0.1.0
9b1502ef
ML
1070 */
1071enum sp_return sp_set_config_dtr(struct sp_port_config *config, enum sp_dtr dtr);
1072
1073/**
1074 * Set the DSR pin behaviour for the specified serial port.
cf9d365c 1075 *
35578b06
UH
1076 * @param[in] port Pointer to a port structure. Must not be NULL.
1077 * @param[in] dsr DSR pin mode.
cf9d365c 1078 *
f36c6395 1079 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1080 *
1081 * @since 0.1.0
cf9d365c 1082 */
eb6ed20f 1083enum sp_return sp_set_dsr(struct sp_port *port, enum sp_dsr dsr);
cd5f5281
ML
1084
1085/**
9b1502ef
ML
1086 * Get the DSR pin behaviour from a port configuration.
1087 *
35578b06
UH
1088 * The user should allocate a variable of type enum sp_dsr and
1089 * pass a pointer to this to receive the result.
9b1502ef 1090 *
35578b06
UH
1091 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1092 * @param[out] dsr_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
1093 *
1094 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1095 *
1096 * @since 0.1.0
9b1502ef
ML
1097 */
1098enum sp_return sp_get_config_dsr(const struct sp_port_config *config, enum sp_dsr *dsr_ptr);
1099
1100/**
1101 * Set the DSR pin behaviour in a port configuration.
1102 *
35578b06
UH
1103 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1104 * @param[in] dsr DSR pin mode, or -1 to retain the current setting.
9b1502ef
ML
1105 *
1106 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1107 *
1108 * @since 0.1.0
9b1502ef
ML
1109 */
1110enum sp_return sp_set_config_dsr(struct sp_port_config *config, enum sp_dsr dsr);
1111
1112/**
1113 * Set the XON/XOFF configuration for the specified serial port.
cf9d365c 1114 *
35578b06
UH
1115 * @param[in] port Pointer to a port structure. Must not be NULL.
1116 * @param[in] xon_xoff XON/XOFF mode.
cf9d365c 1117 *
f36c6395 1118 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1119 *
1120 * @since 0.1.0
cf9d365c 1121 */
eb6ed20f 1122enum sp_return sp_set_xon_xoff(struct sp_port *port, enum sp_xonxoff xon_xoff);
e96d8bd2 1123
9b1502ef
ML
1124/**
1125 * Get the XON/XOFF configuration from a port configuration.
1126 *
35578b06
UH
1127 * The user should allocate a variable of type enum sp_xonxoff and
1128 * pass a pointer to this to receive the result.
9b1502ef 1129 *
35578b06
UH
1130 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1131 * @param[out] xon_xoff_ptr Pointer to a variable to store the result. Must not be NULL.
9b1502ef
ML
1132 *
1133 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1134 *
1135 * @since 0.1.0
9b1502ef
ML
1136 */
1137enum sp_return sp_get_config_xon_xoff(const struct sp_port_config *config, enum sp_xonxoff *xon_xoff_ptr);
1138
1139/**
1140 * Set the XON/XOFF configuration in a port configuration.
1141 *
35578b06
UH
1142 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1143 * @param[in] xon_xoff XON/XOFF mode, or -1 to retain the current setting.
9b1502ef
ML
1144 *
1145 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1146 *
1147 * @since 0.1.0
9b1502ef
ML
1148 */
1149enum sp_return sp_set_config_xon_xoff(struct sp_port_config *config, enum sp_xonxoff xon_xoff);
1150
1151/**
1152 * Set the flow control type in a port configuration.
1153 *
1154 * This function is a wrapper that sets the RTS, CTS, DTR, DSR and
1155 * XON/XOFF settings as necessary for the specified flow control
1156 * type. For more fine-grained control of these settings, use their
1157 * individual configuration functions.
1158 *
35578b06
UH
1159 * @param[in] config Pointer to a configuration structure. Must not be NULL.
1160 * @param[in] flowcontrol Flow control setting to use.
9b1502ef
ML
1161 *
1162 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1163 *
1164 * @since 0.1.0
9b1502ef
ML
1165 */
1166enum sp_return sp_set_config_flowcontrol(struct sp_port_config *config, enum sp_flowcontrol flowcontrol);
1167
1168/**
1169 * Set the flow control type for the specified serial port.
1170 *
1171 * This function is a wrapper that sets the RTS, CTS, DTR, DSR and
1172 * XON/XOFF settings as necessary for the specified flow control
1173 * type. For more fine-grained control of these settings, use their
1174 * individual configuration functions.
1175 *
35578b06
UH
1176 * @param[in] port Pointer to a port structure. Must not be NULL.
1177 * @param[in] flowcontrol Flow control setting to use.
9b1502ef
ML
1178 *
1179 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1180 *
1181 * @since 0.1.0
9b1502ef
ML
1182 */
1183enum sp_return sp_set_flowcontrol(struct sp_port *port, enum sp_flowcontrol flowcontrol);
1184
091e75fe 1185/**
cf9d365c 1186 * @}
144a598f
UH
1187 *
1188 * @defgroup Data Data handling
1189 *
1190 * Reading, writing, and flushing data.
1191 *
cf9d365c 1192 * @{
144a598f 1193 */
091e75fe
ML
1194
1195/**
2007ce5e
ML
1196 * Read bytes from the specified serial port, blocking until complete.
1197 *
b87deb7c
ML
1198 * @warning If your program runs on Unix, defines its own signal handlers, and
1199 * needs to abort blocking reads when these are called, then you
1200 * should not use this function. It repeats system calls that return
1201 * with EINTR. To be able to abort a read from a signal handler, you
1202 * should implement your own blocking read using sp_nonblocking_read()
2007ce5e
ML
1203 * together with a blocking method that makes sense for your program.
1204 * E.g. you can obtain the file descriptor for an open port using
1205 * sp_get_port_handle() and use this to call select() or pselect(),
1206 * with appropriate arrangements to return if a signal is received.
cf9d365c 1207 *
35578b06
UH
1208 * @param[in] port Pointer to a port structure. Must not be NULL.
1209 * @param[out] buf Buffer in which to store the bytes read. Must not be NULL.
1210 * @param[in] count Requested number of bytes to read.
1b91c6ea 1211 * @param[in] timeout_ms Timeout in milliseconds, or zero to wait indefinitely.
e3dcf906
ML
1212 *
1213 * @return The number of bytes read on success, or a negative error code. If
1214 * the number of bytes returned is less than that requested, the
1215 * timeout was reached before the requested number of bytes was
1216 * available. If timeout is zero, the function will always return
1217 * either the requested number of bytes or a negative error code.
1652aa86
UH
1218 *
1219 * @since 0.1.0
e3dcf906 1220 */
1b91c6ea 1221enum sp_return sp_blocking_read(struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms);
e3dcf906 1222
e5c2630e
ML
1223/**
1224 * Read bytes from the specified serial port, returning as soon as any data is
1225 * available.
1226 *
1227 * @warning If your program runs on Unix, defines its own signal handlers, and
1228 * needs to abort blocking reads when these are called, then you
1229 * should not use this function. It repeats system calls that return
1230 * with EINTR. To be able to abort a read from a signal handler, you
1231 * should implement your own blocking read using sp_nonblocking_read()
1232 * together with a blocking method that makes sense for your program.
1233 * E.g. you can obtain the file descriptor for an open port using
1234 * sp_get_port_handle() and use this to call select() or pselect(),
1235 * with appropriate arrangements to return if a signal is received.
1236 *
1237 * @param[in] port Pointer to a port structure. Must not be NULL.
1238 * @param[out] buf Buffer in which to store the bytes read. Must not be NULL.
1239 * @param[in] count Maximum number of bytes to read. Must not be zero.
1240 * @param[in] timeout_ms Timeout in milliseconds, or zero to wait indefinitely.
1241 *
1242 * @return The number of bytes read on success, or a negative error code. If
1243 * the result is zero, the timeout was reached before any bytes were
1244 * available. If timeout_ms is zero, the function will always return
1245 * either at least one byte, or a negative error code.
1246 *
1247 * @since 0.1.1
1248 */
1249enum sp_return sp_blocking_read_next(struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms);
1250
e3dcf906
ML
1251/**
1252 * Read bytes from the specified serial port, without blocking.
cf9d365c 1253 *
35578b06
UH
1254 * @param[in] port Pointer to a port structure. Must not be NULL.
1255 * @param[out] buf Buffer in which to store the bytes read. Must not be NULL.
1256 * @param[in] count Maximum number of bytes to read.
cf9d365c 1257 *
e3dcf906
ML
1258 * @return The number of bytes read on success, or a negative error code. The
1259 * number of bytes returned may be any number from zero to the maximum
1260 * that was requested.
1652aa86
UH
1261 *
1262 * @since 0.1.0
e3dcf906
ML
1263 */
1264enum sp_return sp_nonblocking_read(struct sp_port *port, void *buf, size_t count);
1265
1266/**
1267 * Write bytes to the specified serial port, blocking until complete.
1268 *
1269 * Note that this function only ensures that the accepted bytes have been
1270 * written to the OS; they may be held in driver or hardware buffers and not
1271 * yet physically transmitted. To check whether all written bytes have actually
1272 * been transmitted, use the sp_output_waiting() function. To wait until all
1273 * written bytes have actually been transmitted, use the sp_drain() function.
1274 *
b87deb7c
ML
1275 * @warning If your program runs on Unix, defines its own signal handlers, and
1276 * needs to abort blocking writes when these are called, then you
1277 * should not use this function. It repeats system calls that return
1278 * with EINTR. To be able to abort a write from a signal handler, you
1279 * should implement your own blocking write using sp_nonblocking_write()
2007ce5e
ML
1280 * together with a blocking method that makes sense for your program.
1281 * E.g. you can obtain the file descriptor for an open port using
1282 * sp_get_port_handle() and use this to call select() or pselect(),
1283 * with appropriate arrangements to return if a signal is received.
1284 *
35578b06
UH
1285 * @param[in] port Pointer to a port structure. Must not be NULL.
1286 * @param[in] buf Buffer containing the bytes to write. Must not be NULL.
1287 * @param[in] count Requested number of bytes to write.
1b91c6ea 1288 * @param[in] timeout_ms Timeout in milliseconds, or zero to wait indefinitely.
e3dcf906 1289 *
85987464
ML
1290 * @return The number of bytes written on success, or a negative error code.
1291 * If the number of bytes returned is less than that requested, the
e3dcf906 1292 * timeout was reached before the requested number of bytes was
85987464 1293 * written. If timeout is zero, the function will always return
e3dcf906
ML
1294 * either the requested number of bytes or a negative error code. In
1295 * the event of an error there is no way to determine how many bytes
cfa5af67 1296 * were sent before the error occurred.
1652aa86
UH
1297 *
1298 * @since 0.1.0
cf9d365c 1299 */
1b91c6ea 1300enum sp_return sp_blocking_write(struct sp_port *port, const void *buf, size_t count, unsigned int timeout_ms);
091e75fe
ML
1301
1302/**
e3dcf906 1303 * Write bytes to the specified serial port, without blocking.
cf9d365c 1304 *
e3dcf906
ML
1305 * Note that this function only ensures that the accepted bytes have been
1306 * written to the OS; they may be held in driver or hardware buffers and not
1307 * yet physically transmitted. To check whether all written bytes have actually
1308 * been transmitted, use the sp_output_waiting() function. To wait until all
1309 * written bytes have actually been transmitted, use the sp_drain() function.
cf9d365c 1310 *
35578b06
UH
1311 * @param[in] port Pointer to a port structure. Must not be NULL.
1312 * @param[in] buf Buffer containing the bytes to write. Must not be NULL.
1313 * @param[in] count Maximum number of bytes to write.
cf9d365c 1314 *
f36c6395 1315 * @return The number of bytes written on success, or a negative error code.
e3dcf906
ML
1316 * The number of bytes returned may be any number from zero to the
1317 * maximum that was requested.
1652aa86
UH
1318 *
1319 * @since 0.1.0
cf9d365c 1320 */
e3dcf906 1321enum sp_return sp_nonblocking_write(struct sp_port *port, const void *buf, size_t count);
091e75fe 1322
3353c22f
ML
1323/**
1324 * Gets the number of bytes waiting in the input buffer.
1325 *
35578b06 1326 * @param[in] port Pointer to a port structure. Must not be NULL.
3353c22f
ML
1327 *
1328 * @return Number of bytes waiting on success, a negative error code otherwise.
1652aa86
UH
1329 *
1330 * @since 0.1.0
3353c22f
ML
1331 */
1332enum sp_return sp_input_waiting(struct sp_port *port);
1333
1334/**
1335 * Gets the number of bytes waiting in the output buffer.
1336 *
35578b06 1337 * @param[in] port Pointer to a port structure. Must not be NULL.
3353c22f
ML
1338 *
1339 * @return Number of bytes waiting on success, a negative error code otherwise.
1652aa86
UH
1340 *
1341 * @since 0.1.0
3353c22f
ML
1342 */
1343enum sp_return sp_output_waiting(struct sp_port *port);
1344
091e75fe 1345/**
fd8fd11a
ML
1346 * Flush serial port buffers. Data in the selected buffer(s) is discarded.
1347 *
35578b06
UH
1348 * @param[in] port Pointer to a port structure. Must not be NULL.
1349 * @param[in] buffers Which buffer(s) to flush.
cf9d365c 1350 *
f36c6395 1351 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1352 *
1353 * @since 0.1.0
cf9d365c 1354 */
fd8fd11a 1355enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers);
091e75fe 1356
69a3739c
ML
1357/**
1358 * Wait for buffered data to be transmitted.
1359 *
2c827b21
ML
1360 * @warning If your program runs on Unix, defines its own signal handlers, and
1361 * needs to abort draining the output buffer when when these are
1362 * called, then you should not use this function. It repeats system
1363 * calls that return with EINTR. To be able to abort a drain from a
1364 * signal handler, you would need to implement your own blocking
1365 * drain by polling the result of sp_output_waiting().
1366 *
35578b06 1367 * @param[in] port Pointer to a port structure. Must not be NULL.
3f099f4f 1368 *
f36c6395 1369 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1370 *
1371 * @since 0.1.0
69a3739c
ML
1372 */
1373enum sp_return sp_drain(struct sp_port *port);
1374
6f1186aa
ML
1375/**
1376 * @}
144a598f
UH
1377 *
1378 * @defgroup Waiting Waiting
1379 *
1380 * Waiting for events and timeout handling.
1381 *
6f1186aa
ML
1382 * @{
1383 */
1384
1385/**
1386 * Allocate storage for a set of events.
1387 *
1388 * The user should allocate a variable of type struct sp_event_set *,
1389 * then pass a pointer to this variable to receive the result.
1390 *
1391 * The result should be freed after use by calling sp_free_event_set().
1392 *
35578b06
UH
1393 * @param[out] result_ptr If any error is returned, the variable pointed to by
1394 * result_ptr will be set to NULL. Otherwise, it will
1395 * be set to point to the event set. Must not be NULL.
1396 *
6f1186aa 1397 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1398 *
1399 * @since 0.1.0
6f1186aa
ML
1400 */
1401enum sp_return sp_new_event_set(struct sp_event_set **result_ptr);
1402
1403/**
1404 * Add events to a struct sp_event_set for a given port.
1405 *
1406 * The port must first be opened by calling sp_open() using the same port
1407 * structure.
1408 *
1409 * After the port is closed or the port structure freed, the results may
1410 * no longer be valid.
1411 *
35578b06
UH
1412 * @param[in,out] event_set Event set to update. Must not be NULL.
1413 * @param[in] port Pointer to a port structure. Must not be NULL.
1414 * @param[in] mask Bitmask of events to be waited for.
6f1186aa
ML
1415 *
1416 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1417 *
1418 * @since 0.1.0
6f1186aa
ML
1419 */
1420enum sp_return sp_add_port_events(struct sp_event_set *event_set,
1421 const struct sp_port *port, enum sp_event mask);
1422
1423/**
1424 * Wait for any of a set of events to occur.
1425 *
35578b06 1426 * @param[in] event_set Event set to wait on. Must not be NULL.
1b91c6ea 1427 * @param[in] timeout_ms Timeout in milliseconds, or zero to wait indefinitely.
6f1186aa
ML
1428 *
1429 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1430 *
1431 * @since 0.1.0
6f1186aa 1432 */
1b91c6ea 1433enum sp_return sp_wait(struct sp_event_set *event_set, unsigned int timeout_ms);
6f1186aa
ML
1434
1435/**
1436 * Free a structure allocated by sp_new_event_set().
1652aa86 1437 *
35578b06
UH
1438 * @param[in] event_set Event set to free. Must not be NULL.
1439 *
1652aa86 1440 * @since 0.1.0
6f1186aa
ML
1441 */
1442void sp_free_event_set(struct sp_event_set *event_set);
1443
90cc3ee6
ML
1444/**
1445 * @}
144a598f
UH
1446 *
1447 * @defgroup Signals Signals
1448 *
1449 * Port signalling operations.
1450 *
90cc3ee6
ML
1451 * @{
1452 */
1453
8cf7c697
ML
1454/**
1455 * Gets the status of the control signals for the specified port.
1456 *
1457 * The user should allocate a variable of type "enum sp_signal" and pass a
1458 * pointer to this variable to receive the result. The result is a bitmask
1459 * in which individual signals can be checked by bitwise OR with values of
1460 * the sp_signal enum.
1461 *
35578b06
UH
1462 * @param[in] port Pointer to a port structure. Must not be NULL.
1463 * @param[out] signal_mask Pointer to a variable to receive the result.
1464 * Must not be NULL.
8cf7c697 1465 *
f36c6395 1466 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1467 *
1468 * @since 0.1.0
8cf7c697 1469 */
f3ccf157 1470enum sp_return sp_get_signals(struct sp_port *port, enum sp_signal *signal_mask);
8cf7c697 1471
90cc3ee6
ML
1472/**
1473 * Put the port transmit line into the break state.
1474 *
35578b06 1475 * @param[in] port Pointer to a port structure. Must not be NULL.
3f099f4f 1476 *
f36c6395 1477 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1478 *
1479 * @since 0.1.0
90cc3ee6
ML
1480 */
1481enum sp_return sp_start_break(struct sp_port *port);
1482
1483/**
1484 * Take the port transmit line out of the break state.
1485 *
35578b06 1486 * @param[in] port Pointer to a port structure. Must not be NULL.
3f099f4f 1487 *
f36c6395 1488 * @return SP_OK upon success, a negative error code otherwise.
1652aa86
UH
1489 *
1490 * @since 0.1.0
90cc3ee6
ML
1491 */
1492enum sp_return sp_end_break(struct sp_port *port);
1493
091e75fe 1494/**
cf9d365c 1495 * @}
144a598f
UH
1496 *
1497 * @defgroup Errors Errors
1498 *
1499 * Obtaining error information.
1500 *
cf9d365c 1501 * @{
144a598f 1502 */
091e75fe 1503
cd5f5281 1504/**
cf9d365c
UH
1505 * Get the error code for a failed operation.
1506 *
1507 * In order to obtain the correct result, this function should be called
1508 * straight after the failure, before executing any other system operations.
ec4b55ae
ML
1509 * The result is thread-specific, and only valid when called immediately
1510 * after a previous call returning SP_ERR_FAIL.
cf9d365c
UH
1511 *
1512 * @return The system's numeric code for the error that caused the last
1513 * operation to fail.
1652aa86
UH
1514 *
1515 * @since 0.1.0
cf9d365c 1516 */
74510d4b 1517int sp_last_error_code(void);
cd5f5281
ML
1518
1519/**
cf9d365c
UH
1520 * Get the error message for a failed operation.
1521 *
1522 * In order to obtain the correct result, this function should be called
1523 * straight after the failure, before executing other system operations.
ec4b55ae
ML
1524 * The result is thread-specific, and only valid when called immediately
1525 * after a previous call returning SP_ERR_FAIL.
cf9d365c
UH
1526 *
1527 * @return The system's message for the error that caused the last
1528 * operation to fail. This string may be allocated by the function,
1529 * and should be freed after use by calling sp_free_error_message().
1652aa86
UH
1530 *
1531 * @since 0.1.0
cf9d365c 1532 */
74510d4b 1533char *sp_last_error_message(void);
cd5f5281
ML
1534
1535/**
cf9d365c 1536 * Free an error message returned by sp_last_error_message().
1652aa86 1537 *
35578b06
UH
1538 * @param[in] message The error message string to free. Must not be NULL.
1539 *
1652aa86 1540 * @since 0.1.0
cf9d365c 1541 */
74510d4b 1542void sp_free_error_message(char *message);
e8ffaee9 1543
863b35e6
ML
1544/**
1545 * Set the handler function for library debugging messages.
1546 *
1547 * Debugging messages are generated by the library during each operation,
1548 * to help in diagnosing problems. The handler will be called for each
1549 * message. The handler can be set to NULL to ignore all debug messages.
1550 *
1551 * The handler function should accept a format string and variable length
1552 * argument list, in the same manner as e.g. printf().
1553 *
1554 * The default handler is sp_default_debug_handler().
1652aa86 1555 *
35578b06
UH
1556 * @param[in] handler The handler function to use. Can be NULL (in that case
1557 * all debug messages will be ignored).
1558 *
1652aa86 1559 * @since 0.1.0
863b35e6
ML
1560 */
1561void sp_set_debug_handler(void (*handler)(const char *format, ...));
1562
1563/**
1564 * Default handler function for library debugging messages.
1565 *
1566 * This function prints debug messages to the standard error stream if the
1567 * environment variable LIBSERIALPORT_DEBUG is set. Otherwise, they are
1568 * ignored.
1652aa86 1569 *
35578b06
UH
1570 * @param[in] format The format string to use. Must not be NULL.
1571 * @param[in] ... The variable length argument list to use.
1572 *
1652aa86 1573 * @since 0.1.0
863b35e6
ML
1574 */
1575void sp_default_debug_handler(const char *format, ...);
1576
cf9d365c 1577/** @} */
091e75fe 1578
524b0e14 1579/**
144a598f
UH
1580 * @defgroup Versions Versions
1581 *
1582 * Version number querying functions, definitions, and macros.
524b0e14
UH
1583 *
1584 * This set of API calls returns two different version numbers related
1585 * to libserialport. The "package version" is the release version number of the
1586 * libserialport tarball in the usual "major.minor.micro" format, e.g. "0.1.0".
1587 *
1588 * The "library version" is independent of that; it is the libtool version
1589 * number in the "current:revision:age" format, e.g. "2:0:0".
1590 * See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning for details.
1591 *
1592 * Both version numbers (and/or individual components of them) can be
1593 * retrieved via the API calls at runtime, and/or they can be checked at
1594 * compile/preprocessor time using the respective macros.
1595 *
1596 * @{
1597 */
1598
1599/*
1600 * Package version macros (can be used for conditional compilation).
1601 */
1602
1603/** The libserialport package 'major' version number. */
1604#define SP_PACKAGE_VERSION_MAJOR @SP_PACKAGE_VERSION_MAJOR@
1605
1606/** The libserialport package 'minor' version number. */
1607#define SP_PACKAGE_VERSION_MINOR @SP_PACKAGE_VERSION_MINOR@
1608
1609/** The libserialport package 'micro' version number. */
1610#define SP_PACKAGE_VERSION_MICRO @SP_PACKAGE_VERSION_MICRO@
1611
1612/** The libserialport package version ("major.minor.micro") as string. */
1613#define SP_PACKAGE_VERSION_STRING "@SP_PACKAGE_VERSION@"
1614
1615/*
1616 * Library/libtool version macros (can be used for conditional compilation).
1617 */
1618
1619/** The libserialport libtool 'current' version number. */
1620#define SP_LIB_VERSION_CURRENT @SP_LIB_VERSION_CURRENT@
1621
1622/** The libserialport libtool 'revision' version number. */
1623#define SP_LIB_VERSION_REVISION @SP_LIB_VERSION_REVISION@
1624
1625/** The libserialport libtool 'age' version number. */
1626#define SP_LIB_VERSION_AGE @SP_LIB_VERSION_AGE@
1627
1628/** The libserialport libtool version ("current:revision:age") as string. */
1629#define SP_LIB_VERSION_STRING "@SP_LIB_VERSION@"
1630
1631/**
1632 * Get the major libserialport package version number.
1633 *
1634 * @return The major package version number.
1635 *
1636 * @since 0.1.0
1637 */
1638int sp_get_major_package_version(void);
1639
1640/**
1641 * Get the minor libserialport package version number.
1642 *
1643 * @return The minor package version number.
1644 *
1645 * @since 0.1.0
1646 */
1647int sp_get_minor_package_version(void);
1648
1649/**
1650 * Get the micro libserialport package version number.
1651 *
1652 * @return The micro package version number.
1653 *
1654 * @since 0.1.0
1655 */
1656int sp_get_micro_package_version(void);
1657
1658/**
1659 * Get the libserialport package version number as a string.
1660 *
1661 * @return The package version number string. The returned string is
1662 * static and thus should NOT be free'd by the caller.
1663 *
1664 * @since 0.1.0
1665 */
1666const char *sp_get_package_version_string(void);
1667
1668/**
1669 * Get the "current" part of the libserialport library version number.
1670 *
1671 * @return The "current" library version number.
1672 *
1673 * @since 0.1.0
1674 */
1675int sp_get_current_lib_version(void);
1676
1677/**
1678 * Get the "revision" part of the libserialport library version number.
1679 *
1680 * @return The "revision" library version number.
1681 *
1682 * @since 0.1.0
1683 */
1684int sp_get_revision_lib_version(void);
1685
1686/**
1687 * Get the "age" part of the libserialport library version number.
1688 *
1689 * @return The "age" library version number.
1690 *
1691 * @since 0.1.0
1692 */
1693int sp_get_age_lib_version(void);
1694
1695/**
1696 * Get the libserialport library version number as a string.
1697 *
1698 * @return The library version number string. The returned string is
1699 * static and thus should NOT be free'd by the caller.
1700 *
1701 * @since 0.1.0
1702 */
1703const char *sp_get_lib_version_string(void);
1704
1705/** @} */
1706
5ef8a1ed
UH
1707#ifdef __cplusplus
1708}
1709#endif
1710
8645feda 1711#endif