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