mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Compare commits
1 Commits
master
...
libserialp
Author | SHA1 | Date | |
---|---|---|---|
15018e762b |
37
.gitignore
vendored
37
.gitignore
vendored
@ -1,22 +1,19 @@
|
||||
*.[ao]
|
||||
*.l[ao]
|
||||
.deps/
|
||||
.libs/
|
||||
/INSTALL
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/aclocal.m4
|
||||
/autom4te.cache/
|
||||
/autostuff/
|
||||
/config.*
|
||||
/configure
|
||||
/configure.lineno
|
||||
/libserialport-*.tar.*
|
||||
/libserialport.pc
|
||||
/libtool
|
||||
stamp-h?
|
||||
.vs/
|
||||
Debug/
|
||||
Release/
|
||||
x64/
|
||||
*.vcxproj.user
|
||||
INSTALL
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
autostuff/
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
libserialport.la
|
||||
libserialport.pc
|
||||
libserialport.h
|
||||
libtool
|
||||
serialport.lo
|
||||
serialport.o
|
||||
linux_termios.lo
|
||||
linux_termios.o
|
||||
|
24
AUTHORS
24
AUTHORS
@ -2,26 +2,6 @@
|
||||
AUTHORS
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Martin Ling conceived the idea for the library, designed the API and wrote much
|
||||
of the implementation and documentation.
|
||||
Please check the source code files and/or git history and/or ChangeLog for
|
||||
a list of all authors and contributors.
|
||||
|
||||
The initial codebase was adapted from serial code in libsigrok, written by Bert
|
||||
Vermeulen and Uwe Hermann, who gave permission for it to be relicensed under
|
||||
the LGPL3+ for inclusion in libserialport.
|
||||
|
||||
The package is maintained by Uwe Hermann, with input from Martin Ling.
|
||||
|
||||
Aurelien Jacobs made several contributions, including the USB metadata API,
|
||||
improvements to the port enumeration code, and eliminating the previous
|
||||
dependence on libudev for enumeration on Linux.
|
||||
|
||||
Uffe Jakobsen contributed the FreeBSD support.
|
||||
|
||||
Matthias Heidbrink contributed support for non-standard baudrates on Mac OS X.
|
||||
|
||||
Bug fixes have been contributed by Bert Vermeulen, silverbuddy, Marcus
|
||||
Comstedt, Antti Nykanen, Michael B. Trausch and Janne Huttunen.
|
||||
|
||||
For a full history of contributions, see the git history.
|
||||
|
||||
Others have helped the project by contributing bug reports and discussion.
|
||||
|
52
Makefile.am
52
Makefile.am
@ -19,65 +19,35 @@
|
||||
##
|
||||
|
||||
ACLOCAL_AMFLAGS = -I autostuff
|
||||
AM_LIBTOOLFLAGS = --silent
|
||||
GNUMAKEFLAGS = --no-print-directory
|
||||
|
||||
# Enable more compiler warnings.
|
||||
AM_CFLAGS = -std=c99 -Wall -Wextra -pedantic -Wmissing-prototypes -Wshadow
|
||||
# Set flag used in libserialport.h to indicate we are building the library
|
||||
# using autotools.
|
||||
AM_CFLAGS += -DLIBSERIALPORT_ATBUILD
|
||||
AM_CPPFLAGS = -I$(top_srcdir)
|
||||
|
||||
lib_LTLIBRARIES = libserialport.la
|
||||
|
||||
libserialport_la_SOURCES = serialport.c timing.c libserialport_internal.h
|
||||
libserialport_la_SOURCES = serialport.c
|
||||
if LINUX
|
||||
libserialport_la_SOURCES += linux.c linux_termios.c linux_termios.h
|
||||
endif
|
||||
if WIN32
|
||||
libserialport_la_SOURCES += windows.c
|
||||
endif
|
||||
if MACOSX
|
||||
libserialport_la_SOURCES += macosx.c
|
||||
endif
|
||||
if FREEBSD
|
||||
libserialport_la_SOURCES += freebsd.c
|
||||
libserialport_la_SOURCES += linux_termios.c linux_termios.h
|
||||
endif
|
||||
|
||||
libserialport_la_LIBADD = $(SP_LIBS)
|
||||
libserialport_la_LIBADD = $(LIBOBJS)
|
||||
|
||||
libserialport_la_LDFLAGS = -version-info $(SP_LIB_VERSION) -no-undefined
|
||||
if MACOSX
|
||||
libserialport_la_LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||
endif
|
||||
libserialport_la_LDFLAGS = $(SP_LIB_LDFLAGS)
|
||||
|
||||
nodist_include_HEADERS = libserialport.h
|
||||
library_includedir = $(includedir)
|
||||
library_include_HEADERS = libserialport.h
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libserialport.pc
|
||||
|
||||
TESTS = test_timing
|
||||
check_PROGRAMS = test_timing
|
||||
test_timing_SOURCES = timing.c test_timing.c
|
||||
test_timing_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
EXTRA_DIST = Doxyfile \
|
||||
examples/Makefile \
|
||||
examples/README \
|
||||
examples/list_ports.c \
|
||||
examples/port_info.c \
|
||||
examples/port_config.c \
|
||||
examples/await_events.c \
|
||||
examples/handle_errors.c
|
||||
EXTRA_DIST = Doxyfile
|
||||
|
||||
MAINTAINERCLEANFILES = ChangeLog
|
||||
|
||||
.PHONY: ChangeLog doc
|
||||
|
||||
.PHONY: ChangeLog
|
||||
ChangeLog:
|
||||
git --git-dir '$(top_srcdir)/.git' log >$@ || touch $@
|
||||
git --git-dir $(top_srcdir)/.git log > ChangeLog || touch ChangeLog
|
||||
|
||||
dist-hook: ChangeLog
|
||||
|
||||
doc: $(nodist_include_HEADERS) $(top_srcdir)/Doxyfile
|
||||
doc: $(library_include_HEADERS) $(top_srcdir)/Doxyfile
|
||||
doxygen $(top_srcdir)/Doxyfile
|
||||
|
76
NEWS
76
NEWS
@ -1,79 +1,3 @@
|
||||
0.1.1 (2016-01-27)
|
||||
------------------
|
||||
|
||||
Note: This release does NOT change the libserialport API or ABI in
|
||||
backwards-incompatible ways. Programs using libserialport should
|
||||
continue to work fine without recompiling or relinking.
|
||||
|
||||
* New API calls:
|
||||
- sp_get_port_description(): Obtain a user friendly port description.
|
||||
- sp_get_port_transport(): Obtain the underlying transport type.
|
||||
- sp_get_port_usb_bus_address(): Obtain the USB bus number & device address.
|
||||
- sp_get_port_usb_vid_pid(): Obtain the USB VID and PID.
|
||||
- sp_get_port_usb_manufacturer(): Obtain the USB manufacturer string.
|
||||
- sp_get_port_usb_product(): Obtain the USB product string.
|
||||
- sp_get_port_usb_serial(): Obtain the USB serial number string.
|
||||
- sp_get_port_bluetooth_address(): Obtain the Bluetooth MAC address.
|
||||
- sp_blocking_read_next(): Read bytes from the specified serial port,
|
||||
returning as soon as any data is available.
|
||||
* API related additions:
|
||||
- enum sp_mode: Add SP_MODE_READ_WRITE.
|
||||
- Add enum sp_transport with the following enum entries:
|
||||
SP_TRANSPORT_NATIVE, SP_TRANSPORT_USB, SP_TRANSPORT_BLUETOOTH.
|
||||
* Fix the build on platforms where port enumeration and/or port
|
||||
metadata is not available or implemented.
|
||||
* Build system:
|
||||
- Don't set/override "user variables" such as CFLAGS or LDFLAGS, since
|
||||
those are meant to be controlled by the "user" (bug #577).
|
||||
- Modernize and cleanup autotools setup.
|
||||
* Remove trailing commas in libserialport.h enum definitions to allow
|
||||
the code to build with the -pedantic compiler option.
|
||||
* Fix various issues to allow successful builds with -std=c99.
|
||||
* Fix various (non-fatal) compiler warnings.
|
||||
* Fix various memory leaks (bug #419, among others).
|
||||
* Fix a potential overflow of the timeout parameter of poll().
|
||||
* Fix ReadFile() ERROR_IO_PENDING in sp_nonblocking_read() (bug #707).
|
||||
* Fix a glibc >= 2.20 compiler warning for deprecated _BSD_SOURCE (bug #716).
|
||||
* Rename a 'signals' parameter to 'signal_mask' to avoid a conflict with Qt.
|
||||
* Fix two potential segfaults in sp_get_port_handle() and sp_get_config_*()
|
||||
(which only occurred if the user incorrectly passed in a NULL argument).
|
||||
* sp_list_ports(): Actually set list_ptr NULL as documented.
|
||||
* Use "Port not open" debug message when a closed port is used (bug #710).
|
||||
* Linux:
|
||||
- The libudev requirement has been dropped (/sys is now used directly).
|
||||
- Fix a build issue in the get_termios_get_ioctl() call (bug #396).
|
||||
- Fix sp_flush() so that it only flushes the requested buffers.
|
||||
- Fix a build error if BOTHER is not available (bug #363).
|
||||
- If present, add the USB "description" for better port identification.
|
||||
- Handle the case when /sys/class/tty/ entries are not symlinks.
|
||||
* Windows:
|
||||
- MinGW-w64 (mingw-w64.sf.net) is now required for building, and MinGW
|
||||
(mingw.org) is no longer supported (bug #393).
|
||||
- Fix a build issue due to a missing <initguid.h> #include.
|
||||
- Fix a build issue due to the missing -lsetupapi linker argument.
|
||||
- Use libtool's -no-undefined option to allow shared (DLL) builds.
|
||||
- Fix a compile error due to multiply or not defined GUIDs (bug #416).
|
||||
- Fix a build issue related to the SP_PRIV/SP_API macros (bug #553).
|
||||
- Fix a bug where an uninitialized pointer was free()'d (bug #512).
|
||||
- Fix a bug wrt the SetupDiOpenDevRegKey() return code (bug #499).
|
||||
- Fix a bug wrt restart of RX/error wait operations after read (bug #421).
|
||||
- Fix a bug wrt WaitCommEvents() and/or fAbortOnError handling (bug #341).
|
||||
- Fix USB iSerial queries on USB composite devices.
|
||||
- Strip CR/LF from end of system error messages (bug #585).
|
||||
- Avoid unnecessary calls to the SetCommTimeouts() function (bug #586).
|
||||
- Fix a bug in the Windows implementation of sp_blocking_read_next().
|
||||
- Fix an ERROR_SEM_TIMEOUT related issue in sp_blocking_write().
|
||||
* FreeBSD:
|
||||
- Implement serial port enumeration for FreeBSD systems.
|
||||
* Android:
|
||||
- Fix a portability issue wrt the unavailable 'serial_struct' (bug #376).
|
||||
- Fix a portability issue wrt a readlinkat() call (bug #377).
|
||||
* Mac OS X:
|
||||
- Fix port listing on Mac OS X 10.11 (El Capitan).
|
||||
* README: Various documentation updates and fixes.
|
||||
* AUTHORS: Add/update list of contributors.
|
||||
* Doxygen API docs: Various documentation updates and fixes.
|
||||
|
||||
0.1.0 (2014-05-06)
|
||||
------------------
|
||||
|
||||
|
63
README
63
README
@ -11,7 +11,6 @@ transparently on any platform supported by the library.
|
||||
The operations that are supported are:
|
||||
|
||||
- Port enumeration (obtaining a list of serial ports on the system).
|
||||
- Obtaining port metadata (USB device information, Bluetooth address, etc).
|
||||
- Opening and closing ports.
|
||||
- Setting port parameters (baud rate, parity, etc).
|
||||
- Reading, writing and flushing data.
|
||||
@ -25,68 +24,38 @@ Status
|
||||
The library should build and work on any Windows or Unix-based system. If it
|
||||
does not, please submit a bug.
|
||||
|
||||
Enumeration is currently implemented on Windows, Mac OS X, FreeBSD and Linux.
|
||||
On other systems enumeration is not supported, but ports can still be opened
|
||||
by name and then used.
|
||||
Enumeration is currently only implemented on Windows, Mac OS X and Linux. On
|
||||
other systems enumeration is not supported, but ports can still be opened by
|
||||
name and then used.
|
||||
|
||||
If you know how to enumerate available ports on another OS, please submit a bug
|
||||
with this information, or better still a patch implementing it.
|
||||
|
||||
Future
|
||||
======
|
||||
|
||||
Future versions will add additional API calls for obtaining metadata about a
|
||||
port, e.g. for USB devices the USB VID and PID of the underlying device.
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
No other libraries are required.
|
||||
On Linux, libudev is required. On other systems no other libraries are required.
|
||||
|
||||
The libudev dependency could be eliminated in favour of direct sysfs queries at
|
||||
the cost of some brevity. This is not currently a priority but if you feel like
|
||||
doing this feel free to submit a patch.
|
||||
|
||||
Building
|
||||
========
|
||||
|
||||
On Windows, libserialport can be built with Visual Studio 2019 or with
|
||||
the standalone MSBuild tool, using the solution and project files provided.
|
||||
|
||||
For other environments, the package uses a GNU style build based on autotools.
|
||||
The package uses a GNU style build system and requires a Unix style shell.
|
||||
On Windows it can be built with the MinGW toolchain and MSYS environment.
|
||||
|
||||
Run "./autogen.sh" to generate the build system, "./configure" to setup, then
|
||||
"make" to build the library and "make install" to install it.
|
||||
|
||||
Windows builds can also be created using the autotools build system, using the
|
||||
MinGW-w64 toolchain from http://mingw-w64.sourceforge.net/ - either natively
|
||||
in Windows with the MSYS2 environment, or cross-compiling from another system.
|
||||
|
||||
To build from MSYS2, the following packages must be installed: autoconf,
|
||||
automake-wrapper, libtool, make, and either mingw-w64-i686-gcc (for 32-bit)
|
||||
or mingw-w64-x86_64-gcc (for 64-bit). Open either the "MSYS2 MinGW 32-bit" or
|
||||
"MSYS2 MinGW 64-bit" command window from the Start menu and use this when
|
||||
configuring and building the package. Using the "MSYS2 MSYS" shell will build
|
||||
against the Cygwin compatibility layer; this works, but port enumeration and
|
||||
metadata will not be available, and binaries will depend on Cygwin. The builds
|
||||
produced by MinGW-w64 are normal Windows DLLs without additional dependencies.
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
Doxygen API documentation is included.
|
||||
|
||||
It can also be viewed online at:
|
||||
|
||||
http://sigrok.org/api/libserialport/unstable/
|
||||
|
||||
Bug reports
|
||||
===========
|
||||
|
||||
You can report bugs for libserialport at https://sigrok.org/bugzilla.
|
||||
|
||||
Mailing list
|
||||
============
|
||||
|
||||
https://lists.sourceforge.net/lists/listinfo/sigrok-devel
|
||||
|
||||
IRC
|
||||
===
|
||||
|
||||
You can find the developers in the #sigrok IRC channel on Libera.Chat.
|
||||
|
||||
Website
|
||||
=======
|
||||
|
||||
http://sigrok.org/wiki/Libserialport
|
||||
|
||||
|
44
autogen.sh
44
autogen.sh
@ -1,4 +1,4 @@
|
||||
#!/bin/sh -e
|
||||
#!/bin/sh
|
||||
##
|
||||
## This file is part of the libserialport project.
|
||||
##
|
||||
@ -19,8 +19,42 @@
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
test -n "$srcdir" || srcdir=`dirname "$0"`
|
||||
test -n "$srcdir" || srcdir=.
|
||||
OS=`uname`
|
||||
|
||||
LIBTOOLIZE=libtoolize
|
||||
ACLOCAL_DIR=
|
||||
|
||||
if [ "x$OS" = "xDarwin" ]; then
|
||||
LIBTOOLIZE=glibtoolize
|
||||
|
||||
if [ -d /sw/share/aclocal ]; then
|
||||
# fink installs aclocal macros here
|
||||
ACLOCAL_DIR="-I /sw/share/aclocal"
|
||||
elif [ -d /opt/local/share/aclocal ]; then
|
||||
# Macports installs aclocal macros here
|
||||
ACLOCAL_DIR="-I /opt/local/share/aclocal"
|
||||
elif [ -d /usr/local/share/aclocal ]; then
|
||||
# Homebrew installs aclocal macros here
|
||||
ACLOCAL_DIR="-I /usr/local/share/aclocal"
|
||||
elif [ -d /usr/share/aclocal ]; then
|
||||
# Xcode installs aclocal macros here
|
||||
ACLOCAL_DIR="-I /usr/share/aclocal"
|
||||
fi
|
||||
|
||||
elif [ "x$OS" = "xMINGW32_NT-5.1" ]; then
|
||||
# Windows XP
|
||||
ACLOCAL_DIR="-I /usr/local/share/aclocal"
|
||||
elif [ "x$OS" = "xMINGW32_NT-6.0" ]; then
|
||||
# Windows Vista
|
||||
ACLOCAL_DIR="-I /usr/local/share/aclocal"
|
||||
elif [ "x$OS" = "xMINGW32_NT-6.1" ]; then
|
||||
# Windows 7
|
||||
ACLOCAL_DIR="-I /usr/local/share/aclocal"
|
||||
fi
|
||||
|
||||
echo "Generating build system..."
|
||||
${LIBTOOLIZE} --install --copy --quiet || exit 1
|
||||
aclocal ${ACLOCAL_DIR} || exit 1
|
||||
automake --add-missing --copy || exit 1
|
||||
autoconf || exit 1
|
||||
|
||||
test -d "$srcdir/autostuff" || mkdir "$srcdir/autostuff"
|
||||
autoreconf --force --install --verbose "$srcdir"
|
||||
|
23
common.props
23
common.props
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_PropertySheetDisplayName>Common</_PropertySheetDisplayName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
@ -1,38 +1,32 @@
|
||||
/**
|
||||
* Set the {2} for the specified serial port.
|
||||
*
|
||||
* @param[in] port Pointer to a port structure. Must not be NULL.
|
||||
* @param[in] {0} {3}.
|
||||
* @param port Pointer to port structure.
|
||||
* @param {0} {3}.
|
||||
*
|
||||
* @return SP_OK upon success, a negative error code otherwise.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
enum sp_return sp_set_{0}(struct sp_port *port, {1} {0});
|
||||
|
||||
/**
|
||||
* Get the {2} from a port configuration.
|
||||
*
|
||||
* The user should allocate a variable of type {1} and
|
||||
* pass a pointer to this to receive the result.
|
||||
* The user should allocate a variable of type {1} and pass a pointer to this
|
||||
* to receive the result.
|
||||
*
|
||||
* @param[in] config Pointer to a configuration structure. Must not be NULL.
|
||||
* @param[out] {0}_ptr Pointer to a variable to store the result. Must not be NULL.
|
||||
* @param config Pointer to configuration structure.
|
||||
* @param {0}_ptr Pointer to variable to store result.
|
||||
*
|
||||
* @return SP_OK upon success, a negative error code otherwise.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
enum sp_return sp_get_config_{0}(const struct sp_port_config *config, {1} *{0}_ptr);
|
||||
|
||||
/**
|
||||
* Set the {2} in a port configuration.
|
||||
*
|
||||
* @param[in] config Pointer to a configuration structure. Must not be NULL.
|
||||
* @param[in] {0} {3}, or -1 to retain the current setting.
|
||||
* @param config Pointer to configuration structure.
|
||||
* @param {0} {3}, or -1 to retain current setting.
|
||||
*
|
||||
* @return SP_OK upon success, a negative error code otherwise.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
enum sp_return sp_set_config_{0}(struct sp_port_config *config, {1} {0});
|
||||
|
187
configure.ac
187
configure.ac
@ -24,158 +24,117 @@ AC_PREREQ([2.63])
|
||||
# libserialport package version number (NOT the same as shared lib version!).
|
||||
m4_define([sp_package_version_major], [0])
|
||||
m4_define([sp_package_version_minor], [1])
|
||||
m4_define([sp_package_version_micro], [1])
|
||||
m4_define([sp_package_version_micro], [0])
|
||||
m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro])
|
||||
|
||||
AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li],
|
||||
[libserialport], [http://sigrok.org/wiki/Libserialport])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([autostuff])
|
||||
AC_CONFIG_AUX_DIR([autostuff])
|
||||
|
||||
AH_BOTTOM([#if HAVE_STRUCT_TERMIOS_C_ISPEED && HAVE_STRUCT_TERMIOS_C_OSPEED
|
||||
# define HAVE_TERMIOS_SPEED 1
|
||||
#endif
|
||||
#if HAVE_STRUCT_TERMIOS2_C_ISPEED && HAVE_STRUCT_TERMIOS2_C_OSPEED
|
||||
# define HAVE_TERMIOS2_SPEED 1
|
||||
#endif])
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
# We require at least automake 1.11 (needed for 'silent rules').
|
||||
AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define check-news])
|
||||
AM_SILENT_RULES([yes])
|
||||
AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
|
||||
# Enable more compiler warnings via -Wall and -Wextra.
|
||||
CFLAGS="$CFLAGS -Wall -Wextra"
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
## SP_PROG_VERSION(program, sh-var)
|
||||
## Obtain the version of <program> and store it in <sh-var>.
|
||||
AC_DEFUN([SP_PROG_VERSION],
|
||||
[dnl
|
||||
m4_assert([$# >= 2])[]dnl
|
||||
sp_prog_ver=`$1 --version 2>&AS_MESSAGE_LOG_FD | sed 1q 2>&AS_MESSAGE_LOG_FD`
|
||||
AS_CASE([[$]?:$sp_prog_ver],
|
||||
[[0:*[0-9].[0-9]*]], [$2=$sp_prog_ver],
|
||||
[$2=unknown])[]dnl
|
||||
])
|
||||
|
||||
SP_PROG_VERSION([$CC], [sp_cc_version])
|
||||
|
||||
# Initialize libtool.
|
||||
LT_INIT
|
||||
|
||||
AC_DEFINE([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major], [.])
|
||||
AC_DEFINE([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor], [.])
|
||||
AC_DEFINE([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.])
|
||||
AC_DEFINE([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.])
|
||||
AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version])
|
||||
# Initialize pkg-config.
|
||||
# We require at least 0.22, as "Requires.private" behaviour changed there.
|
||||
PKG_PROG_PKG_CONFIG([0.22])
|
||||
|
||||
# Library version for libserialport (NOT the same as the package version).
|
||||
# Carefully read the libtool docs before updating these numbers!
|
||||
# The algorithm for determining which number to change (and how) is nontrivial!
|
||||
# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
|
||||
SP_LIB_VERSION_CURRENT=1
|
||||
SP_LIB_VERSION_CURRENT=0
|
||||
SP_LIB_VERSION_REVISION=0
|
||||
SP_LIB_VERSION_AGE=1
|
||||
AC_SUBST([SP_LIB_VERSION],
|
||||
["$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"])
|
||||
SP_LIB_VERSION_AGE=0
|
||||
SP_LIB_VERSION="$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"
|
||||
SP_LIB_LDFLAGS="-version-info $SP_LIB_VERSION"
|
||||
AC_SUBST(SP_LIB_VERSION_CURRENT)
|
||||
AC_SUBST(SP_LIB_VERSION_REVISION)
|
||||
AC_SUBST(SP_LIB_VERSION_AGE)
|
||||
AC_SUBST(SP_LIB_VERSION)
|
||||
AC_SUBST(SP_LIB_LDFLAGS)
|
||||
|
||||
AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [$SP_LIB_VERSION_CURRENT], [.])
|
||||
AC_DEFINE_UNQUOTED([SP_LIB_VERSION_REVISION], [$SP_LIB_VERSION_REVISION], [.])
|
||||
AC_DEFINE_UNQUOTED([SP_LIB_VERSION_AGE], [$SP_LIB_VERSION_AGE], [.])
|
||||
AC_DEFINE_UNQUOTED([SP_LIB_VERSION_STRING], ["$SP_LIB_VERSION"], [.])
|
||||
# Checks for libraries.
|
||||
|
||||
AM_CONDITIONAL([LINUX], [test -z "${host_os##linux*}" || test -z "${host_os##uclinux*}"])
|
||||
AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}"])
|
||||
AM_CONDITIONAL([MACOSX], [test -z "${host_os##darwin*}"])
|
||||
AM_CONDITIONAL([FREEBSD], [test -z "${host_os##freebsd*}"])
|
||||
# This variable collects the pkg-config names of all detected libs.
|
||||
# It is then used to construct the "Requires.private:" field in the
|
||||
# libserialport.pc file.
|
||||
SP_PKGLIBS=""
|
||||
|
||||
AM_COND_IF([WIN32], [SP_LIBS='-lsetupapi'], [SP_LIBS=])
|
||||
AC_SUBST([SP_LIBS])
|
||||
case $target_os in
|
||||
*linux*)
|
||||
AM_CONDITIONAL([LINUX], true)
|
||||
# On Linux libudev is currently required for enumeration.
|
||||
AC_ARG_WITH([libudev],
|
||||
[AS_HELP_STRING([--with-libudev],
|
||||
[use libudev for serial port enumeration @<:@default=check@:>@])],
|
||||
[], [with_libudev=check])
|
||||
AS_IF([test "x$with_libudev" != xno], [
|
||||
PKG_CHECK_MODULES([libudev], [libudev >= 0],
|
||||
[CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
|
||||
SP_PKGLIBS="$SP_PKGLIBS libudev"; AC_DEFINE(HAVE_LIBUDEV)])], [])
|
||||
;;
|
||||
*darwin*)
|
||||
AM_CONDITIONAL([LINUX], false)
|
||||
LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
|
||||
AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
|
||||
;;
|
||||
*)
|
||||
AM_CONDITIONAL([LINUX], false)
|
||||
esac
|
||||
|
||||
AM_COND_IF([FREEBSD], [SP_PKGLIBS='libusb-2.0'], [SP_PKGLIBS=])
|
||||
AC_SUBST([SP_PKGLIBS])
|
||||
|
||||
AM_COND_IF([MACOSX], [AC_CHECK_HEADER([IOKit/IOKitLib.h], [],
|
||||
[AC_MSG_ERROR([IOKit/IOKitLib.h not found])])])
|
||||
|
||||
AS_CASE([$host_os], [linux*|darwin*|mingw*|freebsd*],, [
|
||||
AC_DEFINE([NO_ENUMERATION], [1], [Enumeration is unsupported.])
|
||||
AC_DEFINE([NO_PORT_METADATA], [1], [Port metadata is unavailable.])
|
||||
])
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
AC_SUBST(SP_PKGLIBS)
|
||||
|
||||
# Define size_t if not defined as standard.
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
# Check for specific termios structures.
|
||||
AC_CHECK_TYPES([struct termios2],,,
|
||||
[[#include <linux/termios.h>]])
|
||||
AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed,
|
||||
struct termios2.c_ispeed, struct termios2.c_ospeed],,,
|
||||
[[#include <linux/termios.h>]])
|
||||
AC_CHECK_TYPE([struct termios2], [AC_DEFINE(HAVE_TERMIOS2, 1)], [], [[#include <linux/termios.h>]])
|
||||
AC_CHECK_TYPE([struct termiox], [AC_DEFINE(HAVE_TERMIOX, 1)], [], [[#include <linux/termios.h>]])
|
||||
AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
|
||||
[AC_DEFINE(HAVE_TERMIOS_SPEED, 1)], [], [[#include <linux/termios.h>]])
|
||||
AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
|
||||
[AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]])
|
||||
|
||||
# Check for the BOTHER definition, needed for setting arbitrary baud rates.
|
||||
# We can't just #ifdef BOTHER in the code, because of the separation between
|
||||
# code using libc headers and code using kernel termios.h headers.
|
||||
AC_CHECK_DECLS([BOTHER],,, [[#include <linux/termios.h>]])
|
||||
AC_SUBST(MAKEFLAGS, '--no-print-directory')
|
||||
AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
|
||||
|
||||
# Check for serial_struct.
|
||||
AC_CHECK_TYPES([struct serial_struct],,, [[#include <linux/serial.h>]])
|
||||
SP_PACKAGE_VERSION_MAJOR=sp_package_version_major
|
||||
SP_PACKAGE_VERSION_MINOR=sp_package_version_minor
|
||||
SP_PACKAGE_VERSION_MICRO=sp_package_version_micro
|
||||
SP_PACKAGE_VERSION=sp_package_version
|
||||
|
||||
# Check for realpath().
|
||||
AC_CHECK_FUNC([realpath], [AC_DEFINE(HAVE_REALPATH, 1, [realpath is available.])], [])
|
||||
AC_SUBST(SP_PACKAGE_VERSION_MAJOR)
|
||||
AC_SUBST(SP_PACKAGE_VERSION_MINOR)
|
||||
AC_SUBST(SP_PACKAGE_VERSION_MICRO)
|
||||
AC_SUBST(SP_PACKAGE_VERSION)
|
||||
|
||||
# Check for flock().
|
||||
AC_CHECK_HEADER([sys/file.h], [AC_DEFINE(HAVE_SYS_FILE_H, 1, [sys/file.h is available.])], [])
|
||||
AC_CHECK_FUNC([flock], [AC_DEFINE(HAVE_FLOCK, 1, [flock is available.])], [])
|
||||
|
||||
# Check for clock_gettime().
|
||||
AC_CHECK_FUNC([clock_gettime],
|
||||
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [clock_gettime is available.])], [])
|
||||
|
||||
AC_CACHE_CHECK([for visibility control], [sp_cv_visibility_control], [
|
||||
sp_saved_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
|
||||
[[__attribute__((visibility("hidden"))) void foo(void) {}]])],
|
||||
[sp_cv_visibility_control=attribute],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE(
|
||||
[[__declspec(dllexport) void foo(void) {}]])],
|
||||
[sp_cv_visibility_control=declspec],
|
||||
[sp_cv_visibility_control=none])])
|
||||
CFLAGS=$sp_saved_CFLAGS
|
||||
])
|
||||
AS_CASE([$sp_cv_visibility_control],
|
||||
[attribute], [SP_API='__attribute__((visibility("default")))'
|
||||
SP_PRIV='__attribute__((visibility("hidden")))'],
|
||||
[declspec], [SP_API='__declspec(dllexport)' SP_PRIV=],
|
||||
[SP_API= SP_PRIV=])
|
||||
AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions])
|
||||
AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions])
|
||||
|
||||
AC_CONFIG_FILES([Makefile libserialport.pc])
|
||||
AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
cat >&AS_MESSAGE_FD <<_EOF
|
||||
|
||||
libserialport configuration summary:
|
||||
|
||||
- Package version................. $SP_PACKAGE_VERSION
|
||||
- Library ABI version............. $SP_LIB_VERSION
|
||||
- Prefix.......................... $prefix
|
||||
- Building on..................... $build
|
||||
- Building for.................... $host
|
||||
- Building shared / static........ $enable_shared / $enable_static
|
||||
|
||||
Compile configuration:
|
||||
- C compiler...................... $CC
|
||||
- C compiler version.............. $sp_cc_version
|
||||
- C compiler flags................ $CFLAGS
|
||||
- Linker flags.................... $LDFLAGS
|
||||
|
||||
_EOF
|
||||
echo
|
||||
echo "libserialport configuration summary:"
|
||||
echo
|
||||
echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION"
|
||||
echo " - Library version (current:revision:age): $SP_LIB_VERSION"
|
||||
echo " - Prefix: $prefix"
|
||||
echo " - Building on: $build"
|
||||
echo " - Building for: $host"
|
||||
echo
|
||||
|
17
debug.props
17
debug.props
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_PropertySheetDisplayName>Debug</_PropertySheetDisplayName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>LIBSERIALPORT_MSBUILD;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
6
examples/.gitignore
vendored
6
examples/.gitignore
vendored
@ -1,6 +0,0 @@
|
||||
await_events
|
||||
handle_errors
|
||||
list_ports
|
||||
port_info
|
||||
port_config
|
||||
send_receive
|
@ -1,20 +0,0 @@
|
||||
# A simple Makefile to build the examples in this directory.
|
||||
#
|
||||
# This example file is released to the public domain.
|
||||
|
||||
CC = gcc
|
||||
PKG_CONFIG = pkg-config
|
||||
CFLAGS = -g -Wall $(shell $(PKG_CONFIG) --cflags libserialport)
|
||||
LIBS = $(shell $(PKG_CONFIG) --libs libserialport)
|
||||
|
||||
SOURCES = $(wildcard *.c)
|
||||
|
||||
BINARIES = $(SOURCES:.c=)
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) $< $(LIBS) -o $@
|
||||
|
||||
all: $(BINARIES)
|
||||
|
||||
clean:
|
||||
rm $(BINARIES)
|
@ -1,33 +0,0 @@
|
||||
This directory contains example programs showing how to use libserialport.
|
||||
|
||||
The examples currently included are:
|
||||
|
||||
list_ports.c - displays a list of ports on the system.
|
||||
port_info.c - displays info about a particular port on the system.
|
||||
port_config.c - sets and displays configuration settings on a port.
|
||||
send_receive.c - loopback test sending & receiving data on 1 or 2 ports.
|
||||
await_events.c - awaits receive events on multiple ports simultaneously.
|
||||
handle_errors.c - demonstrates handling errors returned from the library.
|
||||
|
||||
The programs themselves are completely OS-independent, and require only a
|
||||
C compiler and libserialport.
|
||||
|
||||
The 'examples.sln' file is a solution file for Microsoft Visual Studio 2019
|
||||
which will build libserialport and all of the example programs.
|
||||
|
||||
The Makefile in this directory will attempt to build all the examples,
|
||||
using 'gcc' to compile them and 'pkg-config' to discover the include
|
||||
paths and linker settings needed to build with libserialport. It provides
|
||||
a minimal example of how to write a Makefile to build a program using
|
||||
libserialport.
|
||||
|
||||
If you have make, gcc, pkg-config and libserialport installed correctly
|
||||
then running 'make' should build the example programs in this directory.
|
||||
If this doesn't work, you may need to modify the Makefile or set necessary
|
||||
paths in your environment to suit your system.
|
||||
|
||||
You can also build these examples using any other compiler, IDE or build
|
||||
system. You just need the libserialport.h header available to compile them,
|
||||
and the libserialport library available to link and run them.
|
||||
|
||||
These example files are hereby released into the public domain by the author.
|
@ -1,101 +0,0 @@
|
||||
#include <libserialport.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Example of how to wait for events on multiple ports.
|
||||
*
|
||||
* This example file is released to the public domain. */
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Get the port names from the command line. */
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s <port name>...\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
int num_ports = argc - 1;
|
||||
char **port_names = argv + 1;
|
||||
|
||||
/* The ports we will use. */
|
||||
struct sp_port **ports = malloc(num_ports * sizeof(struct sp_port *));
|
||||
if (!ports)
|
||||
abort();
|
||||
|
||||
/* The set of events we will wait for. */
|
||||
struct sp_event_set *event_set;
|
||||
|
||||
/* Allocate the event set. */
|
||||
check(sp_new_event_set(&event_set));
|
||||
|
||||
/* Open and configure each port, and then add its RX event
|
||||
* to the event set. */
|
||||
for (int i = 0; i < num_ports; i++) {
|
||||
printf("Looking for port %s.\n", port_names[i]);
|
||||
check(sp_get_port_by_name(port_names[i], &ports[i]));
|
||||
|
||||
printf("Opening port.\n");
|
||||
check(sp_open(ports[i], SP_MODE_READ));
|
||||
|
||||
printf("Setting port to 9600 8N1, no flow control.\n");
|
||||
check(sp_set_baudrate(ports[i], 9600));
|
||||
check(sp_set_bits(ports[i], 8));
|
||||
check(sp_set_parity(ports[i], SP_PARITY_NONE));
|
||||
check(sp_set_stopbits(ports[i], 1));
|
||||
check(sp_set_flowcontrol(ports[i], SP_FLOWCONTROL_NONE));
|
||||
|
||||
printf("Adding port RX event to event set.\n");
|
||||
check(sp_add_port_events(event_set, ports[i], SP_EVENT_RX_READY));
|
||||
}
|
||||
|
||||
/* Now we can call sp_wait() to await any event in the set.
|
||||
* It will return when an event occurs, or the timeout elapses. */
|
||||
printf("Waiting up to 5 seconds for RX on any port...\n");
|
||||
check(sp_wait(event_set, 5000));
|
||||
|
||||
/* Iterate over ports to see which have data waiting. */
|
||||
for (int i = 0; i < num_ports; i++) {
|
||||
/* Get number of bytes waiting. */
|
||||
int bytes_waiting = check(sp_input_waiting(ports[i]));
|
||||
printf("Port %s: %d bytes received.\n",
|
||||
sp_get_port_name(ports[i]), bytes_waiting);
|
||||
}
|
||||
|
||||
/* Close ports and free resources. */
|
||||
sp_free_event_set(event_set);
|
||||
for (int i = 0; i < num_ports; i++) {
|
||||
check(sp_close(ports[i]));
|
||||
sp_free_port(ports[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result)
|
||||
{
|
||||
/* For this example we'll just exit on any error by calling abort(). */
|
||||
char *error_message;
|
||||
|
||||
switch (result) {
|
||||
case SP_ERR_ARG:
|
||||
printf("Error: Invalid argument.\n");
|
||||
abort();
|
||||
case SP_ERR_FAIL:
|
||||
error_message = sp_last_error_message();
|
||||
printf("Error: Failed: %s\n", error_message);
|
||||
sp_free_error_message(error_message);
|
||||
abort();
|
||||
case SP_ERR_SUPP:
|
||||
printf("Error: Not supported.\n");
|
||||
abort();
|
||||
case SP_ERR_MEM:
|
||||
printf("Error: Couldn't allocate memory.\n");
|
||||
abort();
|
||||
case SP_OK:
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29613.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "list_ports", "projects\list_ports.vcxproj", "{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "port_info", "projects\port_info.vcxproj", "{4BD48C7E-E097-4580-BC63-B4F586D53B8A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libserialport", "..\libserialport.vcxproj", "{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "port_config", "projects\port_config.vcxproj", "{6CD526C6-0710-4ECA-BE23-6F85032C95F4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "await_events", "projects\await_events.vcxproj", "{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "handle_errors", "projects\handle_errors.vcxproj", "{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "send_receive", "projects\send_receive.vcxproj", "{F0B68251-C73A-4B7F-AA62-6778586A72A0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Debug|x64.Build.0 = Debug|x64
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Debug|x86.Build.0 = Debug|Win32
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Release|x64.ActiveCfg = Release|x64
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Release|x64.Build.0 = Release|x64
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Release|x86.ActiveCfg = Release|Win32
|
||||
{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}.Release|x86.Build.0 = Release|Win32
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Debug|x64.Build.0 = Debug|x64
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Release|x64.ActiveCfg = Release|x64
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Release|x64.Build.0 = Release|x64
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Release|x86.ActiveCfg = Release|Win32
|
||||
{4BD48C7E-E097-4580-BC63-B4F586D53B8A}.Release|x86.Build.0 = Release|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x64.Build.0 = Debug|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x64.ActiveCfg = Release|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x64.Build.0 = Release|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x86.Build.0 = Release|Win32
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Debug|x64.Build.0 = Debug|x64
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Release|x64.ActiveCfg = Release|x64
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Release|x64.Build.0 = Release|x64
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{6CD526C6-0710-4ECA-BE23-6F85032C95F4}.Release|x86.Build.0 = Release|Win32
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Debug|x64.Build.0 = Debug|x64
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Release|x64.ActiveCfg = Release|x64
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Release|x64.Build.0 = Release|x64
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}.Release|x86.Build.0 = Release|Win32
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Debug|x64.Build.0 = Debug|x64
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Release|x64.ActiveCfg = Release|x64
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Release|x64.Build.0 = Release|x64
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}.Release|x86.Build.0 = Release|Win32
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Debug|x64.Build.0 = Debug|x64
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Debug|x86.Build.0 = Debug|Win32
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Release|x64.ActiveCfg = Release|x64
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Release|x64.Build.0 = Release|x64
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F0B68251-C73A-4B7F-AA62-6778586A72A0}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {EEED7125-B08F-4EB9-8F10-F036CCD5F4CF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,117 +0,0 @@
|
||||
#include <libserialport.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Example of how to handle errors from libserialport.
|
||||
*
|
||||
* This example file is released to the public domain. */
|
||||
|
||||
/* Pointers used in the program to resources that may need to be freed. */
|
||||
struct sp_port **port_list = NULL;
|
||||
struct sp_port_config *config = NULL;
|
||||
struct sp_port *port = NULL;
|
||||
|
||||
/* Example of a function to clean up and exit the program with a given return code. */
|
||||
void end_program(int return_code)
|
||||
{
|
||||
/* Free any structures we allocated. */
|
||||
if (port_list != NULL)
|
||||
sp_free_port_list(port_list);
|
||||
if (config != NULL)
|
||||
sp_free_config(config);
|
||||
if (port != NULL)
|
||||
sp_free_port(port);
|
||||
|
||||
/* Exit with the given return code. */
|
||||
exit(return_code);
|
||||
}
|
||||
|
||||
/* Example of a helper function for error handling. */
|
||||
int check(enum sp_return result)
|
||||
{
|
||||
int error_code;
|
||||
char *error_message;
|
||||
|
||||
switch (result) {
|
||||
|
||||
/* Handle each of the four negative error codes that can be returned.
|
||||
*
|
||||
* In this example, we will end the program on any error, using
|
||||
* a different return code for each possible class of error. */
|
||||
|
||||
case SP_ERR_ARG:
|
||||
/* When SP_ERR_ARG is returned, there was a problem with one
|
||||
* or more of the arguments passed to the function, e.g. a null
|
||||
* pointer or an invalid value. This generally implies a bug in
|
||||
* the calling code. */
|
||||
printf("Error: Invalid argument.\n");
|
||||
end_program(1);
|
||||
|
||||
case SP_ERR_FAIL:
|
||||
/* When SP_ERR_FAIL is returned, there was an error from the OS,
|
||||
* which we can obtain the error code and message for. These
|
||||
* calls must be made in the same thread as the call that
|
||||
* returned SP_ERR_FAIL, and before any other system functions
|
||||
* are called in that thread, or they may not return the
|
||||
* correct results. */
|
||||
error_code = sp_last_error_code();
|
||||
error_message = sp_last_error_message();
|
||||
printf("Error: Failed: OS error code: %d, message: '%s'\n",
|
||||
error_code, error_message);
|
||||
/* The error message should be freed after use. */
|
||||
sp_free_error_message(error_message);
|
||||
end_program(2);
|
||||
|
||||
case SP_ERR_SUPP:
|
||||
/* When SP_ERR_SUPP is returned, the function was asked to do
|
||||
* something that isn't supported by the current OS or device,
|
||||
* or that libserialport doesn't know how to do in the current
|
||||
* version. */
|
||||
printf("Error: Not supported.\n");
|
||||
end_program(3);
|
||||
|
||||
case SP_ERR_MEM:
|
||||
/* When SP_ERR_MEM is returned, libserialport wasn't able to
|
||||
* allocate some memory it needed. Since the library doesn't
|
||||
* normally use any large data structures, this probably means
|
||||
* the system is critically low on memory and recovery will
|
||||
* require very careful handling. The library itself will
|
||||
* always try to handle any allocation failure safely.
|
||||
*
|
||||
* In this example, we'll just try to exit gracefully without
|
||||
* calling printf, which might need to allocate further memory. */
|
||||
end_program(4);
|
||||
|
||||
case SP_OK:
|
||||
default:
|
||||
/* A return value of SP_OK, defined as zero, means that the
|
||||
* operation succeeded. */
|
||||
printf("Operation succeeded.\n");
|
||||
|
||||
/* Some fuctions can also return a value greater than zero to
|
||||
* indicate a numeric result, such as the number of bytes read by
|
||||
* sp_blocking_read(). So when writing an error handling wrapper
|
||||
* function like this one, it's helpful to return the result so
|
||||
* that it can be used. */
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Call some functions that should not result in errors. */
|
||||
|
||||
printf("Getting list of ports.\n");
|
||||
check(sp_list_ports(&port_list));
|
||||
|
||||
printf("Creating a new port configuration.\n");
|
||||
check(sp_new_config(&config));
|
||||
|
||||
/* Now make a function call that will result in an error. */
|
||||
|
||||
printf("Trying to find a port that doesn't exist.\n");
|
||||
check(sp_get_port_by_name("NON-EXISTENT-PORT", &port));
|
||||
|
||||
/* We could now clean up and exit normally if an error hadn't occured. */
|
||||
end_program(0);
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
#include <libserialport.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Example of how to get a list of serial ports on the system.
|
||||
*
|
||||
* This example file is released to the public domain. */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* A pointer to a null-terminated array of pointers to
|
||||
* struct sp_port, which will contain the ports found.*/
|
||||
struct sp_port **port_list;
|
||||
|
||||
printf("Getting port list.\n");
|
||||
|
||||
/* Call sp_list_ports() to get the ports. The port_list
|
||||
* pointer will be updated to refer to the array created. */
|
||||
enum sp_return result = sp_list_ports(&port_list);
|
||||
|
||||
if (result != SP_OK) {
|
||||
printf("sp_list_ports() failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Iterate through the ports. When port_list[i] is NULL
|
||||
* this indicates the end of the list. */
|
||||
int i;
|
||||
for (i = 0; port_list[i] != NULL; i++) {
|
||||
struct sp_port *port = port_list[i];
|
||||
|
||||
/* Get the name of the port. */
|
||||
char *port_name = sp_get_port_name(port);
|
||||
|
||||
printf("Found port: %s\n", port_name);
|
||||
}
|
||||
|
||||
printf("Found %d ports.\n", i);
|
||||
|
||||
printf("Freeing port list.\n");
|
||||
|
||||
/* Free the array created by sp_list_ports(). */
|
||||
sp_free_port_list(port_list);
|
||||
|
||||
/* Note that this will also free all the sp_port structures
|
||||
* it points to. If you want to keep one of them (e.g. to
|
||||
* use that port in the rest of your program), take a copy
|
||||
* of it first using sp_copy_port(). */
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
#include <libserialport.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Example of how to configure a serial port.
|
||||
*
|
||||
* This example file is released to the public domain. */
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result);
|
||||
|
||||
/* Helper function to give a name for each parity mode. */
|
||||
const char *parity_name(enum sp_parity parity);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Get the port name from the command line. */
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s <port name>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
char *port_name = argv[1];
|
||||
|
||||
/* A pointer to a struct sp_port, which will refer to
|
||||
* the port found. */
|
||||
struct sp_port *port;
|
||||
|
||||
printf("Looking for port %s.\n", port_name);
|
||||
|
||||
/* Call sp_get_port_by_name() to find the port. The port
|
||||
* pointer will be updated to refer to the port found. */
|
||||
check(sp_get_port_by_name(port_name, &port));
|
||||
|
||||
/* Display some basic information about the port. */
|
||||
printf("Port name: %s\n", sp_get_port_name(port));
|
||||
printf("Description: %s\n", sp_get_port_description(port));
|
||||
|
||||
/* The port must be open to access its configuration. */
|
||||
printf("Opening port.\n");
|
||||
check(sp_open(port, SP_MODE_READ_WRITE));
|
||||
|
||||
/* There are two ways to access a port's configuration:
|
||||
*
|
||||
* 1. You can read and write a whole configuration (all settings at
|
||||
* once) using sp_get_config() and sp_set_config(). This is handy
|
||||
* if you want to change between some preset combinations, or save
|
||||
* and restore an existing configuration. It also ensures the
|
||||
* changes are made together, via an efficient set of calls into
|
||||
* the OS - in some cases a single system call can be used.
|
||||
*
|
||||
* Use accessor functions like sp_get_config_baudrate() and
|
||||
* sp_set_config_baudrate() to get and set individual settings
|
||||
* from a configuration.
|
||||
*
|
||||
* Configurations are allocated using sp_new_config() and freed
|
||||
* with sp_free_config(). You need to manage them yourself.
|
||||
*
|
||||
* 2. As a shortcut, you can set individual settings on a port
|
||||
* directly by calling functions like sp_set_baudrate() and
|
||||
* sp_set_parity(). This saves you the work of allocating
|
||||
* a temporary config, setting it up, applying it to a port
|
||||
* and then freeing it.
|
||||
*
|
||||
* In this example we'll do a bit of both: apply some initial settings
|
||||
* to the port, read out that config and display it, then switch to a
|
||||
* different configuration and back using sp_set_config(). */
|
||||
|
||||
/* First let's set some initial settings directly on the port.
|
||||
*
|
||||
* You should always configure all settings before using a port.
|
||||
* There are no "default" settings applied by libserialport.
|
||||
* When you open a port it has the defaults from the OS or driver,
|
||||
* or the settings left over by the last program to use it. */
|
||||
printf("Setting port to 115200 8N1, no flow control.\n");
|
||||
check(sp_set_baudrate(port, 115200));
|
||||
check(sp_set_bits(port, 8));
|
||||
check(sp_set_parity(port, SP_PARITY_NONE));
|
||||
check(sp_set_stopbits(port, 1));
|
||||
check(sp_set_flowcontrol(port, SP_FLOWCONTROL_NONE));
|
||||
|
||||
/* A pointer to a struct sp_port_config, which we'll use for the config
|
||||
* read back from the port. The pointer will be set by sp_new_config(). */
|
||||
struct sp_port_config *initial_config;
|
||||
|
||||
/* Allocate a configuration for us to read the port config into. */
|
||||
check(sp_new_config(&initial_config));
|
||||
|
||||
/* Read the current config from the port into that configuration. */
|
||||
check(sp_get_config(port, initial_config));
|
||||
|
||||
/* Display some of the settings read back from the port. */
|
||||
int baudrate, bits, stopbits;
|
||||
enum sp_parity parity;
|
||||
check(sp_get_config_baudrate(initial_config, &baudrate));
|
||||
check(sp_get_config_bits(initial_config, &bits));
|
||||
check(sp_get_config_stopbits(initial_config, &stopbits));
|
||||
check(sp_get_config_parity(initial_config, &parity));
|
||||
printf("Baudrate: %d, data bits: %d, parity: %s, stop bits: %d\n",
|
||||
baudrate, bits, parity_name(parity), stopbits);
|
||||
|
||||
/* Create a different configuration to have ready for use. */
|
||||
printf("Creating new config for 9600 7E2, XON/XOFF flow control.\n");
|
||||
struct sp_port_config *other_config;
|
||||
check(sp_new_config(&other_config));
|
||||
check(sp_set_config_baudrate(other_config, 9600));
|
||||
check(sp_set_config_bits(other_config, 7));
|
||||
check(sp_set_config_parity(other_config, SP_PARITY_EVEN));
|
||||
check(sp_set_config_stopbits(other_config, 2));
|
||||
check(sp_set_config_flowcontrol(other_config, SP_FLOWCONTROL_XONXOFF));
|
||||
|
||||
/* We can apply the new config to the port in one call. */
|
||||
printf("Applying new configuration.\n");
|
||||
check(sp_set_config(port, other_config));
|
||||
|
||||
/* And now switch back to our original config. */
|
||||
printf("Setting port back to previous config.\n");
|
||||
check(sp_set_config(port, initial_config));
|
||||
|
||||
/* Now clean up by closing the port and freeing structures. */
|
||||
check(sp_close(port));
|
||||
sp_free_port(port);
|
||||
sp_free_config(initial_config);
|
||||
sp_free_config(other_config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result)
|
||||
{
|
||||
/* For this example we'll just exit on any error by calling abort(). */
|
||||
char *error_message;
|
||||
|
||||
switch (result) {
|
||||
case SP_ERR_ARG:
|
||||
printf("Error: Invalid argument.\n");
|
||||
abort();
|
||||
case SP_ERR_FAIL:
|
||||
error_message = sp_last_error_message();
|
||||
printf("Error: Failed: %s\n", error_message);
|
||||
sp_free_error_message(error_message);
|
||||
abort();
|
||||
case SP_ERR_SUPP:
|
||||
printf("Error: Not supported.\n");
|
||||
abort();
|
||||
case SP_ERR_MEM:
|
||||
printf("Error: Couldn't allocate memory.\n");
|
||||
abort();
|
||||
case SP_OK:
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/* Helper function to give a name for each parity mode. */
|
||||
const char *parity_name(enum sp_parity parity)
|
||||
{
|
||||
switch (parity) {
|
||||
case SP_PARITY_INVALID:
|
||||
return "(Invalid)";
|
||||
case SP_PARITY_NONE:
|
||||
return "None";
|
||||
case SP_PARITY_ODD:
|
||||
return "Odd";
|
||||
case SP_PARITY_EVEN:
|
||||
return "Even";
|
||||
case SP_PARITY_MARK:
|
||||
return "Mark";
|
||||
case SP_PARITY_SPACE:
|
||||
return "Space";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
#include <libserialport.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Example of how to get information about a serial port.
|
||||
*
|
||||
* This example file is released to the public domain. */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Get the port name from the command line. */
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s <port name>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
char *port_name = argv[1];
|
||||
|
||||
/* A pointer to a struct sp_port, which will refer to
|
||||
* the port found. */
|
||||
struct sp_port *port;
|
||||
|
||||
printf("Looking for port %s.\n", port_name);
|
||||
|
||||
/* Call sp_get_port_by_name() to find the port. The port
|
||||
* pointer will be updated to refer to the port found. */
|
||||
enum sp_return result = sp_get_port_by_name(port_name, &port);
|
||||
|
||||
if (result != SP_OK) {
|
||||
printf("sp_get_port_by_name() failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Display some basic information about the port. */
|
||||
printf("Port name: %s\n", sp_get_port_name(port));
|
||||
printf("Description: %s\n", sp_get_port_description(port));
|
||||
|
||||
/* Identify the transport which this port is connected through,
|
||||
* e.g. native port, USB or Bluetooth. */
|
||||
enum sp_transport transport = sp_get_port_transport(port);
|
||||
|
||||
if (transport == SP_TRANSPORT_NATIVE) {
|
||||
/* This is a "native" port, usually directly connected
|
||||
* to the system rather than some external interface. */
|
||||
printf("Type: Native\n");
|
||||
} else if (transport == SP_TRANSPORT_USB) {
|
||||
/* This is a USB to serial converter of some kind. */
|
||||
printf("Type: USB\n");
|
||||
|
||||
/* Display string information from the USB descriptors. */
|
||||
printf("Manufacturer: %s\n", sp_get_port_usb_manufacturer(port));
|
||||
printf("Product: %s\n", sp_get_port_usb_product(port));
|
||||
printf("Serial: %s\n", sp_get_port_usb_serial(port));
|
||||
|
||||
/* Display USB vendor and product IDs. */
|
||||
int usb_vid, usb_pid;
|
||||
sp_get_port_usb_vid_pid(port, &usb_vid, &usb_pid);
|
||||
printf("VID: %04X PID: %04X\n", usb_vid, usb_pid);
|
||||
|
||||
/* Display bus and address. */
|
||||
int usb_bus, usb_address;
|
||||
sp_get_port_usb_bus_address(port, &usb_bus, &usb_address);
|
||||
printf("Bus: %d Address: %d\n", usb_bus, usb_address);
|
||||
} else if (transport == SP_TRANSPORT_BLUETOOTH) {
|
||||
/* This is a Bluetooth serial port. */
|
||||
printf("Type: Bluetooth\n");
|
||||
|
||||
/* Display Bluetooth MAC address. */
|
||||
printf("MAC: %s\n", sp_get_port_bluetooth_address(port));
|
||||
}
|
||||
|
||||
printf("Freeing port.\n");
|
||||
|
||||
/* Free the port structure created by sp_get_port_by_name(). */
|
||||
sp_free_port(port);
|
||||
|
||||
/* Note that this will also free the port name and other
|
||||
* strings retrieved from the port structure. If you want
|
||||
* to keep these, copy them before freeing the port. */
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\await_events.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libserialport.vcxproj">
|
||||
<Project>{1c8eaaf2-133e-4cee-8981-4a903a8b3935}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{E757BAB5-C79B-49AD-B9C1-B81276B0A6FA}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>listports</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\await_events.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_PropertySheetDisplayName>Common</_PropertySheetDisplayName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
@ -1,167 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\handle_errors.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libserialport.vcxproj">
|
||||
<Project>{1c8eaaf2-133e-4cee-8981-4a903a8b3935}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{09EC5FFB-4DB0-4FE8-BF1E-050F03EC7ED4}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>listports</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\handle_errors.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,167 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\list_ports.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libserialport.vcxproj">
|
||||
<Project>{1c8eaaf2-133e-4cee-8981-4a903a8b3935}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{4447C677-0B59-4E1A-9EFD-50D0BE8A0F64}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>listports</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\list_ports.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,167 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\port_config.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libserialport.vcxproj">
|
||||
<Project>{1c8eaaf2-133e-4cee-8981-4a903a8b3935}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{6CD526C6-0710-4ECA-BE23-6F85032C95F4}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>listports</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\port_config.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,167 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\port_info.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libserialport.vcxproj">
|
||||
<Project>{1c8eaaf2-133e-4cee-8981-4a903a8b3935}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{4BD48C7E-E097-4580-BC63-B4F586D53B8A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>listports</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\port_info.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,167 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\send_receive.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libserialport.vcxproj">
|
||||
<Project>{1c8eaaf2-133e-4cee-8981-4a903a8b3935}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{F0B68251-C73A-4B7F-AA62-6778586A72A0}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>listports</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\send_receive.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,139 +0,0 @@
|
||||
#include <libserialport.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Example of how to send and receive data.
|
||||
*
|
||||
* This example file is released to the public domain. */
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* This example can be used with one or two ports. With one port, it
|
||||
* will send data and try to receive it on the same port. This can be
|
||||
* done by connecting a single wire between the TX and RX pins of the
|
||||
* port.
|
||||
*
|
||||
* Alternatively it can be used with two serial ports connected to each
|
||||
* other, so that data can be sent on one and received on the other.
|
||||
* This can be done with two ports with TX/RX cross-connected, e.g. by
|
||||
* a "null modem" cable, or with a pair of interconnected virtual ports,
|
||||
* such as those created by com0com on Windows or tty0tty on Linux. */
|
||||
|
||||
/* Get the port names from the command line. */
|
||||
if (argc < 2 || argc > 3) {
|
||||
printf("Usage: %s <port 1> [<port 2>]\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
int num_ports = argc - 1;
|
||||
char **port_names = argv + 1;
|
||||
|
||||
/* The ports we will use. */
|
||||
struct sp_port *ports[2];
|
||||
|
||||
/* Open and configure each port. */
|
||||
for (int i = 0; i < num_ports; i++) {
|
||||
printf("Looking for port %s.\n", port_names[i]);
|
||||
check(sp_get_port_by_name(port_names[i], &ports[i]));
|
||||
|
||||
printf("Opening port.\n");
|
||||
check(sp_open(ports[i], SP_MODE_READ_WRITE));
|
||||
|
||||
printf("Setting port to 9600 8N1, no flow control.\n");
|
||||
check(sp_set_baudrate(ports[i], 9600));
|
||||
check(sp_set_bits(ports[i], 8));
|
||||
check(sp_set_parity(ports[i], SP_PARITY_NONE));
|
||||
check(sp_set_stopbits(ports[i], 1));
|
||||
check(sp_set_flowcontrol(ports[i], SP_FLOWCONTROL_NONE));
|
||||
}
|
||||
|
||||
/* Now send some data on each port and receive it back. */
|
||||
for (int tx = 0; tx < num_ports; tx++) {
|
||||
/* Get the ports to send and receive on. */
|
||||
int rx = num_ports == 1 ? 0 : ((tx == 0) ? 1 : 0);
|
||||
struct sp_port *tx_port = ports[tx];
|
||||
struct sp_port *rx_port = ports[rx];
|
||||
|
||||
/* The data we will send. */
|
||||
char *data = "Hello!";
|
||||
int size = strlen(data);
|
||||
|
||||
/* We'll allow a 1 second timeout for send and receive. */
|
||||
unsigned int timeout = 1000;
|
||||
|
||||
/* On success, sp_blocking_write() and sp_blocking_read()
|
||||
* return the number of bytes sent/received before the
|
||||
* timeout expired. We'll store that result here. */
|
||||
int result;
|
||||
|
||||
/* Send data. */
|
||||
printf("Sending '%s' (%d bytes) on port %s.\n",
|
||||
data, size, sp_get_port_name(tx_port));
|
||||
result = check(sp_blocking_write(tx_port, data, size, timeout));
|
||||
|
||||
/* Check whether we sent all of the data. */
|
||||
if (result == size)
|
||||
printf("Sent %d bytes successfully.\n", size);
|
||||
else
|
||||
printf("Timed out, %d/%d bytes sent.\n", result, size);
|
||||
|
||||
/* Allocate a buffer to receive data. */
|
||||
char *buf = malloc(size + 1);
|
||||
|
||||
/* Try to receive the data on the other port. */
|
||||
printf("Receiving %d bytes on port %s.\n",
|
||||
size, sp_get_port_name(rx_port));
|
||||
result = check(sp_blocking_read(rx_port, buf, size, timeout));
|
||||
|
||||
/* Check whether we received the number of bytes we wanted. */
|
||||
if (result == size)
|
||||
printf("Received %d bytes successfully.\n", size);
|
||||
else
|
||||
printf("Timed out, %d/%d bytes received.\n", result, size);
|
||||
|
||||
/* Check if we received the same data we sent. */
|
||||
buf[result] = '\0';
|
||||
printf("Received '%s'.\n", buf);
|
||||
|
||||
/* Free receive buffer. */
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* Close ports and free resources. */
|
||||
for (int i = 0; i < num_ports; i++) {
|
||||
check(sp_close(ports[i]));
|
||||
sp_free_port(ports[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result)
|
||||
{
|
||||
/* For this example we'll just exit on any error by calling abort(). */
|
||||
char *error_message;
|
||||
|
||||
switch (result) {
|
||||
case SP_ERR_ARG:
|
||||
printf("Error: Invalid argument.\n");
|
||||
abort();
|
||||
case SP_ERR_FAIL:
|
||||
error_message = sp_last_error_message();
|
||||
printf("Error: Failed: %s\n", error_message);
|
||||
sp_free_error_message(error_message);
|
||||
abort();
|
||||
case SP_ERR_SUPP:
|
||||
printf("Error: Not supported.\n");
|
||||
abort();
|
||||
case SP_ERR_MEM:
|
||||
printf("Error: Couldn't allocate memory.\n");
|
||||
abort();
|
||||
case SP_OK:
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
383
freebsd.c
383
freebsd.c
@ -1,383 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libserialport project.
|
||||
*
|
||||
* Copyright (C) 2015 Uffe Jakobsen <uffe@uffe.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FreeBSD platform specific serial port information:
|
||||
*
|
||||
* FreeBSD has two device nodes for each serial port:
|
||||
*
|
||||
* 1) a call-in port
|
||||
* 2) a call-out port
|
||||
*
|
||||
* Quoting FreeBSD Handbook section 26.2.1
|
||||
* (https://www.freebsd.org/doc/handbook/serial.html)
|
||||
*
|
||||
* In FreeBSD, each serial port is accessed through an entry in /dev.
|
||||
* There are two different kinds of entries:
|
||||
*
|
||||
* 1) Call-in ports are named /dev/ttyuN where N is the port number,
|
||||
* starting from zero. If a terminal is connected to the first serial port
|
||||
* (COM1), use /dev/ttyu0 to refer to the terminal. If the terminal is on
|
||||
* the second serial port (COM2), use /dev/ttyu1, and so forth.
|
||||
* Generally, the call-in port is used for terminals. Call-in ports require
|
||||
* that the serial line assert the "Data Carrier Detect" signal to work
|
||||
* correctly.
|
||||
*
|
||||
* 2) Call-out ports are named /dev/cuauN on FreeBSD versions 10.x and higher
|
||||
* and /dev/cuadN on FreeBSD versions 9.x and lower. Call-out ports are
|
||||
* usually not used for terminals, but are used for modems. The call-out
|
||||
* port can be used if the serial cable or the terminal does not support
|
||||
* the "Data Carrier Detect" signal.
|
||||
*
|
||||
* FreeBSD also provides initialization devices (/dev/ttyuN.init and
|
||||
* /dev/cuauN.init or /dev/cuadN.init) and locking devices (/dev/ttyuN.lock
|
||||
* and /dev/cuauN.lock or /dev/cuadN.lock). The initialization devices are
|
||||
* used to initialize communications port parameters each time a port is
|
||||
* opened, such as crtscts for modems which use RTS/CTS signaling for flow
|
||||
* control. The locking devices are used to lock flags on ports to prevent
|
||||
* users or programs changing certain parameters.
|
||||
*
|
||||
* In line with the above device naming USB-serial devices have
|
||||
* the following naming:
|
||||
*
|
||||
* 1) call-in ports: /dev/ttyUN where N is the port number
|
||||
* 2) call-out ports: /dev/cuaUN where N is the port number
|
||||
*
|
||||
* See also: ucom(4), https://www.freebsd.org/cgi/man.cgi?query=ucom
|
||||
*
|
||||
* Getting USB serial port device description:
|
||||
*
|
||||
* In order to query USB serial ports for device description - the mapping
|
||||
* between the kernel device driver instances must be correlated with the
|
||||
* above mentioned device nodes.
|
||||
*
|
||||
* 1) For each USB-serial port (/dev/cuaUN) use libusb to lookup the device
|
||||
* description and the name of the kernel device driver instance.
|
||||
* 2) Query sysctl for the kernel device driver instance info.
|
||||
* 3) Derive the ttyname and (serial) port count for the kernel device
|
||||
* driver instance.
|
||||
* 4) If sysctl ttyname and port matches /dev/cuaUN apply the libusb
|
||||
* device description.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <dirent.h>
|
||||
#include <libusb20.h>
|
||||
#include <libusb20_desc.h>
|
||||
#include "libserialport.h"
|
||||
#include "libserialport_internal.h"
|
||||
|
||||
#define DEV_CUA_PATH "/dev/cua"
|
||||
|
||||
//#define DBG(...) printf(__VA_ARGS__)
|
||||
#define DBG(...)
|
||||
|
||||
static char *strrspn(const char *s, const char *charset)
|
||||
{
|
||||
char *t = (char *)s + strlen(s);
|
||||
while (t != (char *)s)
|
||||
if (!strchr(charset, *(--t)))
|
||||
return ++t;
|
||||
return t;
|
||||
}
|
||||
|
||||
static int strend(const char *str, const char *pattern)
|
||||
{
|
||||
size_t slen = strlen(str);
|
||||
size_t plen = strlen(pattern);
|
||||
if (slen >= plen)
|
||||
return (!memcmp(pattern, (str + slen - plen), plen));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int libusb_query_port(struct libusb20_device *dev, int idx,
|
||||
char **drv_name_str, char **drv_inst_str)
|
||||
{
|
||||
int rc;
|
||||
char *j;
|
||||
char sbuf[FILENAME_MAX];
|
||||
|
||||
if (!drv_name_str || !drv_inst_str)
|
||||
return -1;
|
||||
|
||||
rc = libusb20_dev_kernel_driver_active(dev, idx);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
sbuf[0] = 0;
|
||||
libusb20_dev_get_iface_desc(dev, idx, (char *)&sbuf,
|
||||
(uint8_t)sizeof(sbuf) - 1);
|
||||
if (sbuf[0] == 0)
|
||||
return rc;
|
||||
|
||||
DBG("Device interface descriptor: idx=%003d '%s'\n", idx, sbuf);
|
||||
j = strchr(sbuf, ':');
|
||||
if (j > sbuf) {
|
||||
sbuf[j - sbuf] = 0;
|
||||
/*
|
||||
* The device driver name may contain digits that
|
||||
* is not a part of the device instance number - like "u3g".
|
||||
*/
|
||||
j = strrspn(sbuf, "0123456789");
|
||||
if (j > sbuf) {
|
||||
*drv_name_str = strndup(sbuf, j - sbuf);
|
||||
*drv_inst_str = strdup((j));
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int sysctl_query_dev_drv(const char *drv_name_str,
|
||||
const char *drv_inst_str, char **ttyname, int *const ttyport_cnt)
|
||||
{
|
||||
int rc;
|
||||
char sbuf[FILENAME_MAX];
|
||||
char tbuf[FILENAME_MAX];
|
||||
size_t tbuf_len;
|
||||
|
||||
if (!ttyname || !ttyport_cnt)
|
||||
return -1;
|
||||
|
||||
snprintf(sbuf, sizeof(sbuf), "dev.%s.%s.ttyname", drv_name_str,
|
||||
drv_inst_str);
|
||||
tbuf_len = sizeof(tbuf) - 1;
|
||||
if ((rc = sysctlbyname(sbuf, tbuf, &tbuf_len, NULL, 0)) != 0)
|
||||
return rc;
|
||||
|
||||
tbuf[tbuf_len] = 0;
|
||||
*ttyname = strndup(tbuf, tbuf_len);
|
||||
DBG("sysctl: '%s' (%d) (%d): '%.*s'\n", sbuf, rc, (int)tbuf_len,
|
||||
(int)tbuf_len, tbuf);
|
||||
|
||||
snprintf(sbuf, sizeof(sbuf), "dev.%s.%s.ttyports",
|
||||
drv_name_str, drv_inst_str);
|
||||
tbuf_len = sizeof(tbuf) - 1;
|
||||
rc = sysctlbyname(sbuf, tbuf, &tbuf_len, NULL, 0);
|
||||
if (rc == 0) {
|
||||
*ttyport_cnt = *(uint32_t *)tbuf;
|
||||
DBG("sysctl: '%s' (%d) (%d): '%d'\n", sbuf, rc,
|
||||
(int)tbuf_len, (int)ttyport_cnt);
|
||||
} else {
|
||||
*ttyport_cnt = 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int populate_port_struct_from_libusb_desc(struct sp_port *const port,
|
||||
struct libusb20_device *dev)
|
||||
{
|
||||
char tbuf[FILENAME_MAX];
|
||||
|
||||
/* Populate port structure from libusb description. */
|
||||
struct LIBUSB20_DEVICE_DESC_DECODED *dev_desc =
|
||||
libusb20_dev_get_device_desc(dev);
|
||||
|
||||
if (!dev_desc)
|
||||
return -1;
|
||||
|
||||
port->transport = SP_TRANSPORT_USB;
|
||||
port->usb_vid = dev_desc->idVendor;
|
||||
port->usb_pid = dev_desc->idProduct;
|
||||
port->usb_bus = libusb20_dev_get_bus_number(dev);
|
||||
port->usb_address = libusb20_dev_get_address(dev);
|
||||
if (libusb20_dev_req_string_simple_sync
|
||||
(dev, dev_desc->iManufacturer, tbuf, sizeof(tbuf)) == 0) {
|
||||
port->usb_manufacturer = strdup(tbuf);
|
||||
}
|
||||
if (libusb20_dev_req_string_simple_sync
|
||||
(dev, dev_desc->iProduct, tbuf, sizeof(tbuf)) == 0) {
|
||||
port->usb_product = strdup(tbuf);
|
||||
}
|
||||
if (libusb20_dev_req_string_simple_sync
|
||||
(dev, dev_desc->iSerialNumber, tbuf, sizeof(tbuf)) == 0) {
|
||||
port->usb_serial = strdup(tbuf);
|
||||
}
|
||||
/* If present, add serial to description for better identification. */
|
||||
tbuf[0] = '\0';
|
||||
if (port->usb_product && port->usb_product[0])
|
||||
strncat(tbuf, port->usb_product, sizeof(tbuf) - 1);
|
||||
else
|
||||
strncat(tbuf, libusb20_dev_get_desc(dev), sizeof(tbuf) - 1);
|
||||
if (port->usb_serial && port->usb_serial[0]) {
|
||||
strncat(tbuf, " ", sizeof(tbuf) - 1);
|
||||
strncat(tbuf, port->usb_serial, sizeof(tbuf) - 1);
|
||||
}
|
||||
port->description = strdup(tbuf);
|
||||
port->bluetooth_address = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
||||
{
|
||||
int rc;
|
||||
struct libusb20_backend *be;
|
||||
struct libusb20_device *dev, *dev_last;
|
||||
char tbuf[FILENAME_MAX];
|
||||
char *cua_sfx;
|
||||
int cua_dev_found;
|
||||
uint8_t idx;
|
||||
int sub_inst;
|
||||
|
||||
DBG("Portname: '%s'\n", port->name);
|
||||
|
||||
if (!strncmp(port->name, DEV_CUA_PATH, strlen(DEV_CUA_PATH))) {
|
||||
cua_sfx = port->name + strlen(DEV_CUA_PATH);
|
||||
DBG("'%s': '%s'\n", DEV_CUA_PATH, cua_sfx);
|
||||
} else {
|
||||
RETURN_ERROR(SP_ERR_ARG, "Device name not recognized");
|
||||
}
|
||||
|
||||
/* Native UART enumeration. */
|
||||
if ((cua_sfx[0] == 'u') || (cua_sfx[0] == 'd')) {
|
||||
port->transport = SP_TRANSPORT_NATIVE;
|
||||
snprintf(tbuf, sizeof(tbuf), "cua%s", cua_sfx);
|
||||
port->description = strdup(tbuf);
|
||||
RETURN_OK();
|
||||
}
|
||||
|
||||
/* USB device enumeration. */
|
||||
dev = dev_last = NULL;
|
||||
be = libusb20_be_alloc_default();
|
||||
cua_dev_found = 0;
|
||||
while (cua_dev_found == 0) {
|
||||
dev = libusb20_be_device_foreach(be, dev_last);
|
||||
if (!dev)
|
||||
break;
|
||||
|
||||
libusb20_dev_open(dev, 0);
|
||||
DBG("Device descriptor: '%s'\n", libusb20_dev_get_desc(dev));
|
||||
|
||||
for (idx = 0; idx <= UINT8_MAX - 1; idx++) {
|
||||
char *drv_name_str = NULL;
|
||||
char *drv_inst_str = NULL;
|
||||
char *ttyname = NULL;
|
||||
int ttyport_cnt;
|
||||
|
||||
rc = libusb_query_port(dev, idx, &drv_name_str, &drv_inst_str);
|
||||
if (rc == 0) {
|
||||
rc = sysctl_query_dev_drv(drv_name_str,
|
||||
drv_inst_str, &ttyname, &ttyport_cnt);
|
||||
if (rc == 0) {
|
||||
/* Handle multiple subinstances of serial ports in the same driver instance. */
|
||||
for (sub_inst = 0; sub_inst < ttyport_cnt; sub_inst++) {
|
||||
if (ttyport_cnt == 1)
|
||||
snprintf(tbuf, sizeof(tbuf), "%s", ttyname);
|
||||
else
|
||||
snprintf(tbuf, sizeof(tbuf), "%s.%d", ttyname, sub_inst);
|
||||
if (!strcmp(cua_sfx, tbuf)) {
|
||||
DBG("MATCH: '%s' == '%s'\n", cua_sfx, tbuf);
|
||||
cua_dev_found = 1;
|
||||
populate_port_struct_from_libusb_desc(port, dev);
|
||||
break; /* Break out of sub instance loop. */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
if (ttyname)
|
||||
free(ttyname);
|
||||
if (drv_name_str)
|
||||
free(drv_name_str);
|
||||
if (drv_inst_str)
|
||||
free(drv_inst_str);
|
||||
if (cua_dev_found)
|
||||
break; /* Break out of USB device port idx loop. */
|
||||
}
|
||||
libusb20_dev_close(dev);
|
||||
dev_last = dev;
|
||||
}
|
||||
libusb20_be_free(be);
|
||||
|
||||
if (cua_dev_found == 0)
|
||||
DBG("WARN: Found no match '%s' %s'\n", port->name, cua_sfx);
|
||||
|
||||
RETURN_OK();
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
struct termios tios;
|
||||
char name[PATH_MAX];
|
||||
int fd, ret;
|
||||
|
||||
DEBUG("Enumerating tty devices");
|
||||
if (!(dir = opendir("/dev")))
|
||||
RETURN_FAIL("Could not open dir /dev");
|
||||
|
||||
DEBUG("Iterating over results");
|
||||
while ((entry = readdir(dir))) {
|
||||
ret = SP_OK;
|
||||
if (entry->d_type != DT_CHR)
|
||||
continue;
|
||||
if (strncmp(entry->d_name, "cuaU", 4) != 0)
|
||||
if (strncmp(entry->d_name, "cuau", 4) != 0)
|
||||
if (strncmp(entry->d_name, "cuad", 4) != 0)
|
||||
continue;
|
||||
if (strend(entry->d_name, ".init"))
|
||||
continue;
|
||||
if (strend(entry->d_name, ".lock"))
|
||||
continue;
|
||||
|
||||
snprintf(name, sizeof(name), "/dev/%s", entry->d_name);
|
||||
DEBUG_FMT("Found device %s", name);
|
||||
|
||||
/* Check that we can open tty/cua device in rw mode - we need that. */
|
||||
if ((fd = open(name, O_RDWR | O_NONBLOCK | O_NOCTTY | O_TTY_INIT | O_CLOEXEC)) < 0) {
|
||||
DEBUG("Open failed, skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Sanity check if we got a real tty. */
|
||||
if (!isatty(fd)) {
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = tcgetattr(fd, &tios);
|
||||
close(fd);
|
||||
if (ret < 0 || cfgetospeed(&tios) <= 0 || cfgetispeed(&tios) <= 0)
|
||||
continue;
|
||||
|
||||
DEBUG_FMT("Found port %s", name);
|
||||
DBG("%s: %s\n", __func__, entry->d_name);
|
||||
|
||||
*list = list_append(*list, name);
|
||||
if (!*list) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "List append failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
1827
libserialport.h
1827
libserialport.h
File diff suppressed because it is too large
Load Diff
1315
libserialport.h.in
Normal file
1315
libserialport.h.in
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,6 @@ Name: libserialport
|
||||
Description: Cross-platform serial port access library.
|
||||
URL: http://sigrok.org/wiki/Libserialport
|
||||
Requires.private: @SP_PKGLIBS@
|
||||
Version: @SP_PACKAGE_VERSION@
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lserialport
|
||||
Libs.private: @SP_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29613.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libserialport", "libserialport.vcxproj", "{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x64.Build.0 = Debug|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x64.ActiveCfg = Release|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x64.Build.0 = Release|x64
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C2042526-D57D-45CA-B39F-6D9A782D1A05}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="libserialport.h" />
|
||||
<ClInclude Include="libserialport_internal.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="serialport.c" />
|
||||
<ClCompile Include="timing.c" />
|
||||
<ClCompile Include="windows.c" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{1C8EAAF2-133E-4CEE-8981-4A903A8B3935}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>libserialport</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)'=='Debug'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
<Import Project="debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)'=='Release'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="common.props" />
|
||||
<Import Project="release.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="libserialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libserialport_internal.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="serialport.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="windows.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="timing.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,311 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libserialport project.
|
||||
*
|
||||
* Copyright (C) 2014 Martin Ling <martin-libserialport@earth.li>
|
||||
* Copyright (C) 2014 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LIBSERIALPORT_LIBSERIALPORT_INTERNAL_H
|
||||
#define LIBSERIALPORT_LIBSERIALPORT_INTERNAL_H
|
||||
|
||||
/* These MSVC-specific defines must appear before other headers.*/
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
/* These feature test macros must appear before other headers.*/
|
||||
#if defined(__linux__) || defined(__CYGWIN__)
|
||||
/* For timeradd, timersub, timercmp, realpath. */
|
||||
#define _BSD_SOURCE 1 /* for glibc < 2.19 */
|
||||
#define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */
|
||||
/* For clock_gettime and associated types. */
|
||||
#define _POSIX_C_SOURCE 199309L
|
||||
#endif
|
||||
|
||||
#ifdef LIBSERIALPORT_ATBUILD
|
||||
/* If building with autoconf, include the generated config.h. */
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LIBSERIALPORT_MSBUILD
|
||||
/* If building with MS tools, define necessary things that
|
||||
would otherwise appear in config.h. */
|
||||
#define SP_PRIV
|
||||
#endif
|
||||
|
||||
#include "libserialport.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <setupapi.h>
|
||||
#include <cfgmgr32.h>
|
||||
#undef DEFINE_GUID
|
||||
#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
static const GUID name = { l,w1,w2,{ b1,b2,b3,b4,b5,b6,b7,b8 } }
|
||||
#include <usbioctl.h>
|
||||
#include <usbiodef.h>
|
||||
/* The largest size that can be passed to WriteFile() safely
|
||||
* on any architecture. This arises from the expression:
|
||||
* PAGE_SIZE * (65535 - sizeof(MDL)) / sizeof(ULONG_PTR)
|
||||
* and this worst-case value is found on x64. */
|
||||
#define WRITEFILE_MAX_SIZE 33525760
|
||||
#else
|
||||
#include <limits.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_SYS_FILE_H
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/serial/IOSerialKeys.h>
|
||||
#include <IOKit/serial/ioss.h>
|
||||
#include <sys/syslimits.h>
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <dirent.h>
|
||||
/* Android only has linux/serial.h from platform 21 onwards. */
|
||||
#if !(defined(__ANDROID__) && (__ANDROID_API__ < 21))
|
||||
#include <linux/serial.h>
|
||||
#endif
|
||||
#include "linux_termios.h"
|
||||
|
||||
/* TCGETX/TCSETX is not available everywhere. */
|
||||
#if defined(TCGETX) && defined(TCSETX) && defined(HAVE_STRUCT_TERMIOX)
|
||||
#define USE_TERMIOX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* TIOCINQ/TIOCOUTQ is not available everywhere. */
|
||||
#if !defined(TIOCINQ) && defined(FIONREAD)
|
||||
#define TIOCINQ FIONREAD
|
||||
#endif
|
||||
#if !defined(TIOCOUTQ) && defined(FIONWRITE)
|
||||
#define TIOCOUTQ FIONWRITE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* O_CLOEXEC is not available everywhere, fallback to not setting the
|
||||
* flag on those systems.
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Non-standard baudrates are not available everywhere. */
|
||||
#if (defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)) && HAVE_DECL_BOTHER
|
||||
#define USE_TERMIOS_SPEED
|
||||
#endif
|
||||
|
||||
struct sp_port {
|
||||
char *name;
|
||||
char *description;
|
||||
enum sp_transport transport;
|
||||
int usb_bus;
|
||||
int usb_address;
|
||||
int usb_vid;
|
||||
int usb_pid;
|
||||
char *usb_manufacturer;
|
||||
char *usb_product;
|
||||
char *usb_serial;
|
||||
char *bluetooth_address;
|
||||
#ifdef _WIN32
|
||||
char *usb_path;
|
||||
HANDLE hdl;
|
||||
COMMTIMEOUTS timeouts;
|
||||
OVERLAPPED write_ovl;
|
||||
OVERLAPPED read_ovl;
|
||||
OVERLAPPED wait_ovl;
|
||||
DWORD events;
|
||||
BYTE *write_buf;
|
||||
DWORD write_buf_size;
|
||||
BOOL writing;
|
||||
BOOL wait_running;
|
||||
#else
|
||||
int fd;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct sp_port_config {
|
||||
int baudrate;
|
||||
int bits;
|
||||
enum sp_parity parity;
|
||||
int stopbits;
|
||||
enum sp_rts rts;
|
||||
enum sp_cts cts;
|
||||
enum sp_dtr dtr;
|
||||
enum sp_dsr dsr;
|
||||
enum sp_xonxoff xon_xoff;
|
||||
};
|
||||
|
||||
struct port_data {
|
||||
#ifdef _WIN32
|
||||
DCB dcb;
|
||||
#else
|
||||
struct termios term;
|
||||
int controlbits;
|
||||
int termiox_supported;
|
||||
int rts_flow;
|
||||
int cts_flow;
|
||||
int dtr_flow;
|
||||
int dsr_flow;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef HANDLE event_handle;
|
||||
#else
|
||||
typedef int event_handle;
|
||||
#endif
|
||||
|
||||
/* Standard baud rates. */
|
||||
#ifdef _WIN32
|
||||
#define BAUD_TYPE DWORD
|
||||
#define BAUD(n) {CBR_##n, n}
|
||||
#else
|
||||
#define BAUD_TYPE speed_t
|
||||
#define BAUD(n) {B##n, n}
|
||||
#endif
|
||||
|
||||
struct std_baudrate {
|
||||
BAUD_TYPE index;
|
||||
int value;
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
extern void (*sp_debug_handler)(const char *format, ...);
|
||||
|
||||
/* Debug output macros. */
|
||||
#define DEBUG_FMT(fmt, ...) do { \
|
||||
if (sp_debug_handler) \
|
||||
sp_debug_handler(fmt ".\n", __VA_ARGS__); \
|
||||
} while (0)
|
||||
#define DEBUG(msg) DEBUG_FMT(msg, NULL)
|
||||
#define DEBUG_ERROR(err, msg) DEBUG_FMT("%s returning " #err ": " msg, __func__)
|
||||
#define DEBUG_FAIL(msg) do { \
|
||||
char *errmsg = sp_last_error_message(); \
|
||||
DEBUG_FMT("%s returning SP_ERR_FAIL: " msg ": %s", __func__, errmsg); \
|
||||
sp_free_error_message(errmsg); \
|
||||
} while (0);
|
||||
#define RETURN() do { \
|
||||
DEBUG_FMT("%s returning", __func__); \
|
||||
return; \
|
||||
} while (0)
|
||||
#define RETURN_CODE(x) do { \
|
||||
DEBUG_FMT("%s returning " #x, __func__); \
|
||||
return x; \
|
||||
} while (0)
|
||||
#define RETURN_CODEVAL(x) do { \
|
||||
switch (x) { \
|
||||
case SP_OK: RETURN_CODE(SP_OK); \
|
||||
case SP_ERR_ARG: RETURN_CODE(SP_ERR_ARG); \
|
||||
case SP_ERR_FAIL: RETURN_CODE(SP_ERR_FAIL); \
|
||||
case SP_ERR_MEM: RETURN_CODE(SP_ERR_MEM); \
|
||||
case SP_ERR_SUPP: RETURN_CODE(SP_ERR_SUPP); \
|
||||
default: RETURN_CODE(SP_ERR_FAIL); \
|
||||
} \
|
||||
} while (0)
|
||||
#define RETURN_OK() RETURN_CODE(SP_OK);
|
||||
#define RETURN_ERROR(err, msg) do { \
|
||||
DEBUG_ERROR(err, msg); \
|
||||
return err; \
|
||||
} while (0)
|
||||
#define RETURN_FAIL(msg) do { \
|
||||
DEBUG_FAIL(msg); \
|
||||
return SP_ERR_FAIL; \
|
||||
} while (0)
|
||||
#define RETURN_INT(x) do { \
|
||||
int _x = x; \
|
||||
DEBUG_FMT("%s returning %d", __func__, _x); \
|
||||
return _x; \
|
||||
} while (0)
|
||||
#define RETURN_STRING(x) do { \
|
||||
char *_x = x; \
|
||||
DEBUG_FMT("%s returning %s", __func__, _x); \
|
||||
return _x; \
|
||||
} while (0)
|
||||
#define RETURN_POINTER(x) do { \
|
||||
void *_x = x; \
|
||||
DEBUG_FMT("%s returning %p", __func__, _x); \
|
||||
return _x; \
|
||||
} while (0)
|
||||
#define SET_ERROR(val, err, msg) do { DEBUG_ERROR(err, msg); val = err; } while (0)
|
||||
#define SET_FAIL(val, msg) do { DEBUG_FAIL(msg); val = SP_ERR_FAIL; } while (0)
|
||||
#define TRACE(fmt, ...) DEBUG_FMT("%s(" fmt ") called", __func__, __VA_ARGS__)
|
||||
#define TRACE_VOID() DEBUG_FMT("%s() called", __func__)
|
||||
|
||||
#define TRY(x) do { int retval = x; if (retval != SP_OK) RETURN_CODEVAL(retval); } while (0)
|
||||
|
||||
SP_PRIV struct sp_port **list_append(struct sp_port **list, const char *portname);
|
||||
|
||||
/* OS-specific Helper functions. */
|
||||
SP_PRIV enum sp_return get_port_details(struct sp_port *port);
|
||||
SP_PRIV enum sp_return list_ports(struct sp_port ***list);
|
||||
|
||||
/* Timing abstraction */
|
||||
|
||||
struct time {
|
||||
#ifdef _WIN32
|
||||
int64_t ticks;
|
||||
#else
|
||||
struct timeval tv;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct timeout {
|
||||
unsigned int ms, limit_ms;
|
||||
struct time start, now, end, delta, delta_max;
|
||||
struct timeval delta_tv;
|
||||
bool calls_started, overflow;
|
||||
};
|
||||
|
||||
SP_PRIV void time_get(struct time *time);
|
||||
SP_PRIV void time_set_ms(struct time *time, unsigned int ms);
|
||||
SP_PRIV void time_add(const struct time *a, const struct time *b, struct time *result);
|
||||
SP_PRIV void time_sub(const struct time *a, const struct time *b, struct time *result);
|
||||
SP_PRIV bool time_greater(const struct time *a, const struct time *b);
|
||||
SP_PRIV void time_as_timeval(const struct time *time, struct timeval *tv);
|
||||
SP_PRIV unsigned int time_as_ms(const struct time *time);
|
||||
SP_PRIV void timeout_start(struct timeout *timeout, unsigned int timeout_ms);
|
||||
SP_PRIV void timeout_limit(struct timeout *timeout, unsigned int limit_ms);
|
||||
SP_PRIV bool timeout_check(struct timeout *timeout);
|
||||
SP_PRIV void timeout_update(struct timeout *timeout);
|
||||
SP_PRIV struct timeval *timeout_timeval(struct timeout *timeout);
|
||||
SP_PRIV unsigned int timeout_remaining_ms(struct timeout *timeout);
|
||||
|
||||
#endif
|
259
linux.c
259
linux.c
@ -1,259 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libserialport project.
|
||||
*
|
||||
* Copyright (C) 2013 Martin Ling <martin-libserialport@earth.li>
|
||||
* Copyright (C) 2014 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "libserialport.h"
|
||||
#include "libserialport_internal.h"
|
||||
|
||||
/*
|
||||
* The 'e' modifier for O_CLOEXEC is glibc >= 2.7 only, hence not
|
||||
* portable, so provide an own wrapper for this functionality.
|
||||
*/
|
||||
static FILE *fopen_cloexec_rdonly(const char *pathname)
|
||||
{
|
||||
int fd;
|
||||
if ((fd = open(pathname, O_RDONLY | O_CLOEXEC)) < 0)
|
||||
return NULL;
|
||||
return fdopen(fd, "r");
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
||||
{
|
||||
/*
|
||||
* Description limited to 127 char, anything longer
|
||||
* would not be user friendly anyway.
|
||||
*/
|
||||
char description[128];
|
||||
int bus, address;
|
||||
unsigned int vid, pid;
|
||||
char manufacturer[128], product[128], serial[128];
|
||||
char baddr[32];
|
||||
const char dir_name[] = "/sys/class/tty/%s/device/%s%s";
|
||||
char sub_dir[32] = "", link_name[PATH_MAX], file_name[PATH_MAX];
|
||||
char *ptr, *dev = port->name + 5;
|
||||
FILE *file;
|
||||
int i, count;
|
||||
struct stat statbuf;
|
||||
|
||||
if (strncmp(port->name, "/dev/", 5))
|
||||
RETURN_ERROR(SP_ERR_ARG, "Device name not recognized");
|
||||
|
||||
snprintf(link_name, sizeof(link_name), "/sys/class/tty/%s", dev);
|
||||
if (lstat(link_name, &statbuf) == -1)
|
||||
RETURN_ERROR(SP_ERR_ARG, "Device not found");
|
||||
if (!S_ISLNK(statbuf.st_mode))
|
||||
snprintf(link_name, sizeof(link_name), "/sys/class/tty/%s/device", dev);
|
||||
count = readlink(link_name, file_name, sizeof(file_name));
|
||||
if (count <= 0 || count >= (int)(sizeof(file_name) - 1))
|
||||
RETURN_ERROR(SP_ERR_ARG, "Device not found");
|
||||
file_name[count] = 0;
|
||||
if (strstr(file_name, "bluetooth"))
|
||||
port->transport = SP_TRANSPORT_BLUETOOTH;
|
||||
else if (strstr(file_name, "usb"))
|
||||
port->transport = SP_TRANSPORT_USB;
|
||||
|
||||
if (port->transport == SP_TRANSPORT_USB) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
strcat(sub_dir, "../");
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "busnum");
|
||||
if (!(file = fopen_cloexec_rdonly(file_name)))
|
||||
continue;
|
||||
count = fscanf(file, "%d", &bus);
|
||||
fclose(file);
|
||||
if (count != 1)
|
||||
continue;
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "devnum");
|
||||
if (!(file = fopen_cloexec_rdonly(file_name)))
|
||||
continue;
|
||||
count = fscanf(file, "%d", &address);
|
||||
fclose(file);
|
||||
if (count != 1)
|
||||
continue;
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "idVendor");
|
||||
if (!(file = fopen_cloexec_rdonly(file_name)))
|
||||
continue;
|
||||
count = fscanf(file, "%4x", &vid);
|
||||
fclose(file);
|
||||
if (count != 1)
|
||||
continue;
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "idProduct");
|
||||
if (!(file = fopen_cloexec_rdonly(file_name)))
|
||||
continue;
|
||||
count = fscanf(file, "%4x", &pid);
|
||||
fclose(file);
|
||||
if (count != 1)
|
||||
continue;
|
||||
|
||||
port->usb_bus = bus;
|
||||
port->usb_address = address;
|
||||
port->usb_vid = vid;
|
||||
port->usb_pid = pid;
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "product");
|
||||
if ((file = fopen_cloexec_rdonly(file_name))) {
|
||||
if ((ptr = fgets(description, sizeof(description), file))) {
|
||||
ptr = description + strlen(description) - 1;
|
||||
if (ptr >= description && *ptr == '\n')
|
||||
*ptr = 0;
|
||||
port->description = strdup(description);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
if (!file || !ptr)
|
||||
port->description = strdup(dev);
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "manufacturer");
|
||||
if ((file = fopen_cloexec_rdonly(file_name))) {
|
||||
if ((ptr = fgets(manufacturer, sizeof(manufacturer), file))) {
|
||||
ptr = manufacturer + strlen(manufacturer) - 1;
|
||||
if (ptr >= manufacturer && *ptr == '\n')
|
||||
*ptr = 0;
|
||||
port->usb_manufacturer = strdup(manufacturer);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "product");
|
||||
if ((file = fopen_cloexec_rdonly(file_name))) {
|
||||
if ((ptr = fgets(product, sizeof(product), file))) {
|
||||
ptr = product + strlen(product) - 1;
|
||||
if (ptr >= product && *ptr == '\n')
|
||||
*ptr = 0;
|
||||
port->usb_product = strdup(product);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, sub_dir, "serial");
|
||||
if ((file = fopen_cloexec_rdonly(file_name))) {
|
||||
if ((ptr = fgets(serial, sizeof(serial), file))) {
|
||||
ptr = serial + strlen(serial) - 1;
|
||||
if (ptr >= serial && *ptr == '\n')
|
||||
*ptr = 0;
|
||||
port->usb_serial = strdup(serial);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
/* If present, add serial to description for better identification. */
|
||||
if (port->usb_serial && strlen(port->usb_serial)) {
|
||||
snprintf(description, sizeof(description),
|
||||
"%s - %s", port->description, port->usb_serial);
|
||||
if (port->description)
|
||||
free(port->description);
|
||||
port->description = strdup(description);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
port->description = strdup(dev);
|
||||
|
||||
if (port->transport == SP_TRANSPORT_BLUETOOTH) {
|
||||
snprintf(file_name, sizeof(file_name), dir_name, dev, "", "address");
|
||||
if ((file = fopen_cloexec_rdonly(file_name))) {
|
||||
if ((ptr = fgets(baddr, sizeof(baddr), file))) {
|
||||
ptr = baddr + strlen(baddr) - 1;
|
||||
if (ptr >= baddr && *ptr == '\n')
|
||||
*ptr = 0;
|
||||
port->bluetooth_address = strdup(baddr);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_OK();
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
||||
{
|
||||
char name[PATH_MAX], target[PATH_MAX];
|
||||
struct dirent *entry;
|
||||
#ifdef HAVE_STRUCT_SERIAL_STRUCT
|
||||
struct serial_struct serial_info;
|
||||
int ioctl_result;
|
||||
#endif
|
||||
char buf[sizeof(entry->d_name) + 23];
|
||||
int len, fd;
|
||||
DIR *dir;
|
||||
int ret = SP_OK;
|
||||
struct stat statbuf;
|
||||
|
||||
DEBUG("Enumerating tty devices");
|
||||
if (!(dir = opendir("/sys/class/tty")))
|
||||
RETURN_FAIL("Could not open /sys/class/tty");
|
||||
|
||||
DEBUG("Iterating over results");
|
||||
while ((entry = readdir(dir))) {
|
||||
snprintf(buf, sizeof(buf), "/sys/class/tty/%s", entry->d_name);
|
||||
if (lstat(buf, &statbuf) == -1)
|
||||
continue;
|
||||
if (!S_ISLNK(statbuf.st_mode))
|
||||
snprintf(buf, sizeof(buf), "/sys/class/tty/%s/device", entry->d_name);
|
||||
len = readlink(buf, target, sizeof(target));
|
||||
if (len <= 0 || len >= (int)(sizeof(target) - 1))
|
||||
continue;
|
||||
target[len] = 0;
|
||||
if (strstr(target, "virtual"))
|
||||
continue;
|
||||
snprintf(name, sizeof(name), "/dev/%s", entry->d_name);
|
||||
DEBUG_FMT("Found device %s", name);
|
||||
if (strstr(target, "serial8250")) {
|
||||
/*
|
||||
* The serial8250 driver has a hardcoded number of ports.
|
||||
* The only way to tell which actually exist on a given system
|
||||
* is to try to open them and make an ioctl call.
|
||||
*/
|
||||
DEBUG("serial8250 device, attempting to open");
|
||||
if ((fd = open(name, O_RDWR | O_NONBLOCK | O_NOCTTY | O_CLOEXEC)) < 0) {
|
||||
DEBUG("Open failed, skipping");
|
||||
continue;
|
||||
}
|
||||
#ifdef HAVE_STRUCT_SERIAL_STRUCT
|
||||
ioctl_result = ioctl(fd, TIOCGSERIAL, &serial_info);
|
||||
#endif
|
||||
close(fd);
|
||||
#ifdef HAVE_STRUCT_SERIAL_STRUCT
|
||||
if (ioctl_result != 0) {
|
||||
DEBUG("ioctl failed, skipping");
|
||||
continue;
|
||||
}
|
||||
if (serial_info.type == PORT_UNKNOWN) {
|
||||
DEBUG("Port type is unknown, skipping");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
DEBUG_FMT("Found port %s", name);
|
||||
*list = list_append(*list, name);
|
||||
if (!*list) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "List append failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
@ -33,42 +33,40 @@
|
||||
* TCSETX/TCGETX ioctls used with struct termiox, others do not.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <linux/termios.h>
|
||||
#include "linux_termios.h"
|
||||
|
||||
SP_PRIV unsigned long get_termios_get_ioctl(void)
|
||||
int get_termios_get_ioctl(void)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TERMIOS2
|
||||
#ifdef HAVE_TERMIOS2
|
||||
return TCGETS2;
|
||||
#else
|
||||
return TCGETS;
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV unsigned long get_termios_set_ioctl(void)
|
||||
int get_termios_set_ioctl(void)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TERMIOS2
|
||||
#ifdef HAVE_TERMIOS2
|
||||
return TCSETS2;
|
||||
#else
|
||||
return TCSETS;
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV size_t get_termios_size(void)
|
||||
int get_termios_size(void)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TERMIOS2
|
||||
#ifdef HAVE_TERMIOS2
|
||||
return sizeof(struct termios2);
|
||||
#else
|
||||
return sizeof(struct termios);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)) && HAVE_DECL_BOTHER
|
||||
SP_PRIV int get_termios_speed(void *data)
|
||||
#if defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)
|
||||
int get_termios_speed(void *data)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TERMIOS2
|
||||
#ifdef HAVE_TERMIOS2
|
||||
struct termios2 *term = (struct termios2 *) data;
|
||||
#else
|
||||
struct termios *term = (struct termios *) data;
|
||||
@ -79,9 +77,9 @@ SP_PRIV int get_termios_speed(void *data)
|
||||
return term->c_ispeed;
|
||||
}
|
||||
|
||||
SP_PRIV void set_termios_speed(void *data, int speed)
|
||||
void set_termios_speed(void *data, int speed)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TERMIOS2
|
||||
#ifdef HAVE_TERMIOS2
|
||||
struct termios2 *term = (struct termios2 *) data;
|
||||
#else
|
||||
struct termios *term = (struct termios *) data;
|
||||
@ -92,13 +90,13 @@ SP_PRIV void set_termios_speed(void *data, int speed)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRUCT_TERMIOX
|
||||
SP_PRIV size_t get_termiox_size(void)
|
||||
#ifdef HAVE_TERMIOX
|
||||
int get_termiox_size(void)
|
||||
{
|
||||
return sizeof(struct termiox);
|
||||
}
|
||||
|
||||
SP_PRIV int get_termiox_flow(void *data, int *rts, int *cts, int *dtr, int *dsr)
|
||||
int get_termiox_flow(void *data, int *rts, int *cts, int *dtr, int *dsr)
|
||||
{
|
||||
struct termiox *termx = (struct termiox *) data;
|
||||
int flags = 0;
|
||||
@ -111,7 +109,7 @@ SP_PRIV int get_termiox_flow(void *data, int *rts, int *cts, int *dtr, int *dsr)
|
||||
return flags;
|
||||
}
|
||||
|
||||
SP_PRIV void set_termiox_flow(void *data, int rts, int cts, int dtr, int dsr)
|
||||
void set_termiox_flow(void *data, int rts, int cts, int dtr, int dsr)
|
||||
{
|
||||
struct termiox *termx = (struct termiox *) data;
|
||||
|
||||
|
@ -20,15 +20,13 @@
|
||||
#ifndef LIBSERIALPORT_LINUX_TERMIOS_H
|
||||
#define LIBSERIALPORT_LINUX_TERMIOS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
SP_PRIV unsigned long get_termios_get_ioctl(void);
|
||||
SP_PRIV unsigned long get_termios_set_ioctl(void);
|
||||
SP_PRIV size_t get_termios_size(void);
|
||||
SP_PRIV int get_termios_speed(void *data);
|
||||
SP_PRIV void set_termios_speed(void *data, int speed);
|
||||
SP_PRIV size_t get_termiox_size(void);
|
||||
SP_PRIV int get_termiox_flow(void *data, int *rts, int *cts, int *dtr, int *dsr);
|
||||
SP_PRIV void set_termiox_flow(void *data, int rts, int cts, int dtr, int dsr);
|
||||
int get_termios_get_ioctl(void);
|
||||
int get_termios_set_ioctl(void);
|
||||
int get_termios_size(void);
|
||||
int get_termios_speed(void *data);
|
||||
void set_termios_speed(void *data, int speed);
|
||||
int get_termiox_size(void);
|
||||
int get_termiox_flow(void *data, int *rts, int *cts, int *dtr, int *dsr);
|
||||
void set_termiox_flow(void *data, int rts, int cts, int dtr, int dsr);
|
||||
|
||||
#endif
|
||||
|
243
macosx.c
243
macosx.c
@ -1,243 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libserialport project.
|
||||
*
|
||||
* Copyright (C) 2013-2014 Martin Ling <martin-libserialport@earth.li>
|
||||
* Copyright (C) 2014 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "libserialport.h"
|
||||
#include "libserialport_internal.h"
|
||||
|
||||
SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
||||
{
|
||||
/*
|
||||
* Description limited to 127 char, anything longer
|
||||
* would not be user friendly anyway.
|
||||
*/
|
||||
char description[128];
|
||||
int bus, address, vid, pid = -1;
|
||||
char manufacturer[128], product[128], serial[128];
|
||||
CFMutableDictionaryRef classes;
|
||||
io_iterator_t iter;
|
||||
io_object_t ioport, ioparent;
|
||||
CFTypeRef cf_property, cf_bus, cf_address, cf_vendor, cf_product;
|
||||
Boolean result;
|
||||
char path[PATH_MAX], class[16];
|
||||
|
||||
DEBUG("Getting serial port list");
|
||||
if (!(classes = IOServiceMatching(kIOSerialBSDServiceValue)))
|
||||
RETURN_FAIL("IOServiceMatching() failed");
|
||||
|
||||
if (IOServiceGetMatchingServices(kIOMasterPortDefault, classes,
|
||||
&iter) != KERN_SUCCESS)
|
||||
RETURN_FAIL("IOServiceGetMatchingServices() failed");
|
||||
|
||||
DEBUG("Iterating over results");
|
||||
while ((ioport = IOIteratorNext(iter))) {
|
||||
if (!(cf_property = IORegistryEntryCreateCFProperty(ioport,
|
||||
CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0))) {
|
||||
IOObjectRelease(ioport);
|
||||
continue;
|
||||
}
|
||||
result = CFStringGetCString(cf_property, path, sizeof(path),
|
||||
kCFStringEncodingASCII);
|
||||
CFRelease(cf_property);
|
||||
if (!result || strcmp(path, port->name)) {
|
||||
IOObjectRelease(ioport);
|
||||
continue;
|
||||
}
|
||||
DEBUG_FMT("Found port %s", path);
|
||||
|
||||
IORegistryEntryGetParentEntry(ioport, kIOServicePlane, &ioparent);
|
||||
if ((cf_property=IORegistryEntrySearchCFProperty(ioparent,kIOServicePlane,
|
||||
CFSTR("IOClass"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents))) {
|
||||
if (CFStringGetCString(cf_property, class, sizeof(class),
|
||||
kCFStringEncodingASCII) &&
|
||||
strstr(class, "USB")) {
|
||||
DEBUG("Found USB class device");
|
||||
port->transport = SP_TRANSPORT_USB;
|
||||
}
|
||||
CFRelease(cf_property);
|
||||
}
|
||||
if ((cf_property=IORegistryEntrySearchCFProperty(ioparent,kIOServicePlane,
|
||||
CFSTR("IOProviderClass"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents))) {
|
||||
if (CFStringGetCString(cf_property, class, sizeof(class),
|
||||
kCFStringEncodingASCII) &&
|
||||
strstr(class, "USB")) {
|
||||
DEBUG("Found USB class device");
|
||||
port->transport = SP_TRANSPORT_USB;
|
||||
}
|
||||
CFRelease(cf_property);
|
||||
}
|
||||
IOObjectRelease(ioparent);
|
||||
|
||||
if ((cf_property = IORegistryEntrySearchCFProperty(ioport,kIOServicePlane,
|
||||
CFSTR("USB Interface Name"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents)) ||
|
||||
(cf_property = IORegistryEntrySearchCFProperty(ioport,kIOServicePlane,
|
||||
CFSTR("USB Product Name"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents)) ||
|
||||
(cf_property = IORegistryEntrySearchCFProperty(ioport,kIOServicePlane,
|
||||
CFSTR("Product Name"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents)) ||
|
||||
(cf_property = IORegistryEntryCreateCFProperty(ioport,
|
||||
CFSTR(kIOTTYDeviceKey), kCFAllocatorDefault, 0))) {
|
||||
if (CFStringGetCString(cf_property, description, sizeof(description),
|
||||
kCFStringEncodingASCII)) {
|
||||
DEBUG_FMT("Found description %s", description);
|
||||
port->description = strdup(description);
|
||||
}
|
||||
CFRelease(cf_property);
|
||||
} else {
|
||||
DEBUG("No description for this device");
|
||||
}
|
||||
|
||||
cf_bus = IORegistryEntrySearchCFProperty(ioport, kIOServicePlane,
|
||||
CFSTR("USBBusNumber"),
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively
|
||||
| kIORegistryIterateParents);
|
||||
cf_address = IORegistryEntrySearchCFProperty(ioport, kIOServicePlane,
|
||||
CFSTR("USB Address"),
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively
|
||||
| kIORegistryIterateParents);
|
||||
if (cf_bus && cf_address &&
|
||||
CFNumberGetValue(cf_bus , kCFNumberIntType, &bus) &&
|
||||
CFNumberGetValue(cf_address, kCFNumberIntType, &address)) {
|
||||
DEBUG_FMT("Found matching USB bus:address %03d:%03d", bus, address);
|
||||
port->usb_bus = bus;
|
||||
port->usb_address = address;
|
||||
}
|
||||
if (cf_bus)
|
||||
CFRelease(cf_bus);
|
||||
if (cf_address)
|
||||
CFRelease(cf_address);
|
||||
|
||||
cf_vendor = IORegistryEntrySearchCFProperty(ioport, kIOServicePlane,
|
||||
CFSTR("idVendor"),
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively
|
||||
| kIORegistryIterateParents);
|
||||
cf_product = IORegistryEntrySearchCFProperty(ioport, kIOServicePlane,
|
||||
CFSTR("idProduct"),
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively
|
||||
| kIORegistryIterateParents);
|
||||
if (cf_vendor && cf_product &&
|
||||
CFNumberGetValue(cf_vendor , kCFNumberIntType, &vid) &&
|
||||
CFNumberGetValue(cf_product, kCFNumberIntType, &pid)) {
|
||||
DEBUG_FMT("Found matching USB VID:PID %04X:%04X", vid, pid);
|
||||
port->usb_vid = vid;
|
||||
port->usb_pid = pid;
|
||||
}
|
||||
if (cf_vendor)
|
||||
CFRelease(cf_vendor);
|
||||
if (cf_product)
|
||||
CFRelease(cf_product);
|
||||
|
||||
if ((cf_property = IORegistryEntrySearchCFProperty(ioport,kIOServicePlane,
|
||||
CFSTR("USB Vendor Name"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents))) {
|
||||
if (CFStringGetCString(cf_property, manufacturer, sizeof(manufacturer),
|
||||
kCFStringEncodingASCII)) {
|
||||
DEBUG_FMT("Found manufacturer %s", manufacturer);
|
||||
port->usb_manufacturer = strdup(manufacturer);
|
||||
}
|
||||
CFRelease(cf_property);
|
||||
}
|
||||
|
||||
if ((cf_property = IORegistryEntrySearchCFProperty(ioport,kIOServicePlane,
|
||||
CFSTR("USB Product Name"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents))) {
|
||||
if (CFStringGetCString(cf_property, product, sizeof(product),
|
||||
kCFStringEncodingASCII)) {
|
||||
DEBUG_FMT("Found product name %s", product);
|
||||
port->usb_product = strdup(product);
|
||||
}
|
||||
CFRelease(cf_property);
|
||||
}
|
||||
|
||||
if ((cf_property = IORegistryEntrySearchCFProperty(ioport,kIOServicePlane,
|
||||
CFSTR("USB Serial Number"), kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively | kIORegistryIterateParents))) {
|
||||
if (CFStringGetCString(cf_property, serial, sizeof(serial),
|
||||
kCFStringEncodingASCII)) {
|
||||
DEBUG_FMT("Found serial number %s", serial);
|
||||
port->usb_serial = strdup(serial);
|
||||
}
|
||||
CFRelease(cf_property);
|
||||
}
|
||||
|
||||
IOObjectRelease(ioport);
|
||||
break;
|
||||
}
|
||||
IOObjectRelease(iter);
|
||||
|
||||
RETURN_OK();
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
||||
{
|
||||
CFMutableDictionaryRef classes;
|
||||
io_iterator_t iter;
|
||||
char path[PATH_MAX];
|
||||
io_object_t port;
|
||||
CFTypeRef cf_path;
|
||||
Boolean result;
|
||||
int ret = SP_OK;
|
||||
|
||||
DEBUG("Creating matching dictionary");
|
||||
if (!(classes = IOServiceMatching(kIOSerialBSDServiceValue))) {
|
||||
SET_FAIL(ret, "IOServiceMatching() failed");
|
||||
goto out_done;
|
||||
}
|
||||
|
||||
DEBUG("Getting matching services");
|
||||
if (IOServiceGetMatchingServices(kIOMasterPortDefault, classes,
|
||||
&iter) != KERN_SUCCESS) {
|
||||
SET_FAIL(ret, "IOServiceGetMatchingServices() failed");
|
||||
goto out_done;
|
||||
}
|
||||
|
||||
DEBUG("Iterating over results");
|
||||
while ((port = IOIteratorNext(iter))) {
|
||||
cf_path = IORegistryEntryCreateCFProperty(port,
|
||||
CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0);
|
||||
if (cf_path) {
|
||||
result = CFStringGetCString(cf_path, path, sizeof(path),
|
||||
kCFStringEncodingASCII);
|
||||
CFRelease(cf_path);
|
||||
if (result) {
|
||||
DEBUG_FMT("Found port %s", path);
|
||||
if (!(*list = list_append(*list, path))) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "List append failed");
|
||||
IOObjectRelease(port);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
IOObjectRelease(port);
|
||||
}
|
||||
out:
|
||||
IOObjectRelease(iter);
|
||||
out_done:
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_PropertySheetDisplayName>Release</_PropertySheetDisplayName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>LIBSERIALPORT_MSBUILD;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
1413
serialport.c
1413
serialport.c
File diff suppressed because it is too large
Load Diff
@ -1,69 +0,0 @@
|
||||
#include "config.h"
|
||||
#include "libserialport.h"
|
||||
#include "libserialport_internal.h"
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
struct time a, b, c;
|
||||
struct timeval tv;
|
||||
struct timeout to;
|
||||
|
||||
printf("Testing arithmetic\n");
|
||||
time_set_ms(&a, 10050);
|
||||
time_set_ms(&b, 100);
|
||||
assert(time_greater(&a, &b));
|
||||
assert(!time_greater(&b, &a));
|
||||
time_add(&a, &b, &c);
|
||||
assert(time_as_ms(&c) == 10150);
|
||||
time_sub(&a, &b, &c);
|
||||
assert(time_as_ms(&c) == 9950);
|
||||
time_as_timeval(&a, &tv);
|
||||
assert(tv.tv_sec == 10);
|
||||
assert(tv.tv_usec == 50000);
|
||||
time_get(&a);
|
||||
printf("Sleeping for 1s\n");
|
||||
sleep(1);
|
||||
time_get(&b);
|
||||
time_sub(&b, &a, &c);
|
||||
printf("Measured: %ums\n", time_as_ms(&c));
|
||||
assert(time_as_ms(&c) >= 950);
|
||||
assert(time_as_ms(&c) <= 1050);
|
||||
printf("Starting 3s timeout\n");
|
||||
timeout_start(&to, 3000);
|
||||
printf("Time to wait: %dms\n", timeout_remaining_ms(&to));
|
||||
printf("Sleeping for 1s\n");
|
||||
sleep(1);
|
||||
timeout_update(&to);
|
||||
assert(!timeout_check(&to));
|
||||
printf("Sleeping for 1s\n");
|
||||
sleep(1);
|
||||
timeout_update(&to);
|
||||
assert(!timeout_check(&to));
|
||||
printf("Remaining: %ums\n", timeout_remaining_ms(&to));
|
||||
printf("Sleeping for 1s\n");
|
||||
sleep(1);
|
||||
timeout_update(&to);
|
||||
assert(timeout_check(&to));
|
||||
printf("Timeout expired\n");
|
||||
printf("Starting 2s timeout\n");
|
||||
timeout_start(&to, 2000);
|
||||
printf("Limiting steps to 1s\n");
|
||||
timeout_limit(&to, 1000);
|
||||
printf("Time to wait: %ums\n", timeout_remaining_ms(&to));
|
||||
printf("Sleeping for 1s\n");
|
||||
sleep(1);
|
||||
timeout_update(&to);
|
||||
assert(!timeout_check(&to));
|
||||
printf("Remaining: %ums\n", timeout_remaining_ms(&to));
|
||||
printf("Sleeping for 1s\n");
|
||||
sleep(1);
|
||||
timeout_update(&to);
|
||||
assert(timeout_check(&to));
|
||||
printf("Timeout expired\n");
|
||||
|
||||
return 0;
|
||||
}
|
174
timing.c
174
timing.c
@ -1,174 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libserialport project.
|
||||
*
|
||||
* Copyright (C) 2019 Martin Ling <martin-libserialport@earth.li>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libserialport_internal.h"
|
||||
|
||||
SP_PRIV void time_get(struct time *time)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER count;
|
||||
QueryPerformanceCounter(&count);
|
||||
time->ticks = count.QuadPart;
|
||||
#elif defined(HAVE_CLOCK_GETTIME)
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
time->tv.tv_sec = ts.tv_sec;
|
||||
time->tv.tv_usec = ts.tv_nsec / 1000;
|
||||
#elif defined(__APPLE__)
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
uint64_t ticks = mach_absolute_time();
|
||||
uint64_t ns = (ticks * info.numer) / info.denom;
|
||||
time->tv.tv_sec = ns / 1000000000;
|
||||
time->tv.tv_usec = (ns % 1000000000) / 1000;
|
||||
#else
|
||||
gettimeofday(&time->tv, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV void time_set_ms(struct time *time, unsigned int ms)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
time->ticks = ms * (frequency.QuadPart / 1000);
|
||||
#else
|
||||
time->tv.tv_sec = ms / 1000;
|
||||
time->tv.tv_usec = (ms % 1000) * 1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV void time_add(const struct time *a,
|
||||
const struct time *b, struct time *result)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
result->ticks = a->ticks + b->ticks;
|
||||
#else
|
||||
timeradd(&a->tv, &b->tv, &result->tv);
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV void time_sub(const struct time *a,
|
||||
const struct time *b, struct time *result)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
result->ticks = a->ticks - b->ticks;
|
||||
#else
|
||||
timersub(&a->tv, &b->tv, &result->tv);
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV bool time_greater(const struct time *a, const struct time *b)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return (a->ticks > b->ticks);
|
||||
#else
|
||||
return timercmp(&a->tv, &b->tv, >);
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV void time_as_timeval(const struct time *time, struct timeval *tv)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
tv->tv_sec = (long) (time->ticks / frequency.QuadPart);
|
||||
tv->tv_usec = (long) ((time->ticks % frequency.QuadPart) /
|
||||
(frequency.QuadPart / 1000000));
|
||||
#else
|
||||
*tv = time->tv;
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV unsigned int time_as_ms(const struct time *time)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
return (unsigned int) (time->ticks / (frequency.QuadPart / 1000));
|
||||
#else
|
||||
return time->tv.tv_sec * 1000 + time->tv.tv_usec / 1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
SP_PRIV void timeout_start(struct timeout *timeout, unsigned int timeout_ms)
|
||||
{
|
||||
timeout->ms = timeout_ms;
|
||||
|
||||
/* Get time at start of operation. */
|
||||
time_get(&timeout->start);
|
||||
/* Define duration of timeout. */
|
||||
time_set_ms(&timeout->delta, timeout_ms);
|
||||
/* Calculate time at which we should give up. */
|
||||
time_add(&timeout->start, &timeout->delta, &timeout->end);
|
||||
/* Disable limit unless timeout_limit() called. */
|
||||
timeout->limit_ms = 0;
|
||||
/* First blocking call has not yet been made. */
|
||||
timeout->calls_started = false;
|
||||
}
|
||||
|
||||
SP_PRIV void timeout_limit(struct timeout *timeout, unsigned int limit_ms)
|
||||
{
|
||||
timeout->limit_ms = limit_ms;
|
||||
timeout->overflow = (timeout->ms > timeout->limit_ms);
|
||||
time_set_ms(&timeout->delta_max, timeout->limit_ms);
|
||||
}
|
||||
|
||||
SP_PRIV bool timeout_check(struct timeout *timeout)
|
||||
{
|
||||
if (!timeout->calls_started)
|
||||
return false;
|
||||
|
||||
if (timeout->ms == 0)
|
||||
return false;
|
||||
|
||||
time_get(&timeout->now);
|
||||
time_sub(&timeout->end, &timeout->now, &timeout->delta);
|
||||
if (timeout->limit_ms)
|
||||
if ((timeout->overflow = time_greater(&timeout->delta, &timeout->delta_max)))
|
||||
timeout->delta = timeout->delta_max;
|
||||
|
||||
return time_greater(&timeout->now, &timeout->end);
|
||||
}
|
||||
|
||||
SP_PRIV void timeout_update(struct timeout *timeout)
|
||||
{
|
||||
timeout->calls_started = true;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
SP_PRIV struct timeval *timeout_timeval(struct timeout *timeout)
|
||||
{
|
||||
if (timeout->ms == 0)
|
||||
return NULL;
|
||||
|
||||
time_as_timeval(&timeout->delta, &timeout->delta_tv);
|
||||
|
||||
return &timeout->delta_tv;
|
||||
}
|
||||
#endif
|
||||
|
||||
SP_PRIV unsigned int timeout_remaining_ms(struct timeout *timeout)
|
||||
{
|
||||
if (timeout->limit_ms && timeout->overflow)
|
||||
return timeout->limit_ms;
|
||||
else
|
||||
return time_as_ms(&timeout->delta);
|
||||
}
|
569
windows.c
569
windows.c
@ -1,569 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libserialport project.
|
||||
*
|
||||
* Copyright (C) 2013-2014 Martin Ling <martin-libserialport@earth.li>
|
||||
* Copyright (C) 2014 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libserialport_internal.h"
|
||||
|
||||
/* USB path is a string of at most 8 decimal numbers < 128 separated by dots. */
|
||||
#define MAX_USB_PATH ((8 * 3) + (7 * 1) + 1)
|
||||
|
||||
static void enumerate_hub(struct sp_port *port, const char *hub_name,
|
||||
const char *parent_path, DEVINST dev_inst);
|
||||
|
||||
static char *wc_to_utf8(PWCHAR wc_buffer, ULONG wc_bytes)
|
||||
{
|
||||
ULONG wc_length = wc_bytes / sizeof(WCHAR);
|
||||
ULONG utf8_bytes;
|
||||
WCHAR *wc_str = NULL;
|
||||
char *utf8_str = NULL;
|
||||
|
||||
/* Allocate aligned wide char buffer */
|
||||
if (!(wc_str = malloc((wc_length + 1) * sizeof(WCHAR))))
|
||||
goto wc_to_utf8_end;
|
||||
|
||||
/* Zero-terminate the wide char string. */
|
||||
memcpy(wc_str, wc_buffer, wc_bytes);
|
||||
wc_str[wc_length] = 0;
|
||||
|
||||
/* Compute the size of the UTF-8 converted string. */
|
||||
if (!(utf8_bytes = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wc_str, -1,
|
||||
NULL, 0, NULL, NULL)))
|
||||
goto wc_to_utf8_end;
|
||||
|
||||
/* Allocate UTF-8 output buffer. */
|
||||
if (!(utf8_str = malloc(utf8_bytes)))
|
||||
goto wc_to_utf8_end;
|
||||
|
||||
/* Actually converted to UTF-8. */
|
||||
if (!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wc_str, -1,
|
||||
utf8_str, utf8_bytes, NULL, NULL)) {
|
||||
free(utf8_str);
|
||||
utf8_str = NULL;
|
||||
goto wc_to_utf8_end;
|
||||
}
|
||||
|
||||
wc_to_utf8_end:
|
||||
if (wc_str)
|
||||
free(wc_str);
|
||||
|
||||
return utf8_str;
|
||||
}
|
||||
|
||||
static char *get_root_hub_name(HANDLE host_controller)
|
||||
{
|
||||
USB_ROOT_HUB_NAME root_hub_name;
|
||||
PUSB_ROOT_HUB_NAME root_hub_name_wc;
|
||||
char *root_hub_name_utf8;
|
||||
ULONG size = 0;
|
||||
|
||||
/* Compute the size of the root hub name string. */
|
||||
if (!DeviceIoControl(host_controller, IOCTL_USB_GET_ROOT_HUB_NAME, 0, 0,
|
||||
&root_hub_name, sizeof(root_hub_name), &size, NULL))
|
||||
return NULL;
|
||||
|
||||
/* Allocate wide char root hub name string. */
|
||||
size = root_hub_name.ActualLength;
|
||||
if (!(root_hub_name_wc = malloc(size)))
|
||||
return NULL;
|
||||
|
||||
/* Actually get the root hub name string. */
|
||||
if (!DeviceIoControl(host_controller, IOCTL_USB_GET_ROOT_HUB_NAME,
|
||||
NULL, 0, root_hub_name_wc, size, &size, NULL)) {
|
||||
free(root_hub_name_wc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert the root hub name string to UTF-8. */
|
||||
root_hub_name_utf8 = wc_to_utf8(root_hub_name_wc->RootHubName, size - offsetof(USB_ROOT_HUB_NAME, RootHubName));
|
||||
free(root_hub_name_wc);
|
||||
return root_hub_name_utf8;
|
||||
}
|
||||
|
||||
static char *get_external_hub_name(HANDLE hub, ULONG connection_index)
|
||||
{
|
||||
USB_NODE_CONNECTION_NAME ext_hub_name;
|
||||
PUSB_NODE_CONNECTION_NAME ext_hub_name_wc;
|
||||
char *ext_hub_name_utf8;
|
||||
ULONG size;
|
||||
|
||||
/* Compute the size of the external hub name string. */
|
||||
ext_hub_name.ConnectionIndex = connection_index;
|
||||
if (!DeviceIoControl(hub, IOCTL_USB_GET_NODE_CONNECTION_NAME,
|
||||
&ext_hub_name, sizeof(ext_hub_name),
|
||||
&ext_hub_name, sizeof(ext_hub_name), &size, NULL))
|
||||
return NULL;
|
||||
|
||||
/* Allocate wide char external hub name string. */
|
||||
size = ext_hub_name.ActualLength;
|
||||
if (size <= sizeof(ext_hub_name)
|
||||
|| !(ext_hub_name_wc = malloc(size)))
|
||||
return NULL;
|
||||
|
||||
/* Get the name of the external hub attached to the specified port. */
|
||||
ext_hub_name_wc->ConnectionIndex = connection_index;
|
||||
if (!DeviceIoControl(hub, IOCTL_USB_GET_NODE_CONNECTION_NAME,
|
||||
ext_hub_name_wc, size,
|
||||
ext_hub_name_wc, size, &size, NULL)) {
|
||||
free(ext_hub_name_wc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert the external hub name string to UTF-8. */
|
||||
ext_hub_name_utf8 = wc_to_utf8(ext_hub_name_wc->NodeName, size - offsetof(USB_NODE_CONNECTION_NAME, NodeName));
|
||||
free(ext_hub_name_wc);
|
||||
return ext_hub_name_utf8;
|
||||
}
|
||||
|
||||
static char *get_string_descriptor(HANDLE hub_device, ULONG connection_index,
|
||||
UCHAR descriptor_index)
|
||||
{
|
||||
char desc_req_buf[sizeof(USB_DESCRIPTOR_REQUEST) +
|
||||
MAXIMUM_USB_STRING_LENGTH] = { 0 };
|
||||
PUSB_DESCRIPTOR_REQUEST desc_req = (void *)desc_req_buf;
|
||||
PUSB_STRING_DESCRIPTOR desc = (void *)(desc_req + 1);
|
||||
ULONG size = sizeof(desc_req_buf);
|
||||
|
||||
desc_req->ConnectionIndex = connection_index;
|
||||
desc_req->SetupPacket.wValue = (USB_STRING_DESCRIPTOR_TYPE << 8)
|
||||
| descriptor_index;
|
||||
desc_req->SetupPacket.wIndex = 0;
|
||||
desc_req->SetupPacket.wLength = (USHORT) (size - sizeof(*desc_req));
|
||||
|
||||
if (!DeviceIoControl(hub_device,
|
||||
IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION,
|
||||
desc_req, size, desc_req, size, &size, NULL)
|
||||
|| size < 2
|
||||
|| desc->bDescriptorType != USB_STRING_DESCRIPTOR_TYPE
|
||||
|| desc->bLength != size - sizeof(*desc_req)
|
||||
|| desc->bLength % 2)
|
||||
return NULL;
|
||||
|
||||
return wc_to_utf8(desc->bString, desc->bLength - offsetof(USB_STRING_DESCRIPTOR, bString));
|
||||
}
|
||||
|
||||
static void enumerate_hub_ports(struct sp_port *port, HANDLE hub_device,
|
||||
ULONG nb_ports, const char *parent_path, DEVINST dev_inst)
|
||||
{
|
||||
char path[MAX_USB_PATH];
|
||||
ULONG index = 0;
|
||||
|
||||
for (index = 1; index <= nb_ports; index++) {
|
||||
PUSB_NODE_CONNECTION_INFORMATION_EX connection_info_ex;
|
||||
ULONG size = sizeof(*connection_info_ex) + (30 * sizeof(USB_PIPE_INFO));
|
||||
|
||||
if (!(connection_info_ex = malloc(size)))
|
||||
break;
|
||||
|
||||
connection_info_ex->ConnectionIndex = index;
|
||||
if (!DeviceIoControl(hub_device,
|
||||
IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX,
|
||||
connection_info_ex, size,
|
||||
connection_info_ex, size, &size, NULL)) {
|
||||
/*
|
||||
* Try to get CONNECTION_INFORMATION if
|
||||
* CONNECTION_INFORMATION_EX did not work.
|
||||
*/
|
||||
PUSB_NODE_CONNECTION_INFORMATION connection_info;
|
||||
|
||||
size = sizeof(*connection_info) + (30 * sizeof(USB_PIPE_INFO));
|
||||
if (!(connection_info = malloc(size))) {
|
||||
free(connection_info_ex);
|
||||
continue;
|
||||
}
|
||||
connection_info->ConnectionIndex = index;
|
||||
if (!DeviceIoControl(hub_device,
|
||||
IOCTL_USB_GET_NODE_CONNECTION_INFORMATION,
|
||||
connection_info, size,
|
||||
connection_info, size, &size, NULL)) {
|
||||
free(connection_info);
|
||||
free(connection_info_ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
connection_info_ex->ConnectionIndex = connection_info->ConnectionIndex;
|
||||
connection_info_ex->DeviceDescriptor = connection_info->DeviceDescriptor;
|
||||
connection_info_ex->DeviceIsHub = connection_info->DeviceIsHub;
|
||||
connection_info_ex->DeviceAddress = connection_info->DeviceAddress;
|
||||
free(connection_info);
|
||||
}
|
||||
|
||||
if (connection_info_ex->DeviceIsHub) {
|
||||
/* Recursively enumerate external hub. */
|
||||
PCHAR ext_hub_name;
|
||||
if ((ext_hub_name = get_external_hub_name(hub_device, index))) {
|
||||
snprintf(path, sizeof(path), "%s%ld.",
|
||||
parent_path, connection_info_ex->ConnectionIndex);
|
||||
enumerate_hub(port, ext_hub_name, path, dev_inst);
|
||||
}
|
||||
free(connection_info_ex);
|
||||
} else {
|
||||
snprintf(path, sizeof(path), "%s%ld",
|
||||
parent_path, connection_info_ex->ConnectionIndex);
|
||||
|
||||
/* Check if this device is the one we search for. */
|
||||
if (strcmp(path, port->usb_path)) {
|
||||
free(connection_info_ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Finally grab detailed information regarding the device. */
|
||||
port->usb_address = connection_info_ex->DeviceAddress + 1;
|
||||
port->usb_vid = connection_info_ex->DeviceDescriptor.idVendor;
|
||||
port->usb_pid = connection_info_ex->DeviceDescriptor.idProduct;
|
||||
|
||||
if (connection_info_ex->DeviceDescriptor.iManufacturer)
|
||||
port->usb_manufacturer = get_string_descriptor(hub_device, index,
|
||||
connection_info_ex->DeviceDescriptor.iManufacturer);
|
||||
if (connection_info_ex->DeviceDescriptor.iProduct)
|
||||
port->usb_product = get_string_descriptor(hub_device, index,
|
||||
connection_info_ex->DeviceDescriptor.iProduct);
|
||||
if (connection_info_ex->DeviceDescriptor.iSerialNumber) {
|
||||
port->usb_serial = get_string_descriptor(hub_device, index,
|
||||
connection_info_ex->DeviceDescriptor.iSerialNumber);
|
||||
if (port->usb_serial == NULL) {
|
||||
//composite device, get the parent's serial number
|
||||
char device_id[MAX_DEVICE_ID_LEN];
|
||||
if (CM_Get_Parent(&dev_inst, dev_inst, 0) == CR_SUCCESS) {
|
||||
if (CM_Get_Device_IDA(dev_inst, device_id, sizeof(device_id), 0) == CR_SUCCESS)
|
||||
port->usb_serial = strdup(strrchr(device_id, '\\')+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(connection_info_ex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void enumerate_hub(struct sp_port *port, const char *hub_name,
|
||||
const char *parent_path, DEVINST dev_inst)
|
||||
{
|
||||
USB_NODE_INFORMATION hub_info;
|
||||
HANDLE hub_device;
|
||||
ULONG size = sizeof(hub_info);
|
||||
char *device_name;
|
||||
|
||||
/* Open the hub with its full name. */
|
||||
if (!(device_name = malloc(strlen("\\\\.\\") + strlen(hub_name) + 1)))
|
||||
return;
|
||||
strcpy(device_name, "\\\\.\\");
|
||||
strcat(device_name, hub_name);
|
||||
hub_device = CreateFileA(device_name, GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
free(device_name);
|
||||
if (hub_device == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
/* Get the number of ports of the hub. */
|
||||
if (DeviceIoControl(hub_device, IOCTL_USB_GET_NODE_INFORMATION,
|
||||
&hub_info, size, &hub_info, size, &size, NULL))
|
||||
/* Enumerate the ports of the hub. */
|
||||
enumerate_hub_ports(port, hub_device,
|
||||
hub_info.u.HubInformation.HubDescriptor.bNumberOfPorts, parent_path, dev_inst);
|
||||
|
||||
CloseHandle(hub_device);
|
||||
}
|
||||
|
||||
static void enumerate_host_controller(struct sp_port *port,
|
||||
HANDLE host_controller_device,
|
||||
DEVINST dev_inst)
|
||||
{
|
||||
char *root_hub_name;
|
||||
|
||||
if ((root_hub_name = get_root_hub_name(host_controller_device))) {
|
||||
enumerate_hub(port, root_hub_name, "", dev_inst);
|
||||
free(root_hub_name);
|
||||
}
|
||||
}
|
||||
|
||||
static void get_usb_details(struct sp_port *port, DEVINST dev_inst_match)
|
||||
{
|
||||
HDEVINFO device_info;
|
||||
SP_DEVINFO_DATA device_info_data;
|
||||
ULONG i, size = 0;
|
||||
|
||||
device_info = SetupDiGetClassDevs(&GUID_CLASS_USB_HOST_CONTROLLER, NULL, NULL,
|
||||
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
device_info_data.cbSize = sizeof(device_info_data);
|
||||
|
||||
for (i = 0; SetupDiEnumDeviceInfo(device_info, i, &device_info_data); i++) {
|
||||
SP_DEVICE_INTERFACE_DATA device_interface_data;
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA device_detail_data;
|
||||
DEVINST dev_inst = dev_inst_match;
|
||||
HANDLE host_controller_device;
|
||||
|
||||
device_interface_data.cbSize = sizeof(device_interface_data);
|
||||
if (!SetupDiEnumDeviceInterfaces(device_info, 0,
|
||||
&GUID_CLASS_USB_HOST_CONTROLLER,
|
||||
i, &device_interface_data))
|
||||
continue;
|
||||
|
||||
if (!SetupDiGetDeviceInterfaceDetail(device_info,&device_interface_data,
|
||||
NULL, 0, &size, NULL)
|
||||
&& GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
continue;
|
||||
|
||||
if (!(device_detail_data = malloc(size)))
|
||||
continue;
|
||||
device_detail_data->cbSize = sizeof(*device_detail_data);
|
||||
if (!SetupDiGetDeviceInterfaceDetail(device_info,&device_interface_data,
|
||||
device_detail_data, size, &size,
|
||||
NULL)) {
|
||||
free(device_detail_data);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (CM_Get_Parent(&dev_inst, dev_inst, 0) == CR_SUCCESS
|
||||
&& dev_inst != device_info_data.DevInst) { }
|
||||
if (dev_inst != device_info_data.DevInst) {
|
||||
free(device_detail_data);
|
||||
continue;
|
||||
}
|
||||
|
||||
port->usb_bus = i + 1;
|
||||
|
||||
host_controller_device = CreateFile(device_detail_data->DevicePath,
|
||||
GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (host_controller_device != INVALID_HANDLE_VALUE) {
|
||||
enumerate_host_controller(port, host_controller_device, dev_inst_match);
|
||||
CloseHandle(host_controller_device);
|
||||
}
|
||||
free(device_detail_data);
|
||||
}
|
||||
|
||||
SetupDiDestroyDeviceInfoList(device_info);
|
||||
return;
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
||||
{
|
||||
/*
|
||||
* Description limited to 127 char, anything longer
|
||||
* would not be user friendly anyway.
|
||||
*/
|
||||
char description[128];
|
||||
SP_DEVINFO_DATA device_info_data = { .cbSize = sizeof(device_info_data) };
|
||||
HDEVINFO device_info;
|
||||
int i;
|
||||
|
||||
device_info = SetupDiGetClassDevs(NULL, 0, 0,
|
||||
DIGCF_PRESENT | DIGCF_ALLCLASSES);
|
||||
if (device_info == INVALID_HANDLE_VALUE)
|
||||
RETURN_FAIL("SetupDiGetClassDevs() failed");
|
||||
|
||||
for (i = 0; SetupDiEnumDeviceInfo(device_info, i, &device_info_data); i++) {
|
||||
HKEY device_key;
|
||||
DEVINST dev_inst;
|
||||
char value[8], class[16];
|
||||
DWORD size, type;
|
||||
CONFIGRET cr;
|
||||
|
||||
/* Check if this is the device we are looking for. */
|
||||
device_key = SetupDiOpenDevRegKey(device_info, &device_info_data,
|
||||
DICS_FLAG_GLOBAL, 0,
|
||||
DIREG_DEV, KEY_QUERY_VALUE);
|
||||
if (device_key == INVALID_HANDLE_VALUE)
|
||||
continue;
|
||||
size = sizeof(value);
|
||||
if (RegQueryValueExA(device_key, "PortName", NULL, &type, (LPBYTE)value,
|
||||
&size) != ERROR_SUCCESS || type != REG_SZ) {
|
||||
RegCloseKey(device_key);
|
||||
continue;
|
||||
}
|
||||
RegCloseKey(device_key);
|
||||
value[sizeof(value) - 1] = 0;
|
||||
if (strcmp(value, port->name))
|
||||
continue;
|
||||
|
||||
/* Check port transport type. */
|
||||
dev_inst = device_info_data.DevInst;
|
||||
size = sizeof(class);
|
||||
cr = CR_FAILURE;
|
||||
while (CM_Get_Parent(&dev_inst, dev_inst, 0) == CR_SUCCESS &&
|
||||
(cr = CM_Get_DevNode_Registry_PropertyA(dev_inst,
|
||||
CM_DRP_CLASS, 0, class, &size, 0)) != CR_SUCCESS) { }
|
||||
if (cr == CR_SUCCESS) {
|
||||
if (!strcmp(class, "USB"))
|
||||
port->transport = SP_TRANSPORT_USB;
|
||||
}
|
||||
|
||||
/* Get port description (friendly name). */
|
||||
dev_inst = device_info_data.DevInst;
|
||||
size = sizeof(description);
|
||||
while ((cr = CM_Get_DevNode_Registry_PropertyA(dev_inst,
|
||||
CM_DRP_FRIENDLYNAME, 0, description, &size, 0)) != CR_SUCCESS
|
||||
&& CM_Get_Parent(&dev_inst, dev_inst, 0) == CR_SUCCESS) { }
|
||||
if (cr == CR_SUCCESS)
|
||||
port->description = strdup(description);
|
||||
|
||||
/* Get more informations for USB connected ports. */
|
||||
if (port->transport == SP_TRANSPORT_USB) {
|
||||
char usb_path[MAX_USB_PATH] = "", tmp[MAX_USB_PATH];
|
||||
char device_id[MAX_DEVICE_ID_LEN];
|
||||
|
||||
/* Recurse over parents to build the USB device path. */
|
||||
dev_inst = device_info_data.DevInst;
|
||||
do {
|
||||
/* Verify that this layer of the tree is USB related. */
|
||||
if (CM_Get_Device_IDA(dev_inst, device_id,
|
||||
sizeof(device_id), 0) != CR_SUCCESS
|
||||
|| strncmp(device_id, "USB\\", 4))
|
||||
continue;
|
||||
|
||||
/* Discard one layer for composite devices. */
|
||||
char compat_ids[512], *p = compat_ids;
|
||||
size = sizeof(compat_ids);
|
||||
if (CM_Get_DevNode_Registry_PropertyA(dev_inst,
|
||||
CM_DRP_COMPATIBLEIDS, 0,
|
||||
&compat_ids,
|
||||
&size, 0) == CR_SUCCESS) {
|
||||
while (*p) {
|
||||
if (!strncmp(p, "USB\\COMPOSITE", 13))
|
||||
break;
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
if (*p)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Stop the recursion when reaching the USB root. */
|
||||
if (!strncmp(device_id, "USB\\ROOT", 8))
|
||||
break;
|
||||
|
||||
/* Prepend the address of current USB layer to the USB path. */
|
||||
DWORD address;
|
||||
size = sizeof(address);
|
||||
if (CM_Get_DevNode_Registry_PropertyA(dev_inst, CM_DRP_ADDRESS,
|
||||
0, &address, &size, 0) == CR_SUCCESS) {
|
||||
strcpy(tmp, usb_path);
|
||||
snprintf(usb_path, sizeof(usb_path), "%d%s%s",
|
||||
(int)address, *tmp ? "." : "", tmp);
|
||||
}
|
||||
} while (CM_Get_Parent(&dev_inst, dev_inst, 0) == CR_SUCCESS);
|
||||
|
||||
port->usb_path = strdup(usb_path);
|
||||
|
||||
/* Wake up the USB device to be able to read string descriptor. */
|
||||
char *escaped_port_name;
|
||||
HANDLE handle;
|
||||
if (!(escaped_port_name = malloc(strlen(port->name) + 5)))
|
||||
RETURN_ERROR(SP_ERR_MEM, "Escaped port name malloc failed");
|
||||
sprintf(escaped_port_name, "\\\\.\\%s", port->name);
|
||||
handle = CreateFileA(escaped_port_name, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0);
|
||||
free(escaped_port_name);
|
||||
CloseHandle(handle);
|
||||
|
||||
/* Retrieve USB device details from the device descriptor. */
|
||||
get_usb_details(port, device_info_data.DevInst);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SetupDiDestroyDeviceInfoList(device_info);
|
||||
|
||||
RETURN_OK();
|
||||
}
|
||||
|
||||
SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
||||
{
|
||||
HKEY key;
|
||||
TCHAR *value, *data;
|
||||
DWORD max_value_len, max_data_size, max_data_len;
|
||||
DWORD value_len, data_size, data_len;
|
||||
DWORD type, index = 0;
|
||||
LSTATUS result;
|
||||
char *name;
|
||||
int name_len;
|
||||
int ret = SP_OK;
|
||||
|
||||
DEBUG("Opening registry key");
|
||||
if ((result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
|
||||
0, KEY_QUERY_VALUE, &key)) != ERROR_SUCCESS) {
|
||||
/* It's possible for this key to not exist if there are no serial ports
|
||||
* at all. In that case we're done. Return a failure for any other error. */
|
||||
if (result != ERROR_FILE_NOT_FOUND) {
|
||||
SetLastError(result);
|
||||
SET_FAIL(ret, "RegOpenKeyEx() failed");
|
||||
}
|
||||
goto out_done;
|
||||
}
|
||||
DEBUG("Querying registry key value and data sizes");
|
||||
if ((result = RegQueryInfoKey(key, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&max_value_len, &max_data_size, NULL, NULL)) != ERROR_SUCCESS) {
|
||||
SetLastError(result);
|
||||
SET_FAIL(ret, "RegQueryInfoKey() failed");
|
||||
goto out_close;
|
||||
}
|
||||
max_data_len = max_data_size / sizeof(TCHAR);
|
||||
if (!(value = malloc((max_value_len + 1) * sizeof(TCHAR)))) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "Registry value malloc failed");
|
||||
goto out_close;
|
||||
}
|
||||
if (!(data = malloc((max_data_len + 1) * sizeof(TCHAR)))) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "Registry data malloc failed");
|
||||
goto out_free_value;
|
||||
}
|
||||
DEBUG("Iterating over values");
|
||||
while (
|
||||
value_len = max_value_len + 1,
|
||||
data_size = max_data_size,
|
||||
RegEnumValue(key, index, value, &value_len,
|
||||
NULL, &type, (LPBYTE)data, &data_size) == ERROR_SUCCESS)
|
||||
{
|
||||
if (type == REG_SZ) {
|
||||
data_len = data_size / sizeof(TCHAR);
|
||||
data[data_len] = '\0';
|
||||
#ifdef UNICODE
|
||||
name_len = WideCharToMultiByte(CP_ACP, 0, data, -1, NULL, 0, NULL, NULL);
|
||||
#else
|
||||
name_len = data_len + 1;
|
||||
#endif
|
||||
if (!(name = malloc(name_len))) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "Registry port name malloc failed");
|
||||
goto out;
|
||||
}
|
||||
#ifdef UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, data, -1, name, name_len, NULL, NULL);
|
||||
#else
|
||||
strcpy(name, data);
|
||||
#endif
|
||||
DEBUG_FMT("Found port %s", name);
|
||||
if (!(*list = list_append(*list, name))) {
|
||||
SET_ERROR(ret, SP_ERR_MEM, "List append failed");
|
||||
free(name);
|
||||
goto out;
|
||||
}
|
||||
free(name);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
out:
|
||||
free(data);
|
||||
out_free_value:
|
||||
free(value);
|
||||
out_close:
|
||||
RegCloseKey(key);
|
||||
out_done:
|
||||
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user