]> sigrok.org Git - libserialport.git/log
libserialport.git
4 years agoREADME: Add note on building for MSYS2/Cygwin.
Martin Ling [Sat, 25 Jan 2020 16:06:49 +0000 (16:06 +0000)]
README: Add note on building for MSYS2/Cygwin.

4 years agoRelax timing test in the other direction.
Martin Ling [Sat, 25 Jan 2020 14:54:39 +0000 (14:54 +0000)]
Relax timing test in the other direction.

On my test system under MSYS (Cygwin64), a period of 991ms was
measured after a sleep of 1s.

4 years agoFix building on Cygwin.
Martin Ling [Sat, 25 Jan 2020 14:51:56 +0000 (14:51 +0000)]
Fix building on Cygwin.

There were two issues: first, feature test macros were only defined
for __linux__, so defintions we needed were not included. Enable the
same feature test macros for __CYGWIN__.

Second, the Cygwin headers do not define TIOCOUTQ, needed to use
ioctl() to get the number of bytes in the output queue. Return
SP_ERR_SUPP on Cygwin for this operation.

This fixes bug #963.

4 years agoRelax timing test because it's too tight for Windows.
Martin Ling [Fri, 24 Jan 2020 08:02:36 +0000 (08:02 +0000)]
Relax timing test because it's too tight for Windows.

On my test system, a delay of 1016ms was measured after a
sleep of 1000ms.

4 years agoREADME: update instructions for building with MSYS2.
Martin Ling [Fri, 24 Jan 2020 07:54:50 +0000 (07:54 +0000)]
README: update instructions for building with MSYS2.

4 years agoREADME: update build instructions with VS2019/MSBuild options.
Martin Ling [Fri, 24 Jan 2020 07:05:50 +0000 (07:05 +0000)]
README: update build instructions with VS2019/MSBuild options.

4 years agoAdd Visual Studio projects and solution to build example programs.
Martin Ling [Fri, 24 Jan 2020 05:59:29 +0000 (05:59 +0000)]
Add Visual Studio projects and solution to build example programs.

4 years agoFix use of variable length local array in await_events example.
Martin Ling [Fri, 24 Jan 2020 06:24:59 +0000 (06:24 +0000)]
Fix use of variable length local array in await_events example.

This prevented building with MSVC.

4 years agowindows: Fix another CreateFile usage.
Martin Ling [Fri, 24 Jan 2020 05:14:47 +0000 (05:14 +0000)]
windows: Fix another CreateFile usage.

When built with MSVC with unicode enabled, this gave:

warning C4133: 'function': incompatible types - from 'char *' to 'LPCWSTR'

due to CreateFile expanding to CreateFileW which accepts UTF-16 filenames.

The device name used here is in 8-bit format, having come from a call to
wc_to_utf8() in either get_root_hub_name() or get_external_hub_name(). So
we need to use CreateFileA.

4 years agowindows: Fix a warning on size_t to USHORT conversion.
Martin Ling [Fri, 24 Jan 2020 05:06:55 +0000 (05:06 +0000)]
windows: Fix a warning on size_t to USHORT conversion.

Building with MSVC gave:
warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data

The value here is known to be safe for the sizes involved. Add an
explicit cast to suppress the warning.

4 years agowindows: Fix a warning on conversion to unsigned int.
Martin Ling [Fri, 24 Jan 2020 05:03:49 +0000 (05:03 +0000)]
windows: Fix a warning on conversion to unsigned int.

The result should be safe because we only use this function on time
differences as part of timeout calculations, not on absolute times.

Add an explicit cast to suppress the warning.

4 years agowindows: Fix warnings for conversions in time_as_timeval().
Martin Ling [Fri, 24 Jan 2020 04:55:32 +0000 (04:55 +0000)]
windows: Fix warnings for conversions in time_as_timeval().

Building with MSVC gave:

warning C4244: '=': conversion from 'LONGLONG' to 'long', possible loss of data

when assigning the results of these calculation to the long fields
of struct timeval. The result should be OK, but put an explicit
cast in to make the change clear and suppress the warning.

4 years agowindows: Avoid leak of write buffer on realloc failure.
Martin Ling [Fri, 24 Jan 2020 04:44:47 +0000 (04:44 +0000)]
windows: Avoid leak of write buffer on realloc failure.

VS2019 IntelliSense reported:

Warning C6308: 'realloc' might return null pointer: assigning null
               pointer to 'port->write_buf', which is passed as an
       argument to 'realloc', will cause the original memory
       block to be leaked.

This is correct, we would leak the buffer on a realloc failure.

Put the realloc result in a separate variable and handle the error
path before assigning the result to port->write_buf.

4 years agowindows: Use correct variant of FormatMessage.
Martin Ling [Fri, 24 Jan 2020 04:30:22 +0000 (04:30 +0000)]
windows: Use correct variant of FormatMessage.

When built with MSVC and unicode enabled, using 'message' gave:

warning C4133: 'initializing': incompatible types - from 'TCHAR *' to 'char *'

FormatMessage expands to either FormatMessageA or FormatMessageW
depending if unicode is enabled, and generates either a char (8-bit)
or WCHAR (UTF-16) string accordingly.

Since sp_last_error_message() returns char *, we must use the 8-bit
variant. The message will be encoded in the current code page.

4 years agowindows: Use correct variant of CreateFile.
Martin Ling [Fri, 24 Jan 2020 04:00:13 +0000 (04:00 +0000)]
windows: Use correct variant of CreateFile.

When built with MSVC and unicode enabled, using CreateFile gave:

warning C4133: 'function': incompatible types - from 'char *' to 'LPCWSTR'

CreateFile is a macro expanding to either CreateFileW if unicode
mode is enabled, or CreateFileA if not.

For CreateFileW, the filename is a UTF-16 string. For CreateFileA
it is an 'ANSI' string, meaning 8-bit chars in the current Windows
code page.

We do need to stick to 8-bit strings for port names, since
sp_get_port_by_name() and sp_get_port_name() are defined with
char * types, and that is what we store in struct sp_port. So
CreateFileA is the correct version to use.

Since Windows serial port names are always just 'COM' and a digit,
with a '\\.\' prefix for higher numbers, encoding is fortunately
not an issue - ASCII, UTF-8 and all the Windows code pages seem to
be equivalent for these characters.

We should however explicitly document what the encoding of strings
accepted and returned by libserialport is.

4 years agoFix some warnings for size_t, DWORD and int conversions.
Martin Ling [Fri, 24 Jan 2020 03:11:47 +0000 (03:11 +0000)]
Fix some warnings for size_t, DWORD and int conversions.

These cases are all in the sp_[non]blocking_{read,write} functions.

On MSVC, these conversions would generate warnings such as:
warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data

The warnings are genuine. There are some places where overflow is technically
possible, due to our use of size_t for sizes in function parameters (unsigned
64-bit on Windows x64), but an enum for return values (typically signed int
and 32-bit, but not guaranteed to be so by the standards), plus the Win32 API
usage of DWORD (unsigned 32-bit) for sizes in ReadFile/WriteFile.

However, overflow in practice would require reading/writing more than 2GB
over a serial port in a single call and is therefore unlikely to be a
real-world concern. I have therefore not tried to catch those cases - but the
places it is possible do now have explicit casts to the smaller types so that
they are more obvious.

We could document and test for a maximum read/write size of INT_MAX, but that
would still depend on the storage of 'enum sp_return' being at least a signed
int, which as I understand it the C standard does not require.

To be absolutely correct we would need a different API where sp_return
was only used for result codes, and the read/write functions took a
pointer to size_t for result sizes.

4 years agoReplace some usages of int with size_t to fix overflow warnings.
Martin Ling [Fri, 24 Jan 2020 03:01:23 +0000 (03:01 +0000)]
Replace some usages of int with size_t to fix overflow warnings.

On MSVC, these gave the following warning:

warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data

4 years agoAdd project files for Visual Studio 2019.
Martin Ling [Fri, 24 Jan 2020 02:56:50 +0000 (02:56 +0000)]
Add project files for Visual Studio 2019.

4 years agoAdjust headers and include ordering for MSVC support.
Martin Ling [Fri, 24 Jan 2020 02:56:05 +0000 (02:56 +0000)]
Adjust headers and include ordering for MSVC support.

4 years agoAdd example of waiting for events.
Martin Ling [Thu, 23 Jan 2020 02:54:23 +0000 (02:54 +0000)]
Add example of waiting for events.

4 years agoAdd an example of proper error handling.
Martin Ling [Mon, 20 Jan 2020 08:28:25 +0000 (08:28 +0000)]
Add an example of proper error handling.

4 years agoAdd some more narrative docs on the configuration API.
Martin Ling [Mon, 20 Jan 2020 07:40:10 +0000 (07:40 +0000)]
Add some more narrative docs on the configuration API.

4 years agoAdd example of how to configure a port.
Martin Ling [Mon, 20 Jan 2020 06:58:54 +0000 (06:58 +0000)]
Add example of how to configure a port.

4 years agoUse SP_API prefix for functions in libserialport.h.
Martin Ling [Mon, 20 Jan 2020 05:02:27 +0000 (05:02 +0000)]
Use SP_API prefix for functions in libserialport.h.

For MSVC, we need to set the __declspec() for public symbols to
dllexport or dllimport, depending if we are building or using the
library. So, detect MSVC and define SP_API appropriately if found.
We use the LIBSERIALPORT_MSBUILD define to distinguish between
building and using the library, which will need to be set in the
project configuration when building the library using MS tools.

For normal client use of the header on other systems, we need to
define SP_API to nothing to avoid it being undefined, but we need
to avoid doing this in the case where we are including the header
whilst building the library with autotools and SP_API is already
set by autoconf. So define LIBSERIALPORT_ATBUILD in AM_CFLAGS,
and don't touch SP_API in the header if that's set.

4 years agoUse a static header file, not dependent on autoconf.
Martin Ling [Mon, 20 Jan 2020 04:51:52 +0000 (04:51 +0000)]
Use a static header file, not dependent on autoconf.

4 years agowindows: wc_to_utf8: use some clearer variable names.
Martin Ling [Sun, 29 Dec 2019 16:15:08 +0000 (17:15 +0100)]
windows: wc_to_utf8: use some clearer variable names.

4 years agowindows: Don't try to include <unistd.h>.
Martin Ling [Sun, 29 Dec 2019 13:22:00 +0000 (14:22 +0100)]
windows: Don't try to include <unistd.h>.

This should enable compatibility with MSVC.

4 years agowindows: wc_to_utf8: Eliminate variable-length array.
Martin Ling [Sat, 28 Dec 2019 21:38:04 +0000 (22:38 +0100)]
windows: wc_to_utf8: Eliminate variable-length array.

This should enable compatibility with MSVC.

4 years agowindows: Use a fixed worst-case WRITEFILE_MAX_SIZE.
Martin Ling [Mon, 20 Jan 2020 02:01:38 +0000 (02:01 +0000)]
windows: Use a fixed worst-case WRITEFILE_MAX_SIZE.

This saves needing to include and isolate the DDK headers.

4 years agowindows: Handle the case where there are no serial ports at all.
Martin Ling [Mon, 20 Jan 2020 01:42:00 +0000 (01:42 +0000)]
windows: Handle the case where there are no serial ports at all.

It's possible for the HARDWARE\DEVICEMAP\SERIALCOMM key to not exist in
the registry if there are no serial ports at all and never have been, as
discovered on my rather minimalist gaming machine.

Handle that case gracefully and return an empty list.

4 years agowindows: Handle registry lookup failures correctly.
Martin Ling [Mon, 20 Jan 2020 01:28:17 +0000 (01:28 +0000)]
windows: Handle registry lookup failures correctly.

RegOpenKeyEx() and RegQueryInfoKey() return system error codes directly,
not by setting the thread-local errno equivalent that is returned by
GetLastError().

When returning SP_ERR_FAIL, our API specifies that sp_last_error_code()
may be called immediately afterwards to get the system error code. In
this case that would not work, as it would call GetLastError() and miss
the directly-returned result.

We therefore need to call SetLastError() with the error code before
returning with SP_ERR_FAIL.

4 years agowindows: Loop over WriteFile() if write size exceeds limit.
Martin Ling [Sat, 4 Jan 2020 00:13:58 +0000 (00:13 +0000)]
windows: Loop over WriteFile() if write size exceeds limit.

Fixes #1469.

4 years agoAdd test program for timing functions.
Martin Ling [Mon, 20 Jan 2020 03:43:49 +0000 (03:43 +0000)]
Add test program for timing functions.

4 years agoMove timing routines to separate file.
Martin Ling [Sat, 4 Jan 2020 00:43:41 +0000 (00:43 +0000)]
Move timing routines to separate file.

4 years agoMove commonly used start flag into timeout helpers.
Martin Ling [Sat, 4 Jan 2020 00:33:50 +0000 (00:33 +0000)]
Move commonly used start flag into timeout helpers.

4 years agoMove special case for poll() timeout to call site.
Martin Ling [Sat, 4 Jan 2020 00:13:24 +0000 (00:13 +0000)]
Move special case for poll() timeout to call site.

4 years agoSupport timing helpers on Windows.
Martin Ling [Fri, 3 Jan 2020 23:50:31 +0000 (23:50 +0000)]
Support timing helpers on Windows.

4 years agoMore generic solution for limiting per-call timeout.
Martin Ling [Fri, 3 Jan 2020 23:33:48 +0000 (23:33 +0000)]
More generic solution for limiting per-call timeout.

4 years agoMove repetitive timeout code into helper functions.
Martin Ling [Fri, 3 Jan 2020 22:42:00 +0000 (22:42 +0000)]
Move repetitive timeout code into helper functions.

4 years agoAbstract all time handling operations.
Martin Ling [Sun, 23 Sep 2018 16:10:21 +0000 (17:10 +0100)]
Abstract all time handling operations.

4 years agoMakefile.am: Add example files to the tarball.
Uwe Hermann [Sun, 5 Jan 2020 17:19:00 +0000 (18:19 +0100)]
Makefile.am: Add example files to the tarball.

4 years agoDoxygen: Fix an issue causing missing #define documentation output.
Uwe Hermann [Sun, 5 Jan 2020 17:17:04 +0000 (18:17 +0100)]
Doxygen: Fix an issue causing missing #define documentation output.

  Searching for documented defines...
  [...]libserialport.h:1624: warning: documentation for unknown define SP_PACKAGE_VERSION_MAJOR found.
  [...]libserialport.h:1627: warning: documentation for unknown define SP_PACKAGE_VERSION_MINOR found.
  [...]libserialport.h:1630: warning: documentation for unknown define SP_PACKAGE_VERSION_MICRO found.
  [...]libserialport.h:1633: warning: documentation for unknown define SP_PACKAGE_VERSION_STRING found.
  [...]libserialport.h:1640: warning: documentation for unknown define SP_LIB_VERSION_CURRENT found.
  [...]libserialport.h:1643: warning: documentation for unknown define SP_LIB_VERSION_REVISION found.
  [...]libserialport.h:1646: warning: documentation for unknown define SP_LIB_VERSION_AGE found.
  [...]libserialport.h:1649: warning: documentation for unknown define SP_LIB_VERSION_STRING found.

4 years agoUpdate Doxyfile for doxygen 1.8.16.
Martin Ling [Sun, 5 Jan 2020 16:17:40 +0000 (16:17 +0000)]
Update Doxyfile for doxygen 1.8.16.

4 years agoRelease examples as public domain.
Martin Ling [Sun, 5 Jan 2020 14:53:09 +0000 (14:53 +0000)]
Release examples as public domain.

4 years agoAdd some additional formatting hints to Doxygen comments.
Martin Ling [Sun, 5 Jan 2020 03:28:58 +0000 (03:28 +0000)]
Add some additional formatting hints to Doxygen comments.

4 years agoIntegrate examples into Doxygen.
Martin Ling [Sun, 5 Jan 2020 03:04:38 +0000 (03:04 +0000)]
Integrate examples into Doxygen.

4 years agoAdd examples directory with two example programs.
Martin Ling [Sun, 5 Jan 2020 02:04:06 +0000 (02:04 +0000)]
Add examples directory with two example programs.

4 years agoandroid: Fix build compatibility with NDK platform 21 and up.
Martin Ling [Sat, 4 Jan 2020 23:00:17 +0000 (23:00 +0000)]
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.

4 years agoDefine _POSIX_C_SOURCE to 199309L to get clock_gettime().
Martin Ling [Sat, 4 Jan 2020 15:39:54 +0000 (15:39 +0000)]
Define _POSIX_C_SOURCE to 199309L to get clock_gettime().

4 years agolinux: Fix compile warning on gcc 6+ for readlink() call.
Martin Ling [Tue, 31 Dec 2019 15:50:55 +0000 (16:50 +0100)]
linux: Fix compile warning on gcc 6+ for readlink() call.

Fixes #1268.

4 years agoUse O_CLOEXEC where available
Christian Seiler [Sun, 15 Oct 2017 17:28:05 +0000 (19:28 +0200)]
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.

4 years agowindows: Fix a build error.
Uwe Hermann [Sat, 28 Dec 2019 22:39:15 +0000 (23:39 +0100)]
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)
               ^

4 years agoFall back to CLOCK_REALTIME if CLOCK_MONOTONIC not usable.
Martin Ling [Sun, 23 Sep 2018 17:03:32 +0000 (18:03 +0100)]
Fall back to CLOCK_REALTIME if CLOCK_MONOTONIC not usable.

Sounds like this may be necessary on some older systems.

4 years agoUse mach_absolute_time() on OSX without clock_gettime().
Martin Ling [Sun, 23 Sep 2018 16:43:46 +0000 (17:43 +0100)]
Use mach_absolute_time() on OSX without clock_gettime().

This should fix #759 for OSX versions below 10.12.

4 years agoUse clock_gettime(CLOCK_MONOTONIC) if available.
Martin Ling [Sun, 23 Sep 2018 16:28:11 +0000 (17:28 +0100)]
Use clock_gettime(CLOCK_MONOTONIC) if available.

Should fix #759 except on OSX versions below 10.12, which don't
have clock_gettime.

4 years agoconfigure: Check whether clock_gettime is available.
Martin Ling [Sun, 23 Sep 2018 16:22:20 +0000 (17:22 +0100)]
configure: Check whether clock_gettime is available.

4 years agoMove all gettimeofday() calls into a wrapper function.
Martin Ling [Sun, 23 Sep 2018 16:19:50 +0000 (17:19 +0100)]
Move all gettimeofday() calls into a wrapper function.

4 years agowindows: Use architecture-specific size limit for WriteFile calls.
Martin Ling [Sat, 28 Dec 2019 18:47:06 +0000 (19:47 +0100)]
windows: Use architecture-specific size limit for WriteFile calls.

4 years agowindows: Use an adaptively sized buffer for nonblocking writes.
Martin Ling [Mon, 3 Jul 2017 20:43:38 +0000 (21:43 +0100)]
windows: Use an adaptively sized buffer for nonblocking writes.

4 years agowindows: Await completion of previous write before changing config.
Martin Ling [Mon, 3 Jul 2017 19:56:21 +0000 (20:56 +0100)]
windows: Await completion of previous write before changing config.

4 years agounix: Fix handling of EAGAIN in sp_nonblocking_write().
Martin Ling [Sat, 28 Dec 2019 16:53:11 +0000 (17:53 +0100)]
unix: Fix handling of EAGAIN in sp_nonblocking_write().

4 years agoRandom minor whitespace fixes.
Uwe Hermann [Sat, 28 Dec 2019 18:23:30 +0000 (19:23 +0100)]
Random minor whitespace fixes.

4 years agowindows: Fix incorrect wc_to_utf8() calls.
Uwe Hermann [Sat, 28 Dec 2019 16:08:49 +0000 (17:08 +0100)]
windows: Fix incorrect wc_to_utf8() calls.

This fixes bug #1079.

5 years agowindows: wc_to_utf8(): Fix a WCHAR related issue causing crashes.
Martin Jackson [Sat, 9 Sep 2017 22:37:48 +0000 (00:37 +0200)]
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.

6 years agoREADME: Add link to bug tracker.
Uwe Hermann [Sun, 17 Dec 2017 17:15:56 +0000 (18:15 +0100)]
README: Add link to bug tracker.

6 years agoREADME: Add missing contact info.
Uwe Hermann [Fri, 15 Dec 2017 17:38:11 +0000 (18:38 +0100)]
README: Add missing contact info.

7 years agowindows: Break out helper function for awaiting previous write completion.
Martin Ling [Mon, 3 Jul 2017 19:55:13 +0000 (20:55 +0100)]
windows: Break out helper function for awaiting previous write completion.

7 years agoRemove redundant inclusions of limits.h
Stefan Tauner [Sun, 21 May 2017 21:44:03 +0000 (23:44 +0200)]
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.

7 years agoCanonicalize symlinks in portnames
Stefan Tauner [Sun, 21 May 2017 21:42:06 +0000 (23:42 +0200)]
Canonicalize symlinks in portnames

This allows users to supply symlinks created e.g. by udev rules instead
of the actual device names.

7 years agoFreeBSD: Add missing libusb-2.0 to pkg-config file.
Uwe Hermann [Wed, 13 Sep 2017 13:04:35 +0000 (15:04 +0200)]
FreeBSD: Add missing libusb-2.0 to pkg-config file.

This fixes bug #1033.

7 years agoLinux: fix for alpha where BOTHER is not defined.
Martin Ling [Sun, 19 Mar 2017 12:16:49 +0000 (12:16 +0000)]
Linux: fix for alpha where BOTHER is not defined.

Fixes bug #363.

7 years agoconfigure summary: Show compiler version and flags.
Uwe Hermann [Sun, 5 Mar 2017 16:01:17 +0000 (17:01 +0100)]
configure summary: Show compiler version and flags.

7 years agoconfigure summary: Show whether shared/static build is enabled.
Uwe Hermann [Sun, 5 Mar 2017 15:43:58 +0000 (16:43 +0100)]
configure summary: Show whether shared/static build is enabled.

7 years agoconfigure summary: Slightly change formatting.
Uwe Hermann [Sun, 5 Mar 2017 15:42:37 +0000 (16:42 +0100)]
configure summary: Slightly change formatting.

8 years agouse readdir() instead of the deprecated readir_r()
Aurelien Jacobs [Fri, 14 Oct 2016 21:50:08 +0000 (23:50 +0200)]
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) {
  ^~~~~

8 years agolibserialport: Fix Linux files not compiled in with a toolchain for ucLinux
Paul Cercueil [Mon, 29 Aug 2016 13:05:20 +0000 (15:05 +0200)]
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 <redacted>
8 years agolinux: freebsd: do check on proper pointer libserialport-unreleased
Wolfram Sang [Fri, 19 Feb 2016 21:25:00 +0000 (22:25 +0100)]
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 <redacted>
8 years agoBump libtool version (not package version) to 1:0:1.
Uwe Hermann [Sat, 9 Jan 2016 00:13:45 +0000 (01:13 +0100)]
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.

8 years agoNEWS: Last updates for the upcoming 0.1.1 release.
Uwe Hermann [Fri, 8 Jan 2016 23:48:39 +0000 (00:48 +0100)]
NEWS: Last updates for the upcoming 0.1.1 release.

8 years agoFix ERROR_SEM_TIMEOUT issue on Windows.
Uwe Hermann [Wed, 27 Jan 2016 07:19:38 +0000 (08:19 +0100)]
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.

8 years agoFix sp_blocking_read_next() implementation on Windows.
Uwe Hermann [Fri, 22 Jan 2016 14:30:44 +0000 (15:30 +0100)]
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.

8 years agowindows: Fix iSerial for composite devices.
Martino Facchin [Wed, 16 Dec 2015 18:07:49 +0000 (19:07 +0100)]
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)

8 years agomacosx: Fix port listing on ElCapitan.
Martino Facchin [Fri, 18 Dec 2015 11:40:58 +0000 (12:40 +0100)]
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)

8 years agoChange debug message to "Port not open" when a closed port is used.
Martin Ling [Tue, 29 Dec 2015 02:36:04 +0000 (02:36 +0000)]
Change debug message to "Port not open" when a closed port is used.

Fixes bug #710.

8 years agolibserialport_internal: use new macro to enable timeradd, etc.
Wolfram Sang [Mon, 28 Dec 2015 13:33:40 +0000 (14:33 +0100)]
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 <redacted>
8 years agowindows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read().
Martin Ling [Tue, 8 Dec 2015 20:08:49 +0000 (20:08 +0000)]
windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read().

This fixes bug #707.

9 years agosp_wait: Avoid overflow of timeout parameter to poll().
Martin Ling [Tue, 13 Oct 2015 14:04:03 +0000 (15:04 +0100)]
sp_wait: Avoid overflow of timeout parameter to poll().

9 years agoBuild: Include config.h first in all source files
Daniel Elstner [Sun, 13 Sep 2015 18:04:31 +0000 (20:04 +0200)]
Build: Include config.h first in all source files

9 years agoBuild: Use GNUMAKEFLAGS and $@
Daniel Elstner [Thu, 10 Sep 2015 20:03:07 +0000 (22:03 +0200)]
Build: Use GNUMAKEFLAGS and $@

9 years agoautogen.sh: Create autostuff/ dir if it does not exist
Daniel Elstner [Thu, 27 Aug 2015 09:46:06 +0000 (11:46 +0200)]
autogen.sh: Create autostuff/ dir if it does not exist

9 years agoconfigure: Enable largefile support on 32-bit systems
Daniel Elstner [Wed, 26 Aug 2015 20:49:40 +0000 (22:49 +0200)]
configure: Enable largefile support on 32-bit systems

9 years agoClean up .gitignore
Daniel Elstner [Wed, 26 Aug 2015 20:01:03 +0000 (22:01 +0200)]
Clean up .gitignore

9 years agoBuild: Clean up configure.ac and Makefile.am
Daniel Elstner [Wed, 26 Aug 2015 19:42:32 +0000 (21:42 +0200)]
Build: Clean up configure.ac and Makefile.am

Among other things, rename some config defines so we can take
advantage of standard Autoconf macros.

9 years agoBuild: Reduce autogen.sh to trivial stub
Daniel Elstner [Wed, 26 Aug 2015 17:46:43 +0000 (19:46 +0200)]
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.

9 years agoUpdate copyright notices.
Martin Ling [Sun, 31 May 2015 12:07:20 +0000 (13:07 +0100)]
Update copyright notices.

9 years agoUpdate AUTHORS file.
Martin Ling [Sun, 31 May 2015 11:32:21 +0000 (12:32 +0100)]
Update AUTHORS file.

9 years agoNEWS: Update for the upcoming 0.1.1 release.
Uwe Hermann [Sat, 30 May 2015 20:04:56 +0000 (22:04 +0200)]
NEWS: Update for the upcoming 0.1.1 release.

9 years agodoc: Provided channel is binary, not necessarily 8-bit.
Martin Ling [Sat, 30 May 2015 20:03:38 +0000 (21:03 +0100)]
doc: Provided channel is binary, not necessarily 8-bit.

9 years agoFix possible use of uninitialised variable in poll() setup.
Martin Ling [Wed, 27 May 2015 10:21:56 +0000 (11:21 +0100)]
Fix possible use of uninitialised variable in poll() setup.

9 years agodoc: Additional introductory text.
Martin Ling [Wed, 27 May 2015 09:53:46 +0000 (10:53 +0100)]
doc: Additional introductory text.