Commit Graph

100 Commits

Author SHA1 Message Date
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
Peter Stuge f51b19db34 examples: Add sam3u_benchmark isochronous example by Harald Welte
Copied with the author's permission under LGPL-2.1 from
usb-benchmark-project/host/benchmark.c in
git://git.gnumonks.org/sam3u-tests.git commit
74959f7ee88f1597286cd435f312a8ff52c56b7e

http://git.gnumonks.org/cgi-bin/gitweb.cgi?p=sam3u-tests.git;a=blob;f=usb-benchmark-project/host/benchmark.c;h=74959f7ee88f1597286cd435f312a8ff52c56b7e

An Atmel SAM3U test firmware is also available in the above repository.

Conflicts:
	.gitignore

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-30 14:21:00 +02: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
Hans de Goede ebac6ac1b3 listdevs: Also print portpath for non root hubs
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-16 22:36:26 +02:00
Peter Stuge a1b0ae5e59 examples: Only check for HAVE_SIGACTION once in Makefile.am
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-15 20:43:35 +02:00
Nathan Hjelm 57256dd159 Add some editor meta-comments for proper tab usage
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-15 20:43:35 +02:00
Nathan Hjelm 7801ff94fa Add hotplug support.
The internal API is changing as follows:
 - Adding two new functions. usbi_connect_device, and usbi_disconnect_device.
   Backends must call these functions to add them to the context's device list
   at one of two places: initial enumeration (done at init), and on device
   attach and removal. These functions need to be called once per context.
 - Backends that support hotplug should not provide a get_device_list funtion.
   This function is now deprecated and will likely be removed once all backends
   support hotplug.

The external API is changing as follows:
 - Two new functions have been added to register and deregister callbacks for
   hotplug notification: libusb_hotplug_register_callback(),
   libusb_hotplug_deregister_callback(). Hotplug callbacks are called by
   libusb_handle_events(). Details of the new API can be found in libusb.h.
 - A new capability check has been added to check for hotplug support. See
   LIBUSB_CAP_HAS_HOTPLUG.

Aa suggested by Xiaofan add new example has been added to show how to use
the new external hotplug API. See examples/hotplugtest.c.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-15 17:28:06 +02:00
Pete Batard 77a37cba54 Samples: Fix timeout error on FX3 and logging improvements for fxload
* Add a specific ezusb_fx3_jump() that handles timeout as a non-error
  This is required as a successful jump call makes the device disconnect from the bus
* Set default verbosity to 1 and adjust some messages' verbosity level
* Add a new -q option to decrease verbosity
* Add readout of the bootloader version for FX3 devices
* Filter the image types actually supported for FX3
* Fix the "errcode shadows a global variable" warning on some systems
2013-04-14 22:38:52 +01: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 8aa50632ad Samples: More fxload improvements and cleanup
* Type detection when bus,addr is specified
* Improved check for FX3 image header
* Switch back to using -p for bus,addr and use a comma to
  match the output of listdevs
2013-03-16 23:44:25 +00:00
Ludovic Rousseau e78d37b2ac Samples: fix compiler warning
Make fx3_load_ram a static function.

ezusb.c:534: warning: no previous prototype for ‘fx3_load_ram’
2013-03-15 09:35:16 +01:00
Federico Manzan d345a1ed6b Samples: fxload improvements and cleanup
* fix C++ compilation
* use stdint types
* allow to specify bus:address as a parameter
* allocate a buffer when transferring FX3 image and check for R/W errors
2013-03-15 00:46:24 +00:00
Federico Manzan b74b7f7390 Samples: Add FX3 firmware upload support for fxload 2013-03-10 23:15:46 +00: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
Ludovic Rousseau ad26880470 Examples: Fix compiler warning
examples/ezusb.c:251:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
                off = strtoul(buf+3, NULL, 16);
                    ~ ^~~~~~~~~~~~~~~~~~~~~~~~
2013-02-15 11:19:05 +01:00
Toby Gray 244271931a WinCE: Add support for WinCE (sources) 2013-01-23 00:40:18 +00:00
Peter Stuge 94b0ccc5e5 Autotools: Carry over 2012.10.23 libusb changes
* Use LIBS instead of PC_LIBS_PRIVATE
* Move THREAD_CFLAGS & VISIBILITY_CFLAGS into AM_CFLAGS
* Use AC_SEARCH_LIBS(clock_gettime) for pthreads on Linux
2012-11-25 00:27:45 +00:00
Ludovic Rousseau 38e6eb86b2 All: Use "" instead of <> for local includes
System header files are used with #include <foo.h>
Xcode can't find local headers using this syntax.
2012-10-13 18:34:45 +01:00
Pete Batard c9ecb7255b Misc: Fix missing files from dist package 2012-09-16 17:23:36 +01:00
Ludovic Rousseau 9d50e95028 Samples: Fix compiler warnings in fxload
ezusb.c: In function  "ezusb_cpucs"
ezusb.c:163: warning: initialization discards qualifiers from pointer target type
ezusb.c: At top level:
ezusb.c:193: warning: no previous prototype for "parse_ihex"
ezusb.c:340: warning: no previous prototype for "parse_bin"
ezusb.c:377: warning: no previous prototype for "parse_iic"
ezusb.c: In function "ram_poke":
ezusb.c:451: warning: enumeration value "_undef" not handled in switch
ezusb.c:491: warning: passing argument 2 of "ezusb_write" discards qualifiers from pointer target type
2012-09-15 15:08:38 +01: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 05975333c5 Samples: Add fxload sample for Cypress EZ-USB chips
* This program was modified from the original fxload at:
  http://linux-hotplug.sourceforge.net to add libusbx
  as well as non HEX images support.
* Only supports RAM upload for now, with EEPROM and FX3
  support to be added at a later stage.
2012-09-13 23:58:09 +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 63f569be66 Misc: Fix more Clang warnings in core and darwin
* http://sourceforge.net/mailarchive/message.php?msg_id=29418038
* core.c:700:4: warning: Function call argument is an uninitialized value
* darwin_usb.c:1713:11: warning: Access to field 'cfSource' results in a
  dereference of a null pointer (loaded from variable 'hpriv')
* sync.c/dpfp.c/dpfp_threaded.c: warning: Result of 'malloc' is converted
  to a pointer of type 'unsigned char', which is incompatible with sizeof
  operand type
2012-07-02 18:29:27 +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
Ludovic Rousseau c9d41fe5f0 Autotools: Apply autoupdate 2.68 recommendations
* Not applied: AC_PREREQ([2.68]) as this doesn't seem
  necessary and 2.68 was released less than 2 years ago.
2012-06-04 01:19:25 +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
Ludovic Rousseau 7e52e1e753 Samples: Use the implicit _SOURCES rule
* By default automake looks for a source file foo.c for a foo binary.
2012-05-10 15:39:11 +01:00
Ludovic Rousseau 6b7609125f Samples: Use a common LDADD for all examples
* Similar to libusb patch a129732fb45fc424743f26f01c906e4514f11521
2012-05-10 15:38:19 +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