RE: Learning USB Programming on Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-
> owner@xxxxxxxxxxxxxxx] On Behalf Of Peter Chen
> Sent: Thursday, December 11, 2014 4:25 AM
> To: Greg KH; ivo welch
> Cc: linux-usb; sgowdy+usbweb@xxxxxxxxx
> Subject: RE: Learning USB Programming on Linux
> 
> 
> >
> > On Thu, Dec 11, 2014 at 10:54:13AM +0800, ivo welch wrote:
> > > thank you, greg.   if linux-usb is the wrong starter, can you
> > > recommend some pointers to good starter documentation and books
> about
> > > writing user-space USB programs?  (is it really "read the linux
> kernel
> > > source"??)
> >
> > I don't know of any, sorry.  Look at libusb, there are lots of
> programs in your
> > distro that use it, so start with that.  The libusb web site
> might have example
> > programs as well, that will get you started on the userspace side
> for the host.
> > Not the gadget, that's a different story, but you already have a
> start with that
> > by looking at the PTP gadget userspace code you have access to.
> >
> 
> For host:
> http://libusb.info/
> 
> For device:
> https://github.com/libusbg/libusbg
> 

Please let me clarify. Libusbg is *not* the library for "USB
programming" in a similar meaning as libusb.

Libusb is the library for writing userspace programs on host side
which communicate directly with USB device using pure USB protocol
(usb requests).

 On the other hand libusbg is a library for gadget side but it is
*not* desired for any communication. It's only a library for USB
gadget *composition*. Using this library you can build a USB gadget
from existing blocks called functions for example mass storage,
serial, Ethernet or your custom one based on FunctionFS implemented in
userspace.

If you would like to communicate with host from USB device you should
use mentioned before *FunctionFS*[1]. It's a file system which allows
you to implement the second side of communication for libusb for
example PTP function.

The best place to start are some examples which are present in kernel
tree[2]. First of all please look at ffs-test.c which is a simple
device side program which use synchronous functionfs API. When you
will get through this you should look into [3] where you will find
examples how to use asynchronous functionfs API. Moreover you can find
there also host side programs which use libusb.

Footnotes:
(All paths in kernel repository)
[1] - Documentation/usb/functionfs.txt
[2] - tools/usb
[3] - tools/usb/ffs-aio-example/


--
Best regards,
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
k.opasiak@xxxxxxxxxxx




--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux