Commit graph

42 commits

Author SHA1 Message Date
Nathan Hjelm
a499ef20a1 xusb: fix typo
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
2016-03-05 08:02:58 -07:00
Stefan Tauner
1fd08a1513 Replace obsolete usleep with nanosleep
This fixes compiling libusb with uclibc.

Closes #141, #165

Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
2016-03-05 07:55:25 -07:00
Pete Batard
ada59db186 Windows: Silence VS2013 code analysis warnings
* Also update Windows version report for Windows 10
2014-11-13 22:03:30 +00:00
Pete Batard
c0f5e58acb samples: set xusb to also produce debug output during init when -d is specified
* This can be quite useful for troubleshooting user issues
2014-05-18 19:49:51 +01:00
Pete Batard
bcc4e517d5 core: fix/silence issues reported by Coverity
* 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.
2014-05-16 23:01:57 +01:00
hjelmn@cs.unm.edu
1eff220474 Misc: Revert all references to libusb/libusb.info 2014-01-08 23:51:01 +00:00
Pete Batard
16692c825e examples: add an option to force a device request for WCID descriptors
* 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.
2013-09-29 21:39:26 +01:00
Ludovic Rousseau
c393574a01 examples: check value returned by libusb_bulk_transfer()
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).
2013-09-28 12:17:58 +02:00
Sean McBride
ce8da723b4 made some globals static to fix warnings 2013-07-30 10:44:13 -06:00
Hans de Goede
02281fda6e examples: use libusb_set_auto_detach_kernel_driver()
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>
2013-06-19 11:04:15 +02:00
Ludovic Rousseau
cf8a313b2c Examples: add a missing \n at end of error messages 2013-06-11 17:35:11 +02:00
Hans de Goede
511ed18228 Core: Add a libusb_strerror() function
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
2013-06-10 00:16:36 +01:00
Hans de Goede
d7b796f1fe Add BOS descriptor support
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>
2013-05-30 14:20:51 +02:00
Hans de Goede
ef698c633d Add superspeed endpoint companion descriptor support
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>
2013-05-30 14:20:44 +02:00
Hans de Goede
f3fcf84026 Examples: Fix use of deprecated libusb_get_port_path
While at it also simplify the path printing in listdevs

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-17 10:42:47 +02:00
Pete Batard
e0628c566a Core: Add HID and kernel detach capability detection for all backends
* 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
2013-04-02 19:13:47 +01:00
Pete Batard
a0beff7d98 Samples: Reinstate interface requests when querying WCID devices
* Reverts commit 939a4782b2.
* Closes #96
2013-03-05 20:41:36 +00:00
Pete Batard
0ded9c126e Misc: Simplify includes and misc. cleanup
* 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
2013-02-27 22:58:49 +00:00
Toby Gray
244271931a WinCE: Add support for WinCE (sources) 2013-01-23 00:40:18 +00:00
Ludovic Rousseau
6fbd3dd813 Samples: Display VID:PID of the tested device in xusb
* Also amend the wording of the "no option" comment.
* Closes #42
2012-09-14 00:38:06 +01:00
Pete Batard
8b5ba57e56 Samples: xusb improvements
* update and fix usage details
* make topology and speed printout optional (option -i)
* remove unneeded option -g
2012-09-05 22:53:41 +01:00
Pete Batard
d53c599d0b Samples: Make target mandatory with -b option in xusb 2012-08-12 22:57:10 +01:00
Pete Batard
7ec94a45ed Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
* The LOG_LEVEL_ enums, that were moved to the public API
  in 933a319469 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.
2012-07-03 11:01:41 +01:00
Pete Batard
0e0cbb6c27 Windows: Address MSVC Level 4 & WDK's OACR/Prefast warnings
* 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
2012-07-02 18:28:37 +01:00
Xiaofan Chen
5330c3d8ae Samples: Remove USB version for speed designations in xusb 2012-06-14 12:43:26 +01:00
Ludovic Rousseau
56853b54d0 Samples: Fix no previous prototype warnings in xusb 2012-06-04 01:20:45 +01:00
Pete Batard
3fae93a941 Windows: Restore HID support 2012-05-28 10:57:51 +01:00
Pete Batard
933a319469 Core: Define log levels in libusb.h
* Also update xusb sample to use these levels
2012-05-28 10:35:23 +01:00
Pete Batard
cfb8610242 All: Add parent and port topology calls
* 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
2012-05-28 10:26:44 +01:00
Pete Batard
a544e5972b Misc: Ensure all sources are UTF-8
* Also remove extra lines at the end of samples
2012-05-23 18:25:01 +01:00
Pete Batard
2075665352 Samples: prefer __linux__ over __linux define in xusb
* 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
2012-05-10 15:36:34 +01:00
Pete Batard
00d6fed8f2 Samples: fix strcat vs strlcat warning on OpenBSD
* Without this, OpenBSD produces the following warning:
  strcat() is almost always misused, please use strlcat()
2012-05-08 11:01:42 +01:00
Pete Batard
939a4782b2 Samples: Remove interface requests when querying WCID devices
* As per MS documentation, querying of the Extended Properties
  is a device request (0xC0), not an interface one (0xC1), so
  there is no issue with the WinUSB wIndex override.
2012-05-02 18:02:50 +01:00
Ludovic Rousseau
29d66c1554 Samples: Fix not handled in switch warning in xusb.c
xusb.c: In function ‘test_device’:
xusb.c:722:2: warning: enumeration value ‘USE_GENERIC’ not handled in switch [-Wswitch-enum]
2012-04-20 22:35:38 +01:00
Ludovic Rousseau
d2b7b9f78e Samples: Remove unneeded inline in xusb.c
Fixes:
warning: function ‘perr’ can never be inlined because it uses variable argument lists [-Winline]
warning: inlining failed in call to ‘perr’: function not inlinable [-Winline]
2012-04-20 22:33:24 +01:00
Ludovic Rousseau
28ab85c418 Samples: Fix initialization discards qualifiers warnings in xusb.c
xusb.c: In function ‘read_ms_winsub_feature_descriptors’:
xusb.c:542: warning: initialization discards qualifiers from pointer target type
xusb.c:543: warning: initialization discards qualifiers from pointer target type
xusb.c: In function ‘test_device’:
xusb.c:598: warning: initialization discards qualifiers from pointer target type
xusb.c:598: warning: initialization discards qualifiers from pointer target type
xusb.c:598: warning: initialization discards qualifiers from pointer target type
xusb.c:599: warning: initialization discards qualifiers from pointer target type
xusb.c:599: warning: initialization discards qualifiers from pointer target type
2012-04-15 01:14:09 +01:00
Ludovic Rousseau
baa5563627 Samples: Fix no previous prototype warnings in xusb.c
xusb.c:139: warning: no previous prototype for ‘display_buffer_hex’
xusb.c:169: warning: no previous prototype for ‘display_ps3_status’
xusb.c:260: warning: no previous prototype for ‘display_xbox_status’
xusb.c:281: warning: no previous prototype for ‘set_xbox_actuators’
xusb.c:299: warning: no previous prototype for ‘send_mass_storage_command’
xusb.c:354: warning: no previous prototype for ‘get_mass_storage_status’
xusb.c:401: warning: no previous prototype for ‘get_sense’
xusb.c:431: warning: no previous prototype for ‘test_mass_storage’
xusb.c:530: warning: no previous prototype for ‘read_ms_winsub_feature_descriptors’
xusb.c:583: warning: no previous prototype for ‘test_device’
2012-04-15 01:11:58 +01:00
Pete Batard
37dfd16c8c Core: Add get_version() call
* Also some formatting/typo improvements
2012-04-10 12:46:10 +01:00
Pete Batard
791b7473ec Misc: Rebrand to libusbx
* Mentions of 'libusb' in doxygen are changed to 'libusbx'
* Also update copyright notices and remove unneeded EOF LFs
2012-04-03 15:42:10 +01:00
Pete Batard
985c4fd10d Samples: Fix "warning: no newline at end of file" in xusb.c
* Also remove trailing whitespaces
2012-04-01 21:30:52 +01:00
Pete Batard
d577d4f3f8 Samples: fix a "value is always 0" Clang warning in xusb.c
* Remove the use of os_fd[i].recipient and alter comments with
  regards to Windows Extended Props test limitations with WinUSB
2012-03-28 17:48:12 +01:00
Pete Batard
743fd77dcb Examples: add xusb sample
* Also improvements to WDK build scripts:
  cd to original dir on error, use 2 cores if available
2012-03-28 00:31:50 +01:00