15 Commits

Author SHA1 Message Date
Harry Mallon
5b17c383f8 Add API support for LIBUSB_SPEED_SUPER_PLUS_X2 20Gbps USB 3.2 gen 2x2
Implement detection on darwin and linux_usbfs, and report it in xusb.

Closes #1477
2024-05-07 19:44:28 +02:00
Nathan Hjelm
3c33e499a0 Update tests and example to use the new libusb_init_context() function
This commit updates all test and example code to use the newer
libusb_init_context() function instead of libusb_init().

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
[Tormod: Update umockdev.c as well]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2023-01-20 11:04:14 +01:00
Chris Dickens
f69548c3b3 examples: Enable all examples to build on all platforms
Prior to this change, the dpfp and sam3u_benchmark examples were only
built on POSIX platforms due to a dependency on sigaction(). Furthermore
the dpfp_threaded example only worked with POSIX threads.

Lift this limitation by breaking the dependence on sigaction(). Also
provide a minimal threading abstraction so that dpfp_threaded can be
built on Windows as well.

Also merge the sources for dpfp and dpfp_threaded. The only difference
between the two is how libusb's event handling functions are called and
this can be easily handled within a single source file.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-11-10 14:13:12 -08:00
Chris Dickens
15668087a7 Fix various CI build warnings
* [-Wpointer-arith] arithmetic on a pointer to void is a GNU extension
  * [-Wswitch-enum] enumeration values 'E1, ...' not explicitly handled in switch
  * [-Wunused-parameter] unused parameter 'p'

For '-Wswitch-enum', the switch statements in the individual backends'
set_option() function has been removed. It is not expected that backends
will need to handle or be aware of all the options.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-11-09 15:51:44 -08:00
Hans de Goede
1be063f7bf examples/testlibusb: Print speed of devices
Print the speed of devices to exercise libusb_get_device_speed().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-09-14 09:48:14 +02:00
Hans de Goede
dca3e7ea36 examples/testlibusb: Add support for testing libusb_wrap_sys_device()
Sometimes it is useful to be able to test libusb_wrap_sys_device(),
add support for this to the testlibusb example

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-09-14 09:48:14 +02:00
Chris Dickens
9a1bc8cafb build: Require C11 to build and clean up autoconfig/automake files
C11 compiler support has been available for many years now. It is not
unreasonable to require this now, and doing so allows some cleanup to
the configure script. It is no longer necessary to check for compiler
support of the '-fvibility' flag because any compiler that supports C11
will support this flag as well.

Fix up the way that compiler and linker flags are passed down to the
various makefiles. The compiler flags should be shared by all, but the
linker flags and libraries should be separated between the library and
the examples/tests. The visibility flag is only relevant for the
library and the thread flags are only relevant for sources using thread
constructs, so provide them as needed.

Rearrange configure.ac to group similar functionality and consolidate
where possible.

Based on these changes, update the Travis configuration file to include
newer versions of test platforms to ensure proper C11 compiler support.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-03-30 12:28:11 -07:00
Chris Dickens
f90d07613c Windows: Remove support for WinCE and Visual Studio older than 2013
There appears to be no need for the WinCE backend anymore, and it is
increasingly difficult to keep healthy as the rest of the library
changes.

Require at least Visual Studio 2013 to compile. This simplifies matters
as there is some semblance of C99 support there.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-01-20 18:02:19 -08:00
Chris Dickens
cb95e3ad35 examples: testlibusb: Always print VID and PID in addition to strings
Previously the program would only print the VID when the manufacturer
string is unavailable and the PID when the product string is
unavailable. Change this to print the VID and PID unconditionally and
print the manufacturer and product strings similar to how the serial
number string is being printed. In addition, line up the string values
with the rest of the output.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-01-13 12:50:40 -08:00
Chris Dickens
88ded79caa examples: testlibusb: Formatting, whitespace and functional cleanup
Make the coding style and whitespace consistent with the rest of the
library source code.

In the print_device() function, the 'level' argument is unnecessary, so
remove it and the associated space padding. Switch to use printf()
directly instead of formatting the description into a single buffer.
This not only simplifies the code but avoids truncating the description
for devices with larger descriptor strings.

Make the output formatting consistent by lining up all the printed
values and using the same notation for all hexadecimal values.

Inspired by PR #452, enable printing all available BOS device
capability descriptors, not just the first one.

Closes #452

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-01-13 12:36:59 -08:00
Victor Toso
fcf9a53595 examples: Fix format-truncation on debug
As description is used only for debug, we can extend it to be sure to
fit 256 from string variable plus 3 chars from " - " as described in
gcc warning below

 | testlibusb.c: In function ‘print_device.constprop’:
 | testlibusb.c:188:51: warning: ‘ - ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
 |      snprintf(description, sizeof(description), "%s - ", string);
 |                                                    ^~~
 | testlibusb.c:188:5: note: ‘snprintf’ output between 4 and 259 bytes into a destination of size 256
 |      snprintf(description, sizeof(description), "%s - ", string);
 |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Closes #460

Signed-off-by: Victor Toso <victortoso@redhat.com>

Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
2018-12-05 10:13:08 -07:00
Chris Dickens
f69255217c examples: testlibusb: Fix DDK build warning
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2018-03-24 17:42:46 -07:00
Chris Dickens
539a3230cf Misc: Fix testlibusb build on VS2013 and earlier and suppress warnings
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2017-12-26 23:58:00 -08:00
Ludovic Rousseau
a1cf206218 examples: reformat testlibusb.c
convert from DOS to Unix text format
remove extra spaces at end of line
2017-07-12 17:10:55 +02:00
Anil Nair
bcac08d60f Examples: Ported testlibusb from libus-0.1 to libusb-1.0
This commit is based on Nathan's branch
https://github.com/hjelmn/libusb-darwin/blob/master/examples/testlibusb1.c

Closes #178

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
2016-07-21 22:08:44 -06:00