Commit graph

36 commits

Author SHA1 Message Date
hjelmn@cs.unm.edu
1eff220474 Misc: Revert all references to libusb/libusb.info 2014-01-08 23:51:01 +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
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
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
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
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
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
a636df4ca1 Whitespace cleanup 2010-05-12 22:11:32 -03: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
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
Daniel Drake
8d809854e2 Rename libusb_poll() to libusb_handle_events() 2008-03-30 22:19:00 +01:00
Daniel Drake
211f80c9f2 Isochronous endpoint I/O
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.
2008-03-30 22:17:34 +01:00
Daniel Drake
ead09cde68 API documentation
Hopefully mostly complete. Some constants were renamed and move into
enums.
2008-03-20 21:19:45 +00:00
Daniel Drake
c0c9432d38 Beginnings of cross-platform abstraction
This also includes a libusb_get_pollfds API change
2008-03-13 12:46:08 +00:00
Daniel Drake
de4c5341d1 Add transfer flags 2008-03-10 18:38:15 +00:00
Daniel Drake
aae05f688d Simplify libusb_fill_control_transfer()
Transfer length can be inferred from the setup packet.
2008-03-10 11:32:15 +00:00
Daniel Drake
7c5ea95297 get_device fixup
Rename API away from "devh" and fix implementation to match header
2008-03-10 11:29:24 +00:00
Daniel Drake
283ae96c3c Simplify cancellation API
No need to provide the device here.
2008-03-09 16:15:02 +00:00
Daniel Drake
ebad1c7968 Rename libusb_dev_handle to libusb_device_handle 2008-03-09 16:12:08 +00:00
Daniel Drake
66348c90ea Separate transfer allocation and submission
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...)
2008-03-09 00:58:09 +00:00
Daniel Drake
d21ebe47ce Rework URB API naming
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.
2008-03-08 12:58:32 +00:00
Daniel Drake
23f8fb8baf Add convenience function to find and open a device by USB VID+PID
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.
2008-03-06 23:43:57 +00:00
Daniel Drake
9cfdb494fc Rework device discovery API
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.
2008-03-06 23:25:20 +00:00
Daniel Drake
637a8d7ff8 Remove timers and signalfd
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.
2008-01-30 13:19:10 +00:00
Daniel Drake
e3ce855ace Fix dpfp example compilation 2008-01-26 17:26:40 +00:00
Daniel Drake
de53d972ed Rename some _devh_ functions
Decided against naming functions in this style based on advice from
Tim Roberts. Still not really sure about devh naming in general.
2008-01-04 01:17:06 +00:00
Daniel Drake
132d84bf8a Use "transfer" instead of "msg"
Based on a discussion with Tim Roberts.
2008-01-04 01:13:25 +00:00
Daniel Drake
dbb3fd871e API renaming: remove fpi and usb_ stuff
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.
2008-01-04 00:54:57 +00:00
Daniel Drake
e9364d7215 Rename to libusb-1.0
I've taken over the libusb project, and what was previously known as fpusb
will eventually be released as libusb-1.0.
2008-01-04 00:40:49 +00:00
Daniel Drake
dfac6756fa Don't pass ctrl_msg/bulk_msg structures through async paths
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.
2007-12-12 23:32:54 +00:00
Daniel Drake
b5a7a41108 Rename fpusb_device_handle functions to devh
Prevents confusion with functions that work on fpusb_dev structures.
2007-12-03 22:27:21 +00:00
Daniel Drake
852bba4754 Initial commit
Basic library structure which supports enumerating detected USB devices
2007-12-02 22:54:59 +00:00