76 Commits

Author SHA1 Message Date
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
Peter Stuge d346cd9060 examples: Use snprintf() instead of sprintf() in dpfp and dpfp_threaded
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>
2012-04-09 22:30:25 +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
Peter Stuge 4afbc78fe0 Rename the lsusb example program to listdevs
This is intended to reduce confusion with the much more significant
lsusb utility which is part of the usbutils package.
2012-02-08 15:59:11 +01:00
Xiaofan Chen 93b0e09d53 examples: Link only with ../libusb/libusb-1.0.la and not with -lusb-1.0
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
2012-01-13 18:04:39 +01:00
Hans de Goede a68f956dd4 Linux: Fix warnings seen when compiling with gcc-4.6
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]
2011-07-24 23:33:59 +02:00
Pete Batard 0e177f22fc dpfp_threaded: return instead of pthread_exit() to avoid Cygwin warning 2011-06-13 22:05:34 +02:00
Ludovic Rousseau 2aa8984e59 examples: #include <libusb.h> without directory name
The libusb-1.0 directory name belongs in the compile command, e.g.
via pkg-config --cflags. Fixes #58.
2010-11-22 05:25:53 +01:00
Peter Stuge 678c242705 examples: Silence warnings about return value of fwrite() 2010-10-16 14:22:30 +02:00
Pete Batard 29f9f9e3af Introduced calling convention (for Windows)
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]
2010-08-23 18:48:55 -06:00
Pete Batard 33cd2f68b4 removed trailing whitespaces 2010-08-06 21:44:10 -06:00
Daniel Drake a516fcb993 Only compile dpfp examples when sigaction is available
It's not available on MinGW.
2010-07-22 18:33:37 -06:00
Pete Batard a636df4ca1 Whitespace cleanup 2010-05-12 22:11:32 -03:00
Peter Stuge 23b5db8b3e Add internal abstraction for POSIX Threads
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]
2010-05-12 22:11:29 -03:00
Ludovic Rousseau 8392ff2213 lsusb example: make print_devs() static
lsusb.c:26: warning: no previous prototype for ‘print_devs’
2009-11-21 17:12:17 +00:00
Daniel Drake 1df713d622 Introduce contexts to the API
Suggested by David Zeuthen. This allows multiple libraries in the same
process to independently use libusb without interfering.
2008-06-26 22:42:59 -05:00
Daniel Drake fec7c84163 Handle hot-unplugging
This involved moving from select() to poll() because there is no way to
distinguish usbfs's POLLERR condition with select().
2008-05-11 20:47:27 +01:00
Daniel Drake fe4adcc99e Rework configuration handling
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.
2008-05-09 19:33:33 +01:00
Daniel Drake 5741bfe01a libusb_get_device_list() can return negative error code 2008-05-09 14:36:14 +01:00
Daniel Drake 5878daa85e Fix libusb_get_device_list return value
It was documented to return the list length, but was returning 0.
2008-05-04 00:51:59 +01:00
Daniel Drake 3675e978fb Expose bus number and device address 2008-05-02 12:28:31 +01:00
Daniel Drake 7ac0a405b4 Remove libusb_cancel_transfer_sync
This wasn't a particularly nice API. Cancellation should be handled by
the completion handler.
2008-04-29 12:08:35 +01:00