aboutsummaryrefslogtreecommitdiffstats
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
...
* examples: Use snprintf() instead of sprintf() in dpfp and dpfp_threadedPeter Stuge2012-04-092-2/+2
| | | | | | | The OpenBSD C compiler generates a warning for every use of sprintf() and for a good reason. Reported in http://marc.info/?m=133376187514495 Reported-by: Xiaofan Chen <xiaofanc@gmail.com>
* Misc: Rebrand to libusbxPete Batard2012-04-034-11/+10
| | | | | * Mentions of 'libusb' in doxygen are changed to 'libusbx' * Also update copyright notices and remove unneeded EOF LFs
* Samples: Fix "warning: no newline at end of file" in xusb.cPete Batard2012-04-011-4/+4
| | | | * Also remove trailing whitespaces
* Samples: fix a "value is always 0" Clang warning in xusb.cPete Batard2012-03-281-7/+8
| | | | | * Remove the use of os_fd[i].recipient and alter comments with regards to Windows Extended Props test limitations with WinUSB
* Examples: add xusb samplePete Batard2012-03-282-2/+882
| | | | | * Also improvements to WDK build scripts: cd to original dir on error, use 2 cores if available
* Rename the lsusb example program to listdevsPeter Stuge2012-02-082-3/+3
| | | | | This is intended to reduce confusion with the much more significant lsusb utility which is part of the usbutils package.
* examples: Link only with ../libusb/libusb-1.0.la and not with -lusb-1.0Xiaofan Chen2012-01-131-3/+3
| | | | | | | | | | Previous _LDFLAGS included both the freshly built libusb in ../libusb and -lusb-1.0, where libtool would usually resolve the latter to an already-installed libusb library in the system. The extra reference to a second libusb library resulted in failure to build examples on Mac OS X in some cases, and is plain wrong. See also the thread at http://marc.info/?m=132637593623667
* Linux: Fix warnings seen when compiling with gcc-4.6Hans de Goede2011-07-242-4/+2
| | | | | | | | | | | | | | | | | | | Compiling with gcc-4.6 results in the following warnings: os/linux_usbfs.c: In function 'op_get_configuration': os/linux_usbfs.c:1144:6: warning: variable 'r' set but not used ... os/linux_usbfs.c: In function 'op_handle_events': os/linux_usbfs.c:2091:40: warning: 'status' may be used uninitialized ... os/linux_usbfs.c:2044:6: note: 'status' was declared here dpfp.c: In function 'save_to_file': dpfp.c:228:9: warning: variable 'ignore' set but not used ... dpfp_threaded.c: In function 'save_to_file': dpfp_threaded.c:257:9: warning: variable 'ignore' set but not used ... This patch fixes these. (The second comes from handle_control_completion() which gcc seems to inline into op_handle_events().) Signed-off-by: Hans de Goede <hdegoede@redhat.com> [stuge: Add fixes for dpfp examples and update source references]
* dpfp_threaded: return instead of pthread_exit() to avoid Cygwin warningPete Batard2011-06-131-1/+1
|
* examples: #include <libusb.h> without directory nameLudovic Rousseau2010-11-224-4/+4
| | | | | The libusb-1.0 directory name belongs in the compile command, e.g. via pkg-config --cflags. Fixes #58.
* examples: Silence warnings about return value of fwrite()Peter Stuge2010-10-162-2/+4
|
* Introduced calling convention (for Windows)Pete Batard2010-08-232-6/+6
| | | | | | | | | | | | | | | | | | Under Windows, a variety of compilers and configurations are available, meaning that the manner of parameter passing (e.g. registers vs stack) can vary. Match the Windows API calling convention and document this appropriately. This calling convention will be used regardless of the configuration of the user's development platform. The only user-level complication is that all functions used as libusb callbacks must use the same calling convention as libusb. The LIBUSB_CALL macro is provided to make this easy. Signed-off-by: Michael Plante <michael.plante@gmail.com> Signed-off-by: Pete Batard <pbatard@gmail.com> [dsd: slight change of strategy, add documentation]
* removed trailing whitespacesPete Batard2010-08-061-3/+3
|
* Only compile dpfp examples when sigaction is availableDaniel Drake2010-07-221-1/+6
| | | | It's not available on MinGW.
* Whitespace cleanupPete Batard2010-05-121-7/+7
|
* Add internal abstraction for POSIX ThreadsPeter Stuge2010-05-121-2/+5
| | | | | | | | | | | | | | | | This prepares for a Windows backend without dependency on pthreads-w32. pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*. A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are introduced for statically initialized mutexes, since they may be implemented using other types when pthreads mutexes aren't used. Move -pthread from libusb/Makefile.am to host-specific THREAD_CFLAGS in configure.ac. This will enable optional use of -lpthread for cygwin. [dsd: minor tweaks, and roll in a change based on patches from Pete Batard to only build dpfp_threaded example when we're using pthreads]
* lsusb example: make print_devs() staticLudovic Rousseau2009-11-211-1/+1
| | | | lsusb.c:26: warning: no previous prototype for ‘print_devs’
* Introduce contexts to the APIDaniel Drake2008-06-263-15/+15
| | | | | Suggested by David Zeuthen. This allows multiple libraries in the same process to independently use libusb without interfering.
* Handle hot-unpluggingDaniel Drake2008-05-111-8/+14
| | | | | This involved moving from select() to poll() because there is no way to distinguish usbfs's POLLERR condition with select().
* Rework configuration handlingDaniel Drake2008-05-091-3/+8
| | | | | | libusb no longer caches descriptors in libusb_device but backends are intended to be able to provide copies from memory. In the common linux case we can use sysfs.
* libusb_get_device_list() can return negative error codeDaniel Drake2008-05-091-1/+2
|
* Fix libusb_get_device_list return valueDaniel Drake2008-05-041-3/+4
| | | | It was documented to return the list length, but was returning 0.
* Expose bus number and device addressDaniel Drake2008-05-021-1/+3
|
* Remove libusb_cancel_transfer_syncDaniel Drake2008-04-292-42/+32
| | | | | This wasn't a particularly nice API. Cancellation should be handled by the completion handler.
* add threaded example programDaniel Drake2008-04-192-1/+557
|
* Constify some return dataDaniel Drake2008-04-011-1/+1
| | | | Make it clear that apps should not mess with these structures
* Rename libusb_poll() to libusb_handle_events()Daniel Drake2008-03-301-1/+1
|
* Isochronous endpoint I/ODaniel Drake2008-03-301-3/+3
| | | | | | | | | Due to variable-sized structures, this involved changing allocation mechanism. All transfers must now be allocated and freed through libusb. A synchronous function is missing, and I could do with writing a few more helper functions to simplify things.
* API documentationDaniel Drake2008-03-201-2/+2
| | | | | Hopefully mostly complete. Some constants were renamed and move into enums.
* Beginnings of cross-platform abstractionDaniel Drake2008-03-131-1/+1
| | | | This also includes a libusb_get_pollfds API change
* Add transfer flagsDaniel Drake2008-03-101-2/+2
|
* Simplify libusb_fill_control_transfer()Daniel Drake2008-03-101-4/+3
| | | | Transfer length can be inferred from the setup packet.
* get_device fixupDaniel Drake2008-03-101-1/+2
| | | | Rename API away from "devh" and fix implementation to match header
* Rename descriptor-getting functionsDaniel Drake2008-03-091-1/+2
| | | | Based on feedback from Tim Roberts
* Simplify cancellation APIDaniel Drake2008-03-091-3/+3
| | | | No need to provide the device here.
* Rename libusb_dev_handle to libusb_device_handleDaniel Drake2008-03-091-1/+1
|
* Separate transfer allocation and submissionDaniel Drake2008-03-091-111/+75
| | | | | | | | | | Leads to some hefty API changes. Now we're much more similar to the Linux kernel model. Problems with dealing with asynchronous control transfers are passed on to the user, basically you must allocate a buffer, start with the setup, and put the data after. This won't make much sense until documented (soon...)
* Rework URB API namingDaniel Drake2008-03-081-35/+35
| | | | | | | Now refer to everything as "transfers" as consistent with the USB spec libusb_transfer is now a kind of transfer handle. To reduce confusion with libusb_bulk_transfer and libusb_control_transfer, those have been renamed to libusb_{control,bulk}_transfer_request.
* Persistent libusb_device storageDaniel Drake2008-03-081-1/+1
| | | | | | | | Devices are now assigned a session ID (currently busnum:devaddr) which is used to distinguish unique devices. Now multiple callers of libusb_get_device_list will get the same libusb_device structure instances.
* Add convenience function to find and open a device by USB VID+PIDDaniel Drake2008-03-061-30/+2
| | | | | | Lots of libusb apps I write are simple test apps not intended to be real apps. Having a function available to quickly locate my device will be handy in such situations.
* Rework device discovery APIDaniel Drake2008-03-062-27/+41
| | | | | | | | | | | | | | | | | | | | | | | | libusb_find_devices and libusb_get_devices are no more libusb_get_device_list obtains a list of libusb_device structures for all known devices in the system. Each libusb_device now has a reference count, defaulting to 1 on instantiation. The reference count of 1 refers to the fact that it is present in the list in this scenario. Opening a device adds a pointer to the libusb_device structure in the handle, so that also adds a reference. Closing the device removes that reference. The function to free the device list can optionally unref all the devices inside. In future we will make the libusb_device instances all "global" so that if the app calls get_device_list twice it actually gets the same libusb_device structure references back. This way we can start to track disconnects, and we can investigate adding a unique "session ID" to each libusb_device, an identifier guaranteed to be unique to that device until reboot.
* Remove timers and signalfdDaniel Drake2008-01-302-2/+7
| | | | | | | Instead of timers, add a mechanism for informing the parent app when the next timeout is due to happen, so that it can call us at that time. As we no longer use signals, signalfd has also been removed.
* Fix dpfp example compilationDaniel Drake2008-01-261-3/+3
|
* Rename some _devh_ functionsDaniel Drake2008-01-041-4/+4
| | | | | Decided against naming functions in this style based on advice from Tim Roberts. Still not really sure about devh naming in general.
* Use "transfer" instead of "msg"Daniel Drake2008-01-041-16/+17
| | | | Based on a discussion with Tim Roberts.
* API renaming: remove fpi and usb_ stuffDaniel Drake2008-01-042-7/+7
| | | | | | | | fpi changed to usbi. We should not expose structures with prefix "usb_" in the public namespace as it is quite likely there will be some conflict somewhere. Instead, using "libusb_" should be safer.
* Rename to libusb-1.0Daniel Drake2008-01-043-60/+60
| | | | | I've taken over the libusb project, and what was previously known as fpusb will eventually be released as libusb-1.0.
* Don't pass ctrl_msg/bulk_msg structures through async pathsDaniel Drake2007-12-121-7/+7
| | | | | | These are easiest to construct on the stack, but in the async case it is likely that the submitting function returns (hence stack is destroyed) before URB completion.
* Rename fpusb_device_handle functions to devhDaniel Drake2007-12-031-4/+4
| | | | Prevents confusion with functions that work on fpusb_dev structures.
* Initial commitDaniel Drake2007-12-023-0/+611
Basic library structure which supports enumerating detected USB devices