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

336 Commits

Author SHA1 Message Date
Martin Ling
8c1a14e658 Add examples directory with two example programs. 2020-01-05 02:04:06 +00:00
Martin Ling
abd31fd9f9 android: Fix build compatibility with NDK platform 21 and up.
In platforms 21 and higher of the NDK, linux/serial.h is available,
which it was not before. This broke the build, because the configure
script would detect the availability of 'struct serial_struct' in that
header and set HAVE_STRUCT_SERIAL_STRUCT, but the #ifndef __ANDROID__
in libserialport_internal.h stopped us actually including the header.

This change fixes things to build with all versions of the NDK, and is
tested with builds for arm from versions 9 to 24.

Version 21 also added availability of tcdrain(), so we also use that
where available, and only use the direct ioctl() method on NDK < 21.

Fixes #1078.
2020-01-04 23:00:17 +00:00
Martin Ling
277f832a6a Define _POSIX_C_SOURCE to 199309L to get clock_gettime(). 2020-01-04 18:27:25 +01:00
Martin Ling
9118f753f4 linux: Fix compile warning on gcc 6+ for readlink() call.
Fixes #1268.
2020-01-04 18:24:00 +01:00
Christian Seiler
fa106ef155 Use O_CLOEXEC where available
Ensures that the file descriptor is (by default) not passed to
subprocesses spawned by applications using libserialport.

This fixes bug #1051.
2020-01-04 18:21:35 +01:00
Uwe Hermann
bd0fb6094f windows: Fix a build error.
serialport.c: In function 'get_time':
  serialport.c:64:6: warning: implicit declaration of function 'clock_gettime' [-Wimplicit-function-declaration]
    if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
        ^
  serialport.c:64:20: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
    if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
                      ^
  serialport.c:64:20: note: each undeclared identifier is reported only once for each function it appears in
  serialport.c:65:17: error: 'CLOCK_REALTIME' undeclared (first use in this function)
     clock_gettime(CLOCK_REALTIME, &ts);
                   ^
  serialport.c: At top level:
  serialport.c:60:13: warning: 'get_time' defined but not used [-Wunused-function]
   static void get_time(struct timeval *time)
               ^
2019-12-28 23:39:15 +01:00
Martin Ling
7fb9a7b0a7 Fall back to CLOCK_REALTIME if CLOCK_MONOTONIC not usable.
Sounds like this may be necessary on some older systems.
2019-12-28 22:02:19 +01:00
Martin Ling
192e77492a Use mach_absolute_time() on OSX without clock_gettime().
This should fix #759 for OSX versions below 10.12.
2019-12-28 22:02:19 +01:00
Martin Ling
f40ea9d461 Use clock_gettime(CLOCK_MONOTONIC) if available.
Should fix #759 except on OSX versions below 10.12, which don't
have clock_gettime.
2019-12-28 22:02:19 +01:00
Martin Ling
46bdc20c26 configure: Check whether clock_gettime is available. 2019-12-28 22:02:19 +01:00
Martin Ling
573feabc63 Move all gettimeofday() calls into a wrapper function. 2019-12-28 22:02:19 +01:00
Martin Ling
b457865b8f windows: Use architecture-specific size limit for WriteFile calls. 2019-12-28 20:43:22 +01:00
Martin Ling
39df7833f7 windows: Use an adaptively sized buffer for nonblocking writes. 2019-12-28 20:43:22 +01:00
Martin Ling
6bd6a8b520 windows: Await completion of previous write before changing config. 2019-12-28 20:43:22 +01:00
Martin Ling
55ab7e0b6b unix: Fix handling of EAGAIN in sp_nonblocking_write(). 2019-12-28 20:43:22 +01:00
Uwe Hermann
81243567bc Random minor whitespace fixes. 2019-12-28 19:23:30 +01:00
Uwe Hermann
2e0437c28e windows: Fix incorrect wc_to_utf8() calls.
This fixes bug #1079.
2019-12-28 17:08:49 +01:00
Martin Jackson
38b71192dd windows: wc_to_utf8(): Fix a WCHAR related issue causing crashes.
In wc_to_utf8() in windows.c, the zero terminator is written to an invalid
array index, which results in 2 bytes being zeroed in a random place in the
stack. This sometimes causes a crash when running sp_list_ports() (depending
on string length and compiler optimisation settings).

sizeof(wc_str) returns the size in bytes, so cannot be used directly as an
index into that array, it should be divided by sizeof(WCHAR). Otherwise the
zero terminator index is approximately twice what it should be.

This fixes bug #1031.
2019-06-30 14:23:59 +02:00
Uwe Hermann
a84ffb5372 README: Add link to bug tracker. 2017-12-17 18:15:56 +01:00
Uwe Hermann
42ad781896 README: Add missing contact info. 2017-12-15 18:38:11 +01:00
Martin Ling
62ed9f801a windows: Break out helper function for awaiting previous write completion. 2017-09-13 19:27:50 +02:00
Stefan Tauner
15541ebd78 Remove redundant inclusions of limits.h
The first one would be included for Windows too which seems to be
an error. The second one is obviously redundant.
2017-09-13 19:27:50 +02:00
Stefan Tauner
95bad38c5b Canonicalize symlinks in portnames
This allows users to supply symlinks created e.g. by udev rules instead
of the actual device names.
2017-09-13 19:27:50 +02:00
Uwe Hermann
2a6c24be33 FreeBSD: Add missing libusb-2.0 to pkg-config file.
This fixes bug #1033.
2017-09-13 15:04:56 +02:00
Martin Ling
6c8115820d Linux: fix for alpha where BOTHER is not defined.
Fixes bug #363.
2017-03-19 12:16:49 +00:00
Uwe Hermann
d8de88de32 configure summary: Show compiler version and flags. 2017-03-05 17:01:17 +01:00
Uwe Hermann
0b53933127 configure summary: Show whether shared/static build is enabled. 2017-03-05 16:43:58 +01:00
Uwe Hermann
5ec2f93bce configure summary: Slightly change formatting. 2017-03-05 16:42:37 +01:00
Aurelien Jacobs
df3b70a888 use readdir() instead of the deprecated readir_r()
readir() is threadsafe on both linux and freebsd anyway.
The rationale behind the readdir_r() deprecation is in the glibc manual:
https://www.gnu.org/software/libc/manual/html_node/Reading_002fClosing-Directory.html

This fixes the following warning with recent glibc:

linux.c: In function ‘list_ports’:
linux.c:197:2: warning: ‘readdir_r’ is deprecated [-Wdeprecated-declarations]
  while (!readdir_r(dir, &entry, &result) && result) {
  ^~~~~
2016-10-14 23:58:22 +02:00
Paul Cercueil
b2359c5c99 libserialport: Fix Linux files not compiled in with a toolchain for ucLinux
Buildroot can create toolchains for the no-MMU flavour of Linux, with a triple
containing 'uclinux' instead of just 'linux'.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
2016-09-04 18:42:43 +02:00
Wolfram Sang
0c3f38b81b linux: freebsd: do check on proper pointer
We want to check here if we added something to the list, not if the
function argument was valid. Problem spotted by Coverity, CID 50754.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-02-28 18:01:25 +01:00
Uwe Hermann
3fcdc9f7d5 Bump libtool version (not package version) to 1:0:1.
The last release (0.1.0) had the libtool version (current:revision:age)
set to 0:0:0. Since this release doesn't change/remove any
interfaces (it does *add* new interfaces, though), 'current' and 'age'
are increased and 'revision' is set to 0, resulting in 1:0:1.

http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info

Programs using libserialport don't need to be recompiled or relinked.
2016-01-27 12:36:01 +01:00
Uwe Hermann
24a38c8094 NEWS: Last updates for the upcoming 0.1.1 release. 2016-01-27 12:36:01 +01:00
Uwe Hermann
aee7d69195 Fix ERROR_SEM_TIMEOUT issue on Windows.
The sp_blocking_write() call was incorrectly returning an error upon
ERROR_SEM_TIMEOUT. It now returns 0 instead.
2016-01-27 12:35:45 +01:00
Uwe Hermann
888fb45d66 Fix sp_blocking_read_next() implementation on Windows.
A ReadFile() call needed to check the actual number of bytes read,
instead of assuming all requested bytes were read.
2016-01-22 15:32:00 +01:00
Martino Facchin
02c8a1424d windows: Fix iSerial for composite devices.
USB composite devices can contain an ACM serial interface.
On Windows, the correct iSerial descriptor field is assigned to the parent
(composite) device instead of to the actual serial interface. A bogus
value is returned if the serial interface is asked to provide the S/N.
This patch provides a fallback for this kind of device (tested on Android
with adb + cdc gadgets and on Arduino Zero Programming Port)
2016-01-06 13:54:17 +00:00
Martino Facchin
aacba60dca macosx: Fix port listing on ElCapitan.
On OSX 10.11 (ElCapitan) the query for IOProviderClass fails to list ACM
devices as USB.
Add a fallback query using IOClass to correctly recognize these devices.
The fix has no effect on previous OSX versions (tested on Mavericks)
2016-01-06 13:54:11 +00:00
Martin Ling
8062087ab3 Change debug message to "Port not open" when a closed port is used.
Fixes bug #710.
2015-12-29 13:30:30 +01:00
Wolfram Sang
4d8195fe3f libserialport_internal: use new macro to enable timeradd, etc.
Since glibc 2.20, the usage of _BSD_SOURCE is deprecated. Fix it like
described here:

https://sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros

This fixes bug #716.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2015-12-29 01:16:28 +01:00
Martin Ling
ae2c5825e7 windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read().
This fixes bug #707.
2015-12-09 12:43:11 +01:00
Martin Ling
127d8d0ce7 sp_wait: Avoid overflow of timeout parameter to poll(). 2015-10-13 15:04:03 +01:00
Daniel Elstner
1a584c45b0 Build: Include config.h first in all source files 2015-09-13 20:04:31 +02:00
Daniel Elstner
962143bc5c Build: Use GNUMAKEFLAGS and $@ 2015-09-10 22:19:15 +02:00
Daniel Elstner
c37c9f348d autogen.sh: Create autostuff/ dir if it does not exist 2015-08-27 11:46:06 +02:00
Daniel Elstner
07f61c7131 configure: Enable largefile support on 32-bit systems 2015-08-26 22:49:40 +02:00
Daniel Elstner
87f4a6f021 Clean up .gitignore 2015-08-26 22:01:03 +02:00
Daniel Elstner
f1c916ede1 Build: Clean up configure.ac and Makefile.am
Among other things, rename some config defines so we can take
advantage of standard Autoconf macros.
2015-08-26 21:55:10 +02:00
Daniel Elstner
ef08a6d52b Build: Reduce autogen.sh to trivial stub
Use autoreconf instead of invoking the various Auto tools
separately. Get rid of the Darwin-specific guesswork -- it does
not make sense to handle this at the level of libserialport.

People should set up their ACLOCAL_PATH themselves as appropriate
for their own system; just as they already need to set up various
other paths.
2015-08-26 19:46:43 +02:00
Martin Ling
f77bb46df5 Update copyright notices. 2015-05-31 18:26:53 +02:00
Martin Ling
d931da1042 Update AUTHORS file. 2015-05-31 18:26:53 +02:00