summaryrefslogtreecommitdiff
path: root/examples/xusb.c
Commit message (Collapse)AuthorAgeFilesLines
* xusb: Improve kernel driver probe messagesTormod Volden2023-01-281-3/+16
| | | | Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
* xusb: Add newlines in mass-storage test outputTormod Volden2023-01-211-4/+4
| | | | Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
* Update tests and example to use the new libusb_init_context() functionNathan Hjelm2023-01-201-1/+1
| | | | | | | | | 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>
* descriptor: Add support for BOS platform descriptor parsingDominik Boehi2023-01-191-0/+14
| | | | | | | | | Also add BOS platform descriptor dump to xusb example. Closes #1133 [Tormod: Fixed copy-pasto in Doxygen comment] Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
* xusb: Print info from IAD descriptorsRyan Metcalfe2023-01-191-0/+26
| | | | Signed-off-by: Ryan Metcalfe <ryan.metcalfe@novanta.com>
* xusb: Print total length of configuration descriptorTormod Volden2021-10-311-0/+1
| | | | Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
* Fix various typos in docs/commentsluz paz2021-10-311-2/+2
| | | | | | Found via `codespell -q 3` Closes #1015
* xusb: Print configuration descriptor lengthTormod Volden2021-10-311-1/+6
| | | | | | Also inform about reading OS string descriptor. Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
* xusb: add check for interface kernel driverNathan Hjelm2021-07-211-0/+2
| | | | | | | This commit adds a call to libusb_kernel_driver_active and prints out the result. This provides a way to quickly check the result when testing. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* build: Enable additional build errors and warningsChris Dickens2020-03-301-1/+2
| | | | | | | | | | | Help catch more errors by enabling additional build errors and warnings. Address some of the warnings seen with these new flags, including moving the libusb_transfer structure back out of the usbi_transfer structure to address 'warning: invalid use of structure with flexible array member'. Apparently a structure ending with a flexible array member is not okay with the compiler as the last member within another structure. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Remove support for WinCE and Visual Studio older than 2013Chris Dickens2020-01-201-18/+13
| | | | | | | | | | | 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>
* xusb: Report SuperSpeedPlusHarry Mallon2019-04-041-3/+3
| | | | | | Closes #530 Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* Fixed many compiler warnings about sign and size mismatchSean McBride2019-01-301-1/+1
| | | | | | | | | | - added various casts - added some asserts where the casts made assumptions - enabled additional warnings in Xcode project (especially -Wshorten-64-to-32) Closes #509 Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* Fixed various trivial cppcheck 1.80 warningsSean McBride2017-12-281-1/+1
| | | | | | | | | | | | | | | | | Specifically: redundantAssignment,examples/dpfp.c:422,style,Variable 'r' is reassigned a value before the old one has been used. redundantAssignment,libusb/os/threads_posix.c:64,style,Variable 'ret' is reassigned a value before the old one has been used. unreadVariable,libusb/os/netbsd_usb.c:217,style,Variable 'hpriv' is assigned a value that is never used. unreadVariable,libusb/os/netbsd_usb.c:235,style,Variable 'hpriv' is assigned a value that is never used. unreadVariable,libusb/os/openbsd_usb.c:251,style,Variable 'hpriv' is assigned a value that is never used. unreadVariable,libusb/os/openbsd_usb.c:275,style,Variable 'hpriv' is assigned a value that is never used. unsignedLessThanZero,libusb/os/windows_winusb.c:259,style,Checking if unsigned variable '_index' is less than zero. unsignedLessThanZero,libusb/os/windows_winusb.c:298,style,Checking if unsigned variable '_index' is less than zero. unsignedLessThanZero,libusb/os/windows_winusb.c:367,style,Checking if unsigned variable '_index' is less than zero. invalidPrintfArgType_sint,examples/xusb.c:534,warning,%d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* examples: xusb: replaced insecure sprintf with snprintfSean McBride2017-12-281-1/+2
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Examples: Misc. cleanup to xusbChris Dickens2017-12-261-9/+6
| | | | | | | Make data that is unchanged const, remove an unused return value, and add a missing newline to an error message. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Examples: Improvements to xusb's support for Microsoft OS descriptorsChris Dickens2017-12-261-5/+14
| | | | | | | | | | | | | As noted in issue #269, the current xusb implementation does not handle Microsoft OS descriptors from devices whose vendor code is greater than 0x7F. This commit addresses this limitation by using libusb_get_string_descriptor() instead of the ASCII variant and parsing the descriptor separately. Note that this issue was addressed in PR #276, but that approach was too cryptic to read. Closes #269, Closes #276 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* examples: Fix device handle leak in xusbChris Dickens2017-08-241-12/+10
| | | | | | | | | | | | The CALL_CHECK macro returns from the current function, so in the test_device() function the device handle was being leaked when one of the functions failed. This commit adds a new CALL_CHECK_CLOSE macro that does the same as CALL_CHECK but also closes the device handle before returning. In addition, the macros are changed to declare their needed variable rather than relying on the variable to already exist within the scope of the function. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Introduce libusb_set_option() API functionChris Dickens2017-07-161-2/+2
| | | | | | | | | | | | | | This new function allows more flexibility in extending the library to support more user-configurable options. It is intended to provide a single API that can support a wide variety of needs and eliminates the need for new API functions to set future options. The function is introduced with a single option (LIBUSB_OPTION_LOG_LEVEL) that replaces the libusb_set_debug() function. Documentation relating to libusb_set_debug() and the uses of this function in the examples and tests have been updated accordingly. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* xusb: fix typoNathan Hjelm2016-03-051-1/+1
| | | | Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* Replace obsolete usleep with nanosleepStefan Tauner2016-03-051-2/+2
| | | | | | | | This fixes compiling libusb with uclibc. Closes #141, #165 Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
* Windows: Silence VS2013 code analysis warningsPete Batard2014-11-131-1/+2
| | | | * Also update Windows version report for Windows 10
* samples: set xusb to also produce debug output during init when -d is specifiedPete Batard2014-05-181-2/+21
| | | | * This can be quite useful for troubleshooting user issues
* core: fix/silence issues reported by CoverityPete Batard2014-05-161-0/+1
| | | | | | * libusb has been added to Coverity at https://scan.coverity.com/projects/2180 * Use "// coverity[keyword]" to silence the issues we don't care about * All other issues from the Windows build have been fixed, apart from the closing of the DLLs.
* Misc: Revert all references to libusb/libusb.infohjelmn@cs.unm.edu2014-01-081-2/+2
|
* examples: add an option to force a device request for WCID descriptorsPete Batard2013-09-291-1/+11
| | | | | | | | | * Add option 'w' to force the use of a Device Request rather than an Interface Request when querying the WCID OS Extended Properties descriptor. * This is due to a WinUSB limitation where all Interface Requests have the wIndex set to the interface number. * This assumes that the WCID firmware answers both Device and Interface requests equally.
* examples: check value returned by libusb_bulk_transfer()Ludovic Rousseau2013-09-281-1/+7
| | | | | | | | | Problem detected by the Coverity tool CID 1042540 (#1 of 1): Unchecked return value (CHECKED_RETURN)1. check_return: Calling function "libusb_bulk_transfer(struct libusb_device_handle *, unsigned char, unsigned char *, int, int *, unsigned int)" without checking return value (as is done elsewhere 4 out of 5 times).
* made some globals static to fix warningsSean McBride2013-07-301-5/+5
|
* examples: use libusb_set_auto_detach_kernel_driver()Hans de Goede2013-06-191-18/+1
| | | | | | | What better way to show how useful libusb_set_auto_detach_kernel_driver() is, then to use it in our examples? Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Examples: add a missing \n at end of error messagesLudovic Rousseau2013-06-111-2/+2
|
* Core: Add a libusb_strerror() functionHans de Goede2013-06-101-10/+24
| | | | | | | | | | | | | | | | | | | This patch adds the much requested libusb_strerror() function, taking into account all issues people raised wrt previous attempts. Criteria / Decisions underlying this implementation: - Must support translated messages - Must not use gettext as that does not work well in combination with Windows (when building with Visual C, or for Windows CE) - API compatible with FreeBSD and various patched libusb-s floating around - KISS: - Do not add any (other) library dependencies - Do not try to deal with message encodings (iconv), simply always return UTF-8 making encoding the problem of the application using libusb_strerror. - Defaults to English, so apps which don't want translated messages, don't need to do anything special - Defaults to English (with pure ASCII messages), so apps which don't call libusb_setlocale() don't need to worry about encoding
* Add BOS descriptor supportHans de Goede2013-05-301-1/+61
| | | | | | | Based on earlier work done on this by Maya Erez <merez@codeaurora.org>, Nathan Hjelm <hjelmn@me.com> and Pete Batard <pete@akeo.ie>. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add superspeed endpoint companion descriptor supportHans de Goede2013-05-301-0/+7
| | | | | | | Based on earlier work done on this by Maya Erez <merez@codeaurora.org>, Nathan Hjelm <hjelmn@me.com> and Pete Batard <pete@akeo.ie>. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Examples: Fix use of deprecated libusb_get_port_pathHans de Goede2013-05-171-1/+1
| | | | | | While at it also simplify the path printing in listdevs Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Core: Add HID and kernel detach capability detection for all backendsPete Batard2013-04-021-14/+11
| | | | | | | | | | * Also remove Linux special case from xusb sample. * Note that LIBUSBX_API_VERSION is incremented as a result of libusb_has_capability() returning nonzero rather than 1 when a capability is supported. * A LIBUSB_CAP_HAS_HOTPLUG is also added, though it is currently not implemented on any platform * Closes #102
* Samples: Reinstate interface requests when querying WCID devicesPete Batard2013-03-051-4/+5
| | | | | * Reverts commit 939a4782b28c36dfddb68585c4b027a4d5494a5b. * Closes #96
* Misc: Simplify includes and misc. cleanupPete Batard2013-02-271-6/+1
| | | | | | | | | | | * fxload sample provenance * No need for <sys/types.h> in samples as already in libusb.h * Don't bother about sscanf_s in xusb * Use HAVE_### and rely on config.h where possible * Formal inclusion of <winsock.h> in libusb.h for WinCE and WDK * Cleanup of Windows' config.h * Avoid ENAMETOOLONG and ENOTEMPTY conflict between errno.h and winsock.h for WinCE * Additional newlines & braces cleanup
* WinCE: Add support for WinCE (sources)Toby Gray2013-01-231-1/+1
|
* Samples: Display VID:PID of the tested device in xusbLudovic Rousseau2012-09-141-2/+2
| | | | | * Also amend the wording of the "no option" comment. * Closes #42
* Samples: xusb improvementsPete Batard2012-09-051-21/+28
| | | | | | * update and fix usage details * make topology and speed printout optional (option -i) * remove unneeded option -g
* Samples: Make target mandatory with -b option in xusbPete Batard2012-08-121-8/+6
|
* Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflictsPete Batard2012-07-031-1/+1
| | | | | | | | | * The LOG_LEVEL_ enums, that were moved to the public API in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict with applications/headers that also define their own LOG_LEVEL_ values internally. * As a matter of fact, as per Trac #31, this produces a conflict with libusb-compat, as it defines its own levels.
* Windows: Address MSVC Level 4 & WDK's OACR/Prefast warningsPete Batard2012-07-021-1/+4
| | | | | | | | | | | | | * The library is now compiled with warning level 4 for VS2010 * Move silencing of 4200, 28125 and 28719 to msvc/config.h * Add fixes in core to silence unused variables warnings * Ensure that spinlock is always set interlocked in poll_windows * Add missing check for calloc return value * Fix data assignation in conditionals warnings * Fix an OACR/Prefast error related to the use of strncpy in xusb.c * Also fixes whitespace inconsistencies in core * Issues reported by Orin Eman and Xiaofan Chen. See: https://sourceforge.net/mailarchive/message.php?msg_id=29412656
* Samples: Remove USB version for speed designations in xusbXiaofan Chen2012-06-141-2/+2
|
* Samples: Fix no previous prototype warnings in xusbLudovic Rousseau2012-06-041-2/+2
|
* Windows: Restore HID supportPete Batard2012-05-281-2/+169
|
* Core: Define log levels in libusb.hPete Batard2012-05-281-2/+1
| | | | * Also update xusb sample to use these levels
* All: Add parent and port topology callsPete Batard2012-05-281-4/+0
| | | | | | * Adds libusb_get_port_number, libusb_get_parent and libusb_get_port_path * Linux implementation provided by Alan Stern, OS X by Nathan Hjelm * Unsupported for *BSD platforms
* Misc: Ensure all sources are UTF-8Pete Batard2012-05-231-1/+1
| | | | * Also remove extra lines at the end of samples
* Samples: prefer __linux__ over __linux define in xusbPete Batard2012-05-101-3/+3
| | | | | | * While both should work, __linux__ seems to be preferred and what we use in threads_posix.c * Also fix a typo in .private/README.txt