1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00
Commit Graph

171 Commits

Author SHA1 Message Date
Aurelien Jacobs
073c86bd07 Simplify Mac OS implementation of sp_list_ports(). 2014-06-10 22:17:07 +02:00
Aurelien Jacobs
f095f84164 Remove useless declaration. 2014-06-10 22:17:07 +02:00
Aurelien Jacobs
da2ede60e4 Remove duplicated include. 2014-06-10 22:16:46 +02:00
Aurelien Jacobs
8edf649caf Add format string support to RETURN_ERROR() and RETURN_FAIL(). 2014-06-02 12:08:54 +02:00
Martin Ling
6c4b27a8b8 Merge pull request #1 from silverbuddy/master
Win32 issues
2014-03-22 07:14:49 +00:00
silverbuddy
e48f0ece0f Fix malloc size (Win32) 2014-03-21 21:49:22 +04:00
silverbuddy
904ac164bf Fix compilation (Win32 UNICODE) 2014-03-21 21:43:19 +04:00
Uwe Hermann
524b0e1454 Add runtime version querying functions.
This fixes bug #282.
2014-03-13 12:23:56 +01:00
Martin Ling
5cea279a85 linux: Speed fields may not be present in kernel termios structures. 2014-01-03 13:38:06 +01:00
Martin Ling
bd791fe121 Remove need to include linux_termios.h on non-Linux. 2014-01-03 12:16:41 +01:00
Martin Ling
6f1186aa82 Add API for waiting on port events. 2013-12-20 18:24:42 +00:00
Uwe Hermann
1a2a1544d7 win32: Add missing ClearCommError() error handling/reporting. 2013-12-17 22:39:15 +01:00
Martin Ling
537942c9ed Windows: clear errors after port open. 2013-12-17 17:19:55 +00:00
Martin Ling
950faaa94a Remove obsolete comment. 2013-12-08 14:41:53 +00:00
Martin Ling
9af8cff38f Remove stray periods from debug messages. 2013-12-07 20:18:27 +00:00
Martin Ling
64d996216e Windows nonblocking write: Dont't return if async I/O finishes immediately. 2013-12-07 20:16:38 +00:00
Martin Ling
1622ef60b0 Check return value of GetOverlappedResult(). 2013-12-07 17:09:06 +00:00
Martin Ling
7c1eff54fd Make RETURN_VALUE macro side effect safe. 2013-12-07 16:29:18 +00:00
Martin Ling
33fd8804b8 Fix building for Android. 2013-12-05 20:33:06 +00:00
Martin Ling
397d89de3a Make libudev optional. 2013-12-05 20:21:39 +00:00
Uwe Hermann
6c8716e9da TIOCINQ/TIOCOUTQ is not available everywhere.
E.g. on NetBSD TIOCINQ is not available, but FIONREAD seems to
do pretty much the same thing.
2013-12-01 18:04:24 +01:00
Martin Ling
2c827b2188 Handle EINTR from tcdrain() in sp_drain(). 2013-11-27 14:35:36 +00:00
Martin Ling
63a17c64ae Handle EINTR by repeating the call. 2013-11-27 12:43:12 +00:00
Martin Ling
1b34204261 Fix conversion of timeout to struct timeval. 2013-11-27 11:11:55 +00:00
Martin Ling
3353c22f32 Add sp_input_waiting() and sp_output_waiting() functions. 2013-11-27 02:55:18 +00:00
Martin Ling
e3dcf9068e New API and implementation for blocking and non-blocking I/O. 2013-11-27 01:45:48 +00:00
Martin Ling
8fbf876dfd Set VMIN = 1, not zero which forces non-blocking reads. 2013-11-27 01:37:35 +00:00
Martin Ling
afb518f04a Return SP_ERR_SUPP on attempt to set mark/space parity without CMSPAR. 2013-11-26 15:26:18 +00:00
Uwe Hermann
00d8c56d91 Minor cosmetics. 2013-11-26 16:12:20 +01:00
Uwe Hermann
dd7742fb15 Use "sp: " as prefix for debug logs (nicer/shorter). 2013-11-26 16:00:53 +01:00
Uwe Hermann
c3e0509275 Fix the build on NetBSD/OpenBSD/FreeBSD, possibly others.
Various termios flags used in sp_open() are Linux-specific (or even
specific to certain architectures / drivers) and not available on all
OSes (and/or versions or kernels thereof).

Thus, #ifdef out flags that we know might not be available everywhere.
2013-11-26 16:00:53 +01:00
Martin Ling
bccc7c9fa0 Set some sane defaults in sp_open() on Windows too. 2013-11-25 18:30:34 +00:00
Martin Ling
3f5c06d067 Apply termios setting changes immediately. 2013-11-25 18:21:49 +00:00
Martin Ling
e432ce6006 Support mark/space parity settings. 2013-11-25 18:05:58 +00:00
Martin Ling
b251be4b26 Turn off all the fancy termios features. 2013-11-25 17:55:37 +00:00
Martin Ling
0765af5644 Windows nonblocking write: 1 byte at a time to know when buffer fills. 2013-11-25 15:23:05 +00:00
Martin Ling
a3cb91f5e1 Implement non-blocking I/O on Windows. 2013-11-25 12:01:13 +00:00
Martin Ling
aac4d7f292 Fix SET_FAIL macro. 2013-11-25 11:34:42 +00:00
Martin Ling
33d5ff47b5 Handle -EAGAIN in non-blocking reads on Unix, and return 0 from sp_read(). 2013-11-25 10:23:13 +00:00
Martin Ling
0ba3e49b45 Fix bug in debug message generation in sp_flush(). 2013-11-23 21:21:18 +00:00
Martin Ling
59131d6028 Initialise structure in sp_new_config(). 2013-11-23 20:55:18 +00:00
Martin Ling
9b1502efce Make configuration structure opaque. 2013-11-23 20:43:13 +00:00
Martin Ling
3c126654b3 Add sp_get_port_handle() function. 2013-11-23 17:50:45 +00:00
Martin Ling
1c5aae9dc5 Make port structure opaque. 2013-11-23 17:11:19 +00:00
Martin Ling
70cd37def2 Add back previously deleted sp_get_config function. 2013-11-23 12:04:21 +00:00
Martin Ling
a6cda1e8c7 Fix swapped DCD & RI signals on Windows. 2013-11-23 11:59:42 +00:00
Martin Ling
6b93ede419 Return SP_ERR_SUPP from sp_list_ports() on unsupported platforms. 2013-11-23 11:57:17 +00:00
Martin Ling
64690702cb Generate debug output when returning using TRY() macro. 2013-11-23 11:49:35 +00:00
Martin Ling
dec10e31d0 Additional argument checking. 2013-11-23 11:39:59 +00:00
Martin Ling
ea667be751 Add additional debug messages. 2013-11-23 01:08:57 +00:00
Martin Ling
c33efc482e Add debug output for all entry and exit points. 2013-11-23 00:26:44 +00:00
Martin Ling
92f756f8c1 Add debug macros. 2013-11-23 00:19:38 +00:00
Martin Ling
863b35e69c Add API for and default handler for debug messages. 2013-11-22 22:41:03 +00:00
Uwe Hermann
71c8a9b906 serialport.c: Add missing linux_termios.h #include.
This is safe to include (at the moment) on all non-win32 OSes, since it
doesn't contain anything OS-specific.
2013-11-22 22:41:23 +01:00
Martin Ling
6aabf62a90 Use new SP_ERR_SUPP error to indicate unsupported operations. 2013-11-22 21:46:26 +01:00
Martin Ling
68ec29db5e Check for termiox support at runtime. 2013-11-22 20:28:20 +01:00
Martin Ling
8d43110ad7 Fix memory leaks. 2013-11-22 20:28:20 +01:00
Uwe Hermann
1d5d2a166f Temporarily disable USE_TERMIOX code (breaks the lib).
On some systems the use of the code enabled by USE_TERMIOX leads to a
non-working sp_open() which breaks all functionality provided by the lib.

Thus, temporarily disable that code until the details are investigated.

This has been tested with a serial port DMM and the OLS logic analyzer
on an x86 64bit Linux system with kernel version 3.11. The code compiles
fine but doesn't work at runtime. The configure output included:

checking for struct termios2... yes
checking for struct termiox... yes

The root cause for the problem is that the ioctl(fd, TCGETX, data) call in
get_flow() returns -1 ("Invalid argument"), which in turn lets sp_open()
return SP_ERR_FAIL.
2013-11-22 16:44:19 +01:00
Uwe Hermann
24abdb680f Minor cosmetics. 2013-11-22 16:10:55 +01:00
Martin Ling
82f424e6cd Fix to sp_flush() on Unix. 2013-11-22 02:19:12 +01:00
Martin Ling
8cf7c6978f Add sp_get_signals() function. 2013-11-22 02:11:40 +01:00
Martin Ling
90cc3ee62b Add sp_start_break() and sp_end_break() functions. 2013-11-22 02:11:34 +01:00
Martin Ling
69a3739ca0 Add sp_drain() function. 2013-11-22 02:11:34 +01:00
Martin Ling
fd8fd11a4e Make sp_flush take an option for what to flush. 2013-11-22 01:53:22 +01:00
Martin Ling
a036341bdf Use a more logical set of SP_MODE_* flags. 2013-11-22 01:48:02 +01:00
Martin Ling
40978c2b41 Support non-standard flow control modes on Linux. 2013-11-21 11:52:41 +00:00
Martin Ling
7a6d2196e0 Support custom baudrates on Linux. 2013-11-21 11:51:08 +00:00
Matthias Heidbrink
31b3a8f5b5 Added support for non-standard baud rates for Apple. 2013-11-20 19:18:36 +00:00
Martin Ling
e29b93a572 Retrieve XON/XOFF setting on Unix. 2013-11-19 20:46:52 +00:00
Uwe Hermann
eac329d26b Cosmetics, whitespace, consistency fixes. 2013-11-19 19:32:01 +01:00
Uwe Hermann
705bdc6947 get_config(): Add a quickfix for xon_xoff.
The config->xon_xoff variable is not filled correctly with data read
from the current serial port config. Without this, the value of the
variable will be bogus and some code that depends on the variable will fail.

Note: This is just a temporary quickfix, not a proper final solution.
2013-11-19 19:32:01 +01:00
Uwe Hermann
23922313b3 set_config(): Add missing CS5 handling. 2013-11-19 12:32:01 +01:00
Martin Ling
eb6ed20f51 Use named enums instead of ints for clearer documentation. 2013-11-19 02:36:22 +00:00
Martin Ling
bf2cbd652f Mark config argument to sp_set_config as const. 2013-11-19 01:13:09 +00:00
Martin Ling
823690ae3e Additional argument checking for config functions. 2013-11-18 20:08:25 +00:00
Martin Ling
8f189c4c0f Remove sp_ prefix from private port data structure. 2013-11-18 20:04:54 +00:00
Martin Ling
348e23ccbb Tidy up static functions. 2013-11-18 20:02:30 +00:00
Martin Ling
8f471c669f Make sure OS handles are set correctly for unopened / closed ports. 2013-11-18 20:00:15 +00:00
Martin Ling
c6754b4517 Get Xon/Xoff status on Windows. 2013-11-18 19:55:43 +00:00
Martin Ling
e33ab9aaf2 Refactor port configuration code. 2013-11-18 19:52:37 +00:00
Martin Ling
067417af4f Add sp_get_config() function. 2013-11-16 20:55:53 +00:00
Martin Ling
da2748bfb3 Eliminate lengthy switch/case blocks for baudrates. 2013-11-15 11:43:07 +00:00
Martin Ling
18fc2dd12b Add sp_set_flowcontrol helper function. 2013-11-15 11:43:07 +00:00
Martin Ling
824dcb4561 Store control bits in sp_port_data on Unix. 2013-11-15 11:43:07 +00:00
Martin Ling
9069c2fbb2 Add functions for setting individual port parameters. 2013-11-15 11:43:07 +00:00
Martin Ling
9cb98459a8 Apply sane termios settings at port open time. 2013-11-15 11:43:07 +00:00
Martin Ling
80186526b2 Add prototypes for config helper functions. 2013-11-15 11:43:07 +00:00
Martin Ling
9f90173cbd Retrieve current control line settings in start_config. 2013-11-15 11:43:07 +00:00
Martin Ling
d514a26f81 New API for serial control lines. 2013-11-15 11:43:07 +00:00
Martin Ling
cbf628c7fe Move cfset{i,o}speed() calls to set_baudrate(). 2013-11-15 11:43:07 +00:00
Martin Ling
a46f0960a2 Use negative values in sp_port_config to retain existing settings. 2013-11-15 11:43:07 +00:00
Martin Ling
d1202734fb Replace sp_set_params with sp_set_config, which takes a struct. 2013-11-15 11:43:07 +00:00
Uwe Hermann
f92f1f0c20 Minor cosmetics, typos, and so on. 2013-11-15 00:42:40 +01:00
Martin Ling
8094e4a0ce Divide sp_set_params into separate helper functions. 2013-11-15 00:42:40 +01:00
Martin Ling
767c5ba80e Include <stdio.h> on Windows for sprintf, used in sp_open. 2013-11-15 00:42:40 +01:00
Martin Ling
d1d566f27f Support 6-bit data on Unix. 2013-11-15 00:42:40 +01:00
Martin Ling
e4cc1a537a Set data bits on Windows. 2013-11-15 00:42:39 +01:00
Martin Ling
32b5ac05b4 Add sp_copy_port() function. 2013-11-15 00:42:39 +01:00
Martin Ling
99945a1fb5 On Windows, prefix port names with '\\.\' to work with ports above COM9. 2013-11-15 00:42:39 +01:00
Martin Ling
f6a1fb65ea Rename header to libserialport.h. 2013-11-15 00:42:39 +01:00