platform/upstream/libusb.git
11 years agoCore: use C99 flexible array member when possible
Sean McBride [Fri, 12 Oct 2012 21:34:25 +0000 (17:34 -0400)]
Core: use C99 flexible array member when possible

Fix clang warning by using C99 flexible array member instead of zero
length array gcc extension

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: return LIBUSB_ERROR_NOT_FOUND when reading the active config descriptor when...
Nathan Hjelm [Fri, 3 May 2013 14:03:37 +0000 (08:03 -0600)]
darwin: return LIBUSB_ERROR_NOT_FOUND when reading the active config descriptor when the device is not configured.

fixes #172

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: clean up old code
hjelmn@cs.unm.edu [Tue, 23 Apr 2013 22:35:33 +0000 (16:35 -0600)]
darwin: clean up old code

For some time only one type of completion message has been in use in the darwin
backend. The commit cleans up this code. This commit also removes some code
that has never done anything useful. If a pipe has an error it probably means
the device was closed so there is nothing to do.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: fix memory leaks in the darwin backend.
Nathan Hjelm [Fri, 26 Apr 2013 03:12:45 +0000 (21:12 -0600)]
darwin: fix memory leaks in the darwin backend.

There were two memory leaks in the darwin backend:
 - A CFString allocated by IORegistryEntryCreateCFProperty in darwin_get_interface()
   was not released.
 - The runloop is retained by darwin_open() but was not release by darwin_close().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agocore: release the context device list when the context is deleted.
Nathan Hjelm [Fri, 26 Apr 2013 03:09:19 +0000 (21:09 -0600)]
core: release the context device list when the context is deleted.

This commit fixes a memory leak in the context list patch. Devices need
to be unref'd when the context is deleted. This can happen if either 1)
the backend init fails, or 2) the context is destroyed by libusb_exit().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: don't assume an interval of 1 or high/super speed
Nathan Hjelm [Wed, 3 Apr 2013 04:12:47 +0000 (22:12 -0600)]
darwin: don't assume an interval of 1 or high/super speed

This patch updates submit_iso_transfer to use the bInterval value of the
endpoint and the speed of the device to determine the last frame of the
transaction.

Fixes: #165
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: add support for the LIBUSB_TRANSFER_ADD_ZERO_PACKET transfer flag.
Nathan Hjelm [Fri, 8 Feb 2013 07:12:13 +0000 (00:12 -0700)]
darwin: add support for the LIBUSB_TRANSFER_ADD_ZERO_PACKET transfer flag.

The zero-length packet is sent by the async event thread if all the following
conditions are met:

1) The packet size is not a multiple of maxPacketSize, and
2) the transfer completed successfully.

References #6.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin/libusb_reset: reenumerate device if the device descriptor or any configuration...
Nathan Hjelm [Fri, 8 Feb 2013 04:56:30 +0000 (21:56 -0700)]
darwin/libusb_reset: reenumerate device if the device descriptor or any configuration descriptor has changed

Some background: the Linux kernel causes a device to be reenumeration when
reset if the device's descriptors have changed. Darwin does not provide
this feature but instead provides a call to force the reenumeration of
a device. This behavior is required to support the firmware update
protocol used by some devices.

This patch updates darwin_reset to check if either the device or
configuration descriptors have changed. If they have darwin_reset will
ask the OS to reenumerate the device and return LIBUSB_ERROR_NOT_FOUND
or LIBUSB_SUCCESS accordingly.

Fixes #169

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: dpriv->device will never be NULL for a valid device. remove unnecessary code...
Nathan Hjelm [Sat, 1 Dec 2012 02:17:43 +0000 (19:17 -0700)]
darwin: dpriv->device will never be NULL for a valid device. remove unnecessary code that handled this case

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agodarwin: allow control messages on devices we can not exclusively open
Nathan Hjelm [Thu, 29 Nov 2012 23:19:11 +0000 (16:19 -0700)]
darwin: allow control messages on devices we can not exclusively open

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoBump LIBUSBX_API_VERSION for new hotplug API
Hans de Goede [Wed, 15 May 2013 10:17:42 +0000 (12:17 +0200)]
Bump LIBUSBX_API_VERSION for new hotplug API

And document the minimum version under which hotplug is supported

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoAdd hotplug support to the Linux backend.
Nathan Hjelm [Thu, 29 Nov 2012 23:14:03 +0000 (16:14 -0700)]
Add hotplug support to the Linux backend.

There are two ways to configure hotplug support for Linux: udev, and netlink. It
is strongly recommened that udev support is used on systems that utilize udev.
We reenforce this recommendation by defaulting to --with-udev=yes at configure
time. To enable netlink support run configure with --with-udev=no. If udev
support is enabled all device enumeration is done with udev.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoAdd hotplug support to the Darwin backend.
Nathan Hjelm [Thu, 29 Nov 2012 23:13:00 +0000 (16:13 -0700)]
Add hotplug support to the Darwin backend.

Hotplug events are handled by the async event thread. This thread listens for
two events: kIOTerminatedNotification, and kIOFirstMatchNotification. If
either of these events fires the thread will iterate through the appropriate
iterator and will either enumerate or call usbi_disconnect_device depending
on the event.

While adding hotplug support it was discovered that when reading from the IO
registry we need to use kCFNumberSInt32Type for the device location. Using
kCFNumberLongType would cause locations to be sign-extended and not match
what is stored for the session id. This is now fixed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoAdd hotplug support.
Nathan Hjelm [Thu, 29 Nov 2012 21:23:26 +0000 (14:23 -0700)]
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>
11 years agoFixup .gitignore for examples and tests now living in subdirs
Pete Batard [Wed, 15 May 2013 08:21:16 +0000 (10:21 +0200)]
Fixup .gitignore for examples and tests now living in subdirs

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoCore: Cache device descriptors in the core
Nathan Hjelm [Thu, 29 Nov 2012 20:53:41 +0000 (13:53 -0700)]
Core: Cache device descriptors in the core

Discussion: It is necessary to cache the device descriptor in the core to
support reading the descriptors after a device is disconnected. We could
either 1) allow each backend to handle this caching (which would most
certainly duplicate code), or 2) cache the descritors when a device
is added. This patch does the later.

Further discussion: It might be beneficial to cache more than just the
device descriptors in the core. It might also be worthwhile caching the
configuration and BOS descriptors as well.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoCore: Keep a list of contexts created by libusb_init()
Nathan Hjelm [Sun, 30 Sep 2012 17:49:01 +0000 (11:49 -0600)]
Core: Keep a list of contexts created by libusb_init()

* This list can be used by backends to determine which contexts
  need notification of device removal (and in the future device arrival).
  The active_contexts_list is protected from multiple access by the active_contexts_lock.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agolibusb.h: Correct errors in doxygen comment for struct libusb_device
Hans de Goede [Tue, 23 Apr 2013 08:46:32 +0000 (10:46 +0200)]
libusb.h: Correct errors in doxygen comment for struct libusb_device

The comment refers to the non-existing libusb_device_ref and
libusb_device_unref functions, this should be libusb_ref_device resp.
libusb_unref_device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoWinCE: Include COPYING and license information in binary snapshots.
Toby Gray [Tue, 16 Apr 2013 14:22:14 +0000 (15:22 +0100)]
WinCE: Include COPYING and license information in binary snapshots.

11 years agolibusbx-1.0.15
Pete Batard [Mon, 15 Apr 2013 22:15:10 +0000 (23:15 +0100)]
libusbx-1.0.15

11 years agoSamples: Fix timeout error on FX3 and logging improvements for fxload
Pete Batard [Sun, 14 Apr 2013 21:38:52 +0000 (22:38 +0100)]
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

11 years agoWindows: Correctly clear backend transfer private information
Toby Gray [Thu, 11 Apr 2013 12:40:31 +0000 (13:40 +0100)]
Windows: Correctly clear backend transfer private information

* Without this fix if a transfer is reused then there is a period of
  time between it being adding to the flying transfer list and
  submitted where the fd value will be the old fd value.
* If this occurs at the same time as all of the following conditions
  then the incorrect transfer will be handled as having completed:
* The old fd value in the reused transfer has been recycled for a
  currently pending transfer.
* This other pending transfer has a later timeout than the reused
  transfer (so therefore comes later in the flying transfer list).
* The other pending transfer completes, therefore signalling the fd.

As the flying transfer list is examined in order when handling events,
the resubmitted transfer with the old fd value will be considered as
completed. This will generally cause a NULL pointer dereference as the
OVERLAPPED structure was already freed.

Also see:
http://libusbx.1081486.n5.nabble.com/Libusbx-devel-PATCH-Fix-NULL-pointer-dereference-in-Windows-and-WinCE-backends-when-reusing-transfers-tt1041.html

11 years agoWinCE: Add internal build script for WinCE binaries
Toby Gray [Thu, 4 Apr 2013 12:32:31 +0000 (13:32 +0100)]
WinCE: Add internal build script for WinCE binaries

* Also copy over .pdb for WinCE and WDK generated DLLs

11 years agoWinCE: Fix x86 build on Visual Studio 2005
Toby Gray [Thu, 4 Apr 2013 12:33:20 +0000 (13:33 +0100)]
WinCE: Fix x86 build on Visual Studio 2005

11 years agolibusbx 1.0.15-rc3
Pete Batard [Thu, 4 Apr 2013 18:03:15 +0000 (19:03 +0100)]
libusbx 1.0.15-rc3

11 years agoOS X: Don't try to work around buggy devices with bInterval = 0 on isochronous...
Nathan Hjelm [Thu, 4 Apr 2013 20:51:03 +0000 (14:51 -0600)]
OS X: Don't try to work around buggy devices with bInterval = 0 on isochronous...

11 years agoCore: fix bug in libusb_has_capability()
Ludovic Rousseau [Thu, 4 Apr 2013 16:08:39 +0000 (18:08 +0200)]
Core: fix bug in libusb_has_capability()

The problem was detected by clang on Mac OS X:
warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
note: use '&' for a bitwise operation

We want to use a bitwise operation and not a logical operation.

11 years agolibusbx 1.0.15-rc2
Pete Batard [Wed, 3 Apr 2013 18:49:10 +0000 (19:49 +0100)]
libusbx 1.0.15-rc2

11 years agoOS X: Don't assume an interval of 1
Nathan Hjelm [Wed, 3 Apr 2013 10:12:47 +0000 (04:12 -0600)]
OS X: Don't assume an interval of 1

11 years agoWinCE: Fix missing sources from dist tarball
Toby Gray [Wed, 3 Apr 2013 11:02:50 +0000 (12:02 +0100)]
WinCE: Fix missing sources from dist tarball

11 years agolibusbx 1.0.15-rc1
Pete Batard [Tue, 2 Apr 2013 18:52:16 +0000 (19:52 +0100)]
libusbx 1.0.15-rc1

* Also fix missing header in release tarball

11 years agoCore: Add HID and kernel detach capability detection for all backends
Pete Batard [Sun, 17 Mar 2013 22:13:53 +0000 (22:13 +0000)]
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

11 years agoWindows: Fix USB descriptor creation code for HID devices
Toby Gray [Fri, 22 Mar 2013 13:50:01 +0000 (13:50 +0000)]
Windows: Fix USB descriptor creation code for HID devices

* Prior to this fix the location for the next endpoint structure was
  obtained by using ed++. This doesn't work as
  sizeof(libusb_endpoint_descriptor) is greater than
  LIBUSB_DT_ENDPOINT_SIZE due to extra members.
* Closes #110

11 years agoSamples: More fxload improvements and cleanup
Pete Batard [Sat, 16 Mar 2013 23:36:47 +0000 (23:36 +0000)]
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

11 years agoTests: Suppress Visual Studio 2012 Code Analysis warnings
Pete Batard [Sat, 16 Mar 2013 16:39:14 +0000 (16:39 +0000)]
Tests: Suppress Visual Studio 2012 Code Analysis warnings

11 years agoSamples: fix compiler warning
Ludovic Rousseau [Fri, 15 Mar 2013 08:35:16 +0000 (09:35 +0100)]
Samples: fix compiler warning

Make fx3_load_ram a static function.

ezusb.c:534: warning: no previous prototype for ‘fx3_load_ram’

11 years agoSamples: fxload improvements and cleanup
Federico Manzan [Sun, 10 Mar 2013 07:56:56 +0000 (07:56 +0000)]
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

11 years agoOS X: Do not assume HS when submitting isochronous transfer
Vegard Storheil Eriksen [Tue, 12 Mar 2013 15:30:05 +0000 (23:30 +0800)]
OS X: Do not assume HS when submitting isochronous transfer

* Closes #99

11 years agoOS X: Use kCFNumberSInt32Type when reading device location from the IO registry
Nathan Hjelm [Tue, 12 Mar 2013 15:09:07 +0000 (23:09 +0800)]
OS X: Use kCFNumberSInt32Type when reading device location from the IO registry

* Closes #97

11 years agoWindows: Fix multiple warnings
Pete Batard [Tue, 12 Mar 2013 01:26:08 +0000 (01:26 +0000)]
Windows: Fix multiple warnings

* Most of these warnings are false positive from VS2012's "Run Code Analysis"
* Also closes #98: "windows_usb.c:376:30: 'dev_info' may be used uninitialized"

11 years agoSamples: Add FX3 firmware upload support for fxload
Federico Manzan [Sun, 10 Mar 2013 21:00:00 +0000 (21:00 +0000)]
Samples: Add FX3 firmware upload support for fxload

11 years agoLinux: Consume all events on a fd in one go
Hans de Goede [Thu, 7 Mar 2013 11:44:00 +0000 (11:44 +0000)]
Linux: Consume all events on a fd in one go

* This fixes libusb_handle_events_timeout() only handling one event
* Closes #6

11 years agoSamples: Reinstate interface requests when querying WCID devices
Pete Batard [Mon, 4 Mar 2013 21:52:27 +0000 (21:52 +0000)]
Samples: Reinstate interface requests when querying WCID devices

* Reverts commit 939a4782b28c36dfddb68585c4b027a4d5494a5b.
* Closes #96

11 years agoWinCE: Post integration cleanup
Pete Batard [Sun, 3 Mar 2013 00:56:06 +0000 (00:56 +0000)]
WinCE: Post integration cleanup

* Update copyrights and switch to UTF-8 everywhere
* Add SleepEx() to missing.h, and move include to libusbi.h
* Remove ifdef for GetSystemTimeAsFileTime()

11 years agoMisc: Simplify includes and misc. cleanup
Pete Batard [Wed, 27 Feb 2013 22:58:49 +0000 (22:58 +0000)]
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

11 years agoTests: Fix broken OS-X and Linux builds
Xiaofan Chen [Sun, 24 Feb 2013 05:50:00 +0000 (05:50 +0000)]
Tests: Fix broken OS-X and Linux builds

* _dup2 is Windows only. Use dup2 instead
* Breakage was introduced in 76eecc6ce11d1bedee369859899901037dcd4cc2

11 years agoWinCE: Don't confirm protocol stalls with device in wince_transfer_callback()
Simon Haggett [Thu, 21 Feb 2013 16:59:00 +0000 (16:59 +0000)]
WinCE: Don't confirm protocol stalls with device in wince_transfer_callback()

When wince_transfer_callback() observes a stall (io_result set to
ERROR_NOT_SUPPORTED), it checks with the device (by sending a GET_STATUS
control transfer) that the endpoint is really stalled. This check is not
suitable for protocol stalls as these are always cleared at the start of the
next control transfer. When a protocol stall occurs, wince_transfer_callback()
observes that the corresponding control endpoint does not remain stalled and so
forces io_result to ERROR_SUCCESS. This then prevents applications from
detecting that a control request was not supported by the device.

This patch prevents wince_transfer_callback() from attempting to confirm
protocol stalls with the device, allowing io_result to remain set to
ERROR_NOT_SUPPORTED. A couple of comments and a debug log message within
wince_transfer_callback() are also corrected.

11 years agoTests: Simplify stdout redirection and fix Windows assertion error on cleanup
Pete Batard [Thu, 21 Feb 2013 00:24:18 +0000 (00:24 +0000)]
Tests: Simplify stdout redirection and fix Windows assertion error on cleanup

* cleanup_test_output() produced an assertion error when compiled with MSVC
  due to closing ctx->output_file
* set ctx->output_file to stdout by default

11 years agoWindows: Don't duplicate paths for HID interfaces
Pete Batard [Thu, 21 Feb 2013 00:11:37 +0000 (00:11 +0000)]
Windows: Don't duplicate paths for HID interfaces

* This caused the many_device_lists to fail after 32 iterations
* Closes #69

11 years agoWindows: Fix broken WDK compilation
Pete Batard [Mon, 18 Feb 2013 22:22:01 +0000 (22:22 +0000)]
Windows: Fix broken WDK compilation

790ffc78b008a03c95d10899f53997b504f55c72 moved the inclusion of poll_windows.h
  after the use of struct timeval, which removed the hidden winsock.h include
  where timeval is defined on the WDK.
* Make the winsock.h include explicit

11 years agoWindows: fix compiler warning
Ludovic Rousseau [Mon, 18 Feb 2013 19:29:41 +0000 (20:29 +0100)]
Windows: fix compiler warning

libusb/os/threads_windows.c:139:1: warning: '__inline' is not at beginning of declaration [-Wold-style-declaration]

11 years agoWindows: fix compiler warning
Ludovic Rousseau [Mon, 18 Feb 2013 19:26:46 +0000 (20:26 +0100)]
Windows: fix compiler warning

libusb/os/threads_windows.c: In function 'usbi_cond_timedwait':
libusb/os/threads_windows.c:190:2: warning: nested extern declaration of 'epoch_time' [-Wnested-externs]

11 years agoWindows: fix compiler warning
Ludovic Rousseau [Sat, 16 Feb 2013 16:23:36 +0000 (17:23 +0100)]
Windows: fix compiler warning

sizeof() returns a size_t not an int

libusb/os/windows_usb.c:1411:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libusb/os/windows_usb.c:1416:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

11 years agoWindows: fix compiler warnings
Ludovic Rousseau [Sat, 16 Feb 2013 16:07:53 +0000 (17:07 +0100)]
Windows: fix compiler warnings

libusb/os/windows_usb.c:1317:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:1317:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:1317:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]

libusb/os/windows_usb.c:3634:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:3634:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:3634:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]

11 years agoWindows: remove useless extern declaration
Ludovic Rousseau [Sat, 16 Feb 2013 16:04:59 +0000 (17:04 +0100)]
Windows: remove useless extern declaration

libusb/os/windows_usb.c:45:13: warning: redundant redeclaration of 'usbi_fd_notification' [-Wredundant-decls]
libusb/libusbi.h:420:6: note: previous declaration of 'usbi_fd_notification' was here

11 years agoWindows: fix compiler warnings
Ludovic Rousseau [Sat, 16 Feb 2013 16:02:40 +0000 (17:02 +0100)]
Windows: fix compiler warnings

libusb/os/windows_usb.c:368:36: warning: no previous prototype for 'get_interface_details_filter' [-Wmissing-prototypes]
libusb/os/windows_usb.c:691:5: warning: no previous prototype for 'get_sub_api' [-Wmissing-prototypes]
libusb/os/windows_usb.c:1179:6: warning: no previous prototype for 'get_api_type' [-Wmissing-prototypes]

11 years agoWindows: remove unused function
Ludovic Rousseau [Sat, 16 Feb 2013 16:00:32 +0000 (17:00 +0100)]
Windows: remove unused function

libusb/os/poll_windows.c:223:13: warning: 'reset_overlapped' defined but not used [-Wunused-function]

11 years agoWindows: fix compiler warnings
Ludovic Rousseau [Sat, 16 Feb 2013 15:58:17 +0000 (16:58 +0100)]
Windows: fix compiler warnings

libusb/os/poll_windows.c:176:5: warning: no previous prototype for '_fd_to_index_and_lock' [-Wmissing-prototypes]
libusb/os/poll_windows.c:197:13: warning: no previous prototype for 'create_overlapped' [-Wmissing-prototypes]
libusb/os/poll_windows.c:211:6: warning: no previous prototype for 'free_overlapped' [-Wmissing-prototypes]
libusb/os/poll_windows.c:223:6: warning: no previous prototype for 'reset_overlapped' [-Wmissing-prototypes]
libusb/os/poll_windows.c:401:6: warning: no previous prototype for '_free_index' [-Wmissing-prototypes]

11 years agoExamples: Fix compiler warning
Ludovic Rousseau [Wed, 17 Oct 2012 16:01:59 +0000 (18:01 +0200)]
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);
                    ~ ^~~~~~~~~~~~~~~~~~~~~~~~

11 years agoCore: Fix compiler warning
Ludovic Rousseau [Sat, 13 Oct 2012 18:22:49 +0000 (20:22 +0200)]
Core: Fix compiler warning

libusb/io.c:1877:35: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        timeout_ms = (tv->tv_sec * 1000) + (tv->tv_usec / 1000);
                   ~ ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

On Mac OS X tv_sec is a __darwin_time_t which is a long, not an int.

11 years agoUse "" instead of <> for internal includes
Sean McBride [Wed, 31 Oct 2012 15:09:31 +0000 (11:09 -0400)]
Use "" instead of <> for internal includes

some libusbx include files were included with angle brackets, changed to
quotes. Needed to work better in Xcode project

11 years agoWindows: Update transferred data on timeout or cancel.
Toby Gray [Wed, 13 Feb 2013 15:21:52 +0000 (15:21 +0000)]
Windows: Update transferred data on timeout or cancel.

* When handling aborted transfer it's possible that some data (but not
  the full buffer) was transferred.
* This change ensures that this partially transferred data is recorded
  and passed up to the caller.

11 years agoLinux: Don't set the USBFS_URB_SHORT_NOT_OK flag on the last urb
Hans de Goede [Mon, 11 Feb 2013 15:21:00 +0000 (15:21 +0000)]
Linux: Don't set the USBFS_URB_SHORT_NOT_OK flag on the last urb

* Closes #142

11 years agoWindows: Improve error reporting in winusbx_claim_interface()
Pete Batard [Sat, 2 Feb 2013 01:02:18 +0000 (01:02 +0000)]
Windows: Improve error reporting in winusbx_claim_interface()

* After the filter detection code is run, the error reported may
  have nothing to do with the original error (or report SUCCESS)
  and is unhelpful
* Also change TODO comments to default VS2012 task style

11 years agoWindows: Fixed bug in interface autoclaim
Benjamin Dobell [Fri, 1 Feb 2013 14:42:06 +0000 (01:42 +1100)]
Windows: Fixed bug in interface autoclaim

* Bug was introduced in f2b19e4a32c1445f4fea06beca61e8c7e7757950
* Closes #78
* Closes #80

11 years agoCore: Fix warning implicit conversion changes signedness
Ludovic Rousseau [Fri, 26 Oct 2012 08:02:16 +0000 (10:02 +0200)]
Core: Fix warning implicit conversion changes signedness

* Closes #70

11 years agoCore: Don't wait for completion if cancel_transfer failed
Zoltán Kovács [Tue, 29 Jan 2013 00:14:29 +0000 (00:14 +0000)]
Core: Don't wait for completion if cancel_transfer failed

* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-libusb-interrupt-transfer-does-not-return-in-case-of-error-td626.html
* Closes #76

11 years agoWindows: Display error code in default case of windows_transfer_callback
Pete Batard [Mon, 28 Jan 2013 23:51:53 +0000 (23:51 +0000)]
Windows: Display error code in default case of windows_transfer_callback

11 years agoWinCE: Add support for WinCE (Solution files)
Toby Gray [Wed, 16 Jan 2013 02:10:31 +0000 (02:10 +0000)]
WinCE: Add support for WinCE (Solution files)

11 years agoWinCE: Add support for WinCE (sources)
Toby Gray [Wed, 16 Jan 2013 02:07:29 +0000 (02:07 +0000)]
WinCE: Add support for WinCE (sources)

11 years agoWindows: Simplify poll_windows and add provisions for WinCE
Toby Gray [Tue, 15 Jan 2013 22:46:49 +0000 (22:46 +0000)]
Windows: Simplify poll_windows and add provisions for WinCE

* Because poll_windows now requires struct usbi_transfer to be
  defined, it's inclusion in libusbi.h had to be moved down.

11 years agoWindows: Add windows_common.h header
Toby Gray [Tue, 15 Jan 2013 22:36:47 +0000 (22:36 +0000)]
Windows: Add windows_common.h header

* This file contains definition that will be shared between the
  Windows and Windows CE backends

11 years agoCore: Use HAVE_SYS_TYPES_H and HAVE_SIGNAL_H
Pete Batard [Tue, 15 Jan 2013 22:24:32 +0000 (22:24 +0000)]
Core: Use HAVE_SYS_TYPES_H and HAVE_SIGNAL_H

* These files may not be available on all platforms (eg. WinCE)

11 years agoCore: Filter out 8-bit characters in libusb_get_string_descriptor_ascii
Роман Донченко [Fri, 21 Dec 2012 23:08:09 +0000 (03:08 +0400)]
Core: Filter out 8-bit characters in libusb_get_string_descriptor_ascii

* Closes #68

11 years agoWindows: Add VS2012 solution files
Pete Batard [Mon, 7 Jan 2013 22:00:47 +0000 (22:00 +0000)]
Windows: Add VS2012 solution files

* As well as try to clean up MS's MSVC mess...

11 years agoCore: Fix incorrect reference counting of default context when first created.
Toby Gray [Mon, 26 Nov 2012 13:25:05 +0000 (13:25 +0000)]
Core: Fix incorrect reference counting of default context when first created.

* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-stress-program-crashes-in-libusb-exit-NULL-tp474p477.html

11 years agoTests: Add libusbx stress test
Toby Gray [Wed, 21 Nov 2012 14:00:31 +0000 (14:00 +0000)]
Tests: Add libusbx stress test

See https://github.com/tobygray/libusbx/tree/testing as well
as http://libusbx.1081486.n5.nabble.com/Libusbx-devel-Crashes-tt433.html#a438

11 years agoAutotools: Carry over 2012.10.23 libusb changes
Peter Stuge [Tue, 23 Oct 2012 00:15:23 +0000 (00:15 +0000)]
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

11 years agoCore: Avoid short read failures on broken descriptors
Peter Stuge [Tue, 30 Oct 2012 00:11:41 +0000 (00:11 +0000)]
Core: Avoid short read failures on broken descriptors

* See http://marc.info/?t=135132844600001&r=1&w=2

11 years agoDarwin: kAppleVendorID is not in the 10.5 SDK
Sean McBride [Thu, 8 Nov 2012 19:02:06 +0000 (19:02 +0000)]
Darwin: kAppleVendorID is not in the 10.5 SDK

* Use kIOUSBVendorIDAppleComputer instead

11 years agoDarwin: Clean up tabs
Nathan Hjelm [Wed, 31 Oct 2012 22:54:07 +0000 (22:54 +0000)]
Darwin: Clean up tabs

* Closes #55

11 years agoDarwin: Add support for detecting superspeed devices
Nathan Hjelm [Tue, 2 Oct 2012 14:07:03 +0000 (08:07 -0600)]
Darwin: Add support for detecting superspeed devices

* IOUSBFamily 5.0.0 or newer

11 years agoDarwin: Use Release instead of IODestroyPlugInInterface
Nathan Hjelm [Sat, 29 Sep 2012 04:13:09 +0000 (22:13 -0600)]
Darwin: Use Release instead of IODestroyPlugInInterface

* This avoids stopping IOServices associated with a device
* Closes #54

11 years agoDarwin: Don't retry or unsuspend Apple devices during enum
Nathan Hjelm [Sat, 29 Sep 2012 03:18:36 +0000 (21:18 -0600)]
Darwin: Don't retry or unsuspend Apple devices during enum

11 years agoDarwin: Reduce attempts to retrieve a device descriptor during enumeration
Nathan Hjelm [Sat, 29 Sep 2012 03:18:08 +0000 (21:18 -0600)]
Darwin: Reduce attempts to retrieve a device descriptor during enumeration

11 years agoCore: Use offsetof() instead of null pointer tricks
Sean McBride [Thu, 25 Oct 2012 18:51:50 +0000 (14:51 -0400)]
Core: Use offsetof() instead of null pointer tricks

Closes #53

11 years agoWindows: Fix access for composite HID devices
Pete Batard [Mon, 29 Oct 2012 23:41:23 +0000 (23:41 +0000)]
Windows: Fix access for composite HID devices

* composite_open was only catering for interfaces with WinUSB-like
  drivers and did not properly initialize HID driven ones
* Issue reported by Stefano Di Martino

11 years agoAll: Use "" instead of <> for local includes
Ludovic Rousseau [Fri, 12 Oct 2012 21:28:51 +0000 (23:28 +0200)]
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.

11 years agoWindows: Fix early abort in libusb_close
Pete Batard [Wed, 3 Oct 2012 22:52:16 +0000 (23:52 +0100)]
Windows: Fix early abort in libusb_close

* We're calling winusbx_close with SUB_API_NOTSET, so
  we should attempt to initialize it first.
* Issue reported by Ramon Zambelli and Frank Hibbeln

11 years agolibusbx-1.0.14
Pete Batard [Mon, 24 Sep 2012 23:35:32 +0000 (00:35 +0100)]
libusbx-1.0.14

11 years agolibusbx-1.0.13
Pete Batard [Thu, 20 Sep 2012 20:58:04 +0000 (21:58 +0100)]
libusbx-1.0.13

11 years agoInternal: Add fxload exe and sources to the Windows binary snapshot
Pete Batard [Wed, 19 Sep 2012 21:22:24 +0000 (22:22 +0100)]
Internal: Add fxload exe and sources to the Windows binary snapshot

11 years agoMisc: Update copyrights, TODO and libusb_version.describe
Pete Batard [Tue, 18 Sep 2012 20:35:23 +0000 (21:35 +0100)]
Misc: Update copyrights, TODO and libusb_version.describe

* Changes suggested by Chuck Cook & Xiaofan Chen

11 years agolibusbx 1.0.13-rc2
Pete Batard [Sun, 16 Sep 2012 15:24:24 +0000 (16:24 +0100)]
libusbx 1.0.13-rc2

* Also update NEWS with regards to isoc support for the 0/K Windows drivers

11 years agoDoc: Fix doxygen warnings and issues
Pete Batard [Sun, 16 Sep 2012 15:19:54 +0000 (16:19 +0100)]
Doc: Fix doxygen warnings and issues

* Remove obsolete tags
* Use QUIET = yes to make issues more prominent
* Fix code display for LIBUSBX_API_VERSION and missing parameter
  documentation for libusb_get_port_path()
* Most of the above suggested by Ludovic Rousseau

11 years agoMisc: Fix missing files from dist package
Pete Batard [Sun, 16 Sep 2012 15:11:10 +0000 (16:11 +0100)]
Misc: Fix missing files from dist package

11 years agolibusbx 1.0.13-rc1
Pete Batard [Sat, 15 Sep 2012 23:16:06 +0000 (00:16 +0100)]
libusbx 1.0.13-rc1

11 years agoCore: Introduce LIBUSBX_API_VERSION macro
Pete Batard [Sat, 15 Sep 2012 22:57:21 +0000 (23:57 +0100)]
Core: Introduce LIBUSBX_API_VERSION macro

* This macro can be used to detect if the version of libusbx being
  compiled against has a specific API feature, as well as to detect
  whether compilation occurs against libusb or libusbx.

11 years agoCore: Make libusb_error_name also handle transfer status codes
Hans de Goede [Sat, 15 Sep 2012 10:31:00 +0000 (11:31 +0100)]
Core: Make libusb_error_name also handle transfer status codes

Note that for the code 0 which means success resp. completed we have an
overlap in the codes. This is not a problem since normally one would not
call libusb_error_name on success / normal completion.

11 years agoSamples: Fix compiler warnings in fxload
Ludovic Rousseau [Sat, 15 Sep 2012 08:18:50 +0000 (10:18 +0200)]
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