summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
...
* Examples: Fix device leak in hotplugtestChris Dickens2015-01-121-3/+21
| | | | | | | | Device leak occurred if either of the following occured: 1) Detach followed by attach 2) Two consecutive attach Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* 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-162-5/+10
| | | | | | * 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.
* examples: fix incorrect error message in fxloadCarl Karsten2014-04-071-1/+1
| | | | * Closes #3
* Misc: Revert all references to libusb/libusb.infohjelmn@cs.unm.edu2014-01-086-12/+12
|
* examples: check value returned by ftell()Ludovic Rousseau2013-10-061-1/+5
| | | | | | | | | Problem detected by the Coverity tool CID 1042546 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)3. negative_returns: "initial_pos" is passed to a parameter that cannot be negative. fseek(3) can't be called with a negative offset with SEEK_SET
* 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: fix warningLudovic Rousseau2013-09-281-1/+1
| | | | | | | ezusb.c: In function 'ezusb_load_ram': ezusb.c:719:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] int ret;
* 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).
* examples: check the value returned by libusb_handle_events()Ludovic Rousseau2013-09-281-1/+3
| | | | | | | Problem detected by the Coverity tool CID 1042539 (#1 of 1): Unchecked return value (CHECKED_RETURN)8. check_return: Calling function "libusb_handle_events(libusb_context *)" without checking return value (as is done elsewhere 6 out of 7 times).
* examples: check the value returned by libusb_init()Ludovic Rousseau2013-09-281-1/+6
| | | | | | | Problem detected by the Coverity tool CID 1042538 (#1 of 1): Unchecked return value (CHECKED_RETURN)4. check_return: Calling function "libusb_init(libusb_context **)" without checking return value (as is done elsewhere 11 out of 12 times).
* examples: Fix a memory leakLudovic Rousseau2013-09-201-7/+19
| | | | | | | | Close the image file before exiting the function Problem detected by the Coverity tool CID 1042549 (#2 of 3): Resource leak (RESOURCE_LEAK)9. leaked_storage: Variable "image" going out of scope leaks the storage it points to.
* examples: Fix a memory leakLudovic Rousseau2013-09-201-14/+29
| | | | | | | | Close the image file before exiting the function Problem detected by the Coverity tool CID 1042550 (#1 of 15): Resource leak (RESOURCE_LEAK)7. leaked_storage: Variable "image" going out of scope leaks the storage it points to.
* made some globals static to fix warningsSean McBride2013-07-302-8/+8
|
* examples: use libusb_set_auto_detach_kernel_driver()Hans de Goede2013-06-192-25/+2
| | | | | | | 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
* examples: Add sam3u_benchmark isochronous example by Harald WeltePeter Stuge2013-05-302-0/+196
| | | | | | | | | | | | | | | | 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>
* 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-172-10/+6
| | | | | | While at it also simplify the path printing in listdevs Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* listdevs: Also print portpath for non root hubsHans de Goede2013-05-161-2/+15
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* examples: Only check for HAVE_SIGACTION once in Makefile.amPeter Stuge2013-05-151-2/+0
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add some editor meta-comments for proper tab usageNathan Hjelm2013-05-151-0/+1
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add hotplug support.Nathan Hjelm2013-05-152-1/+97
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Samples: Fix timeout error on FX3 and logging improvements for fxloadPete Batard2013-04-143-18/+73
| | | | | | | | | | * 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
* 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: More fxload improvements and cleanupPete Batard2013-03-162-59/+76
| | | | | | | * 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
* Samples: fix compiler warningLudovic Rousseau2013-03-151-1/+1
| | | | | | Make fx3_load_ram a static function. ezusb.c:534: warning: no previous prototype for ‘fx3_load_ram’
* Samples: fxload improvements and cleanupFederico Manzan2013-03-153-42/+88
| | | | | | | * 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
* Samples: Add FX3 firmware upload support for fxloadFederico Manzan2013-03-103-6/+113
|
* 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-273-10/+2
| | | | | | | | | | | * 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
* Examples: Fix compiler warningLudovic Rousseau2013-02-151-1/+1
| | | | | | 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); ~ ^~~~~~~~~~~~~~~~~~~~~~~~
* WinCE: Add support for WinCE (sources)Toby Gray2013-01-232-1/+3
|
* Autotools: Carry over 2012.10.23 libusb changesPeter Stuge2012-11-251-1/+1
| | | | | | * 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
* All: Use "" instead of <> for local includesLudovic Rousseau2012-10-135-5/+5
| | | | | System header files are used with #include <foo.h> Xcode can't find local headers using this syntax.
* Misc: Fix missing files from dist packagePete Batard2012-09-161-1/+1
|
* Samples: Fix compiler warnings in fxloadLudovic Rousseau2012-09-151-7/+12
| | | | | | | | | | | | 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
* 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: Add fxload sample for Cypress EZ-USB chipsPete Batard2012-09-137-1/+2411
| | | | | | | | * 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.
* 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.
* Misc: Fix more Clang warnings in core and darwinPete Batard2012-07-022-2/+2
| | | | | | | | | | * 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
* 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
|
* Autotools: Apply autoupdate 2.68 recommendationsLudovic Rousseau2012-06-041-1/+1
| | | | | * Not applied: AC_PREREQ([2.68]) as this doesn't seem necessary and 2.68 was released less than 2 years ago.