Daniel Strawson | 3 Jan 2010 19:22
Picon

Timeout parameter in libusb_interrupt_transfer() doesn't work as expected

Hi -

Sorry if this is the wrong list, but I hope someone can help me.  I
don't want to log this as a bug as I'm not really sure that it is.

I'm using the sync API in libusb 1.0.6 (on OSX) and trying to do an
interrupt-in transfer using 'libusb_interrupt_transfer()'.  I set the
timeout to 100ms and believe that if nothing is sent from my device
within 100ms, then the API will return with a timeout error.

As soon as my device sends data to the host, the call returns OK,
however if not libusb_interrupt_transfer just blocks.

However, it does work as per my understanding - turning on debugging,
reading the code and tracing through I think that this is because, in
do_sync_bulk_transfer, libusb_handle_events is called which has a
hardcoded timeout of 60 seconds, rather than calling
libusb_handle_events_timeout.  Also, if no events are handled and
libusb_handle_events{_timeout} times out, then the code doesn't detect
this and doesn't clear up and return.

My question is, have I miss-understood the API semantics, or is this a
bug.  I've tried modifying do_sync_bulk_transfer to call
libusb_handle_events_timeout and I suspect that I'm not handling the
timeout properly as whilst this now works, I get a crash later on.

My new version looks like this:

-------------- (sync.c // do_sync_bulk_transfer()) -------------

(Continue reading)

Daniel Drake | 3 Jan 2010 21:25
Favicon

Re: Timeout parameter in libusb_interrupt_transfer() doesn't work as expected

El 03/01/10 18:22, Daniel Strawson escribió:
> However, it does work as per my understanding - turning on debugging,
> reading the code and tracing through I think that this is because, in
> do_sync_bulk_transfer, libusb_handle_events is called which has a
> hardcoded timeout of 60 seconds, rather than calling
> libusb_handle_events_timeout.

Not exactly. The OSX backend is written in the expectation that one of 
the file descriptors will generate activity indicating a timeout event 
after 100ms. If this isn't happening (or doesn't happen), as you seem to 
be saying, then it's a bug.

Daniel

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
Daniel Strawson | 3 Jan 2010 23:09
Picon

Re: Timeout parameter in libusb_interrupt_transfer() doesn't work as expected

Daniel & Orin, thanks for the comments,

Not sure I understand your comment Daniel fully - in this case, there
is no activity and the call to libusb_interrupt_transfer() blocks
indefinitely.  Does this mean a bug?

Cheers,

Daniel

On Sun, Jan 3, 2010 at 8:25 PM, Daniel Drake <dan <at> reactivated.net> wrote:
> El 03/01/10 18:22, Daniel Strawson escribió:
>>
>> However, it does work as per my understanding - turning on debugging,
>> reading the code and tracing through I think that this is because, in
>> do_sync_bulk_transfer, libusb_handle_events is called which has a
>> hardcoded timeout of 60 seconds, rather than calling
>> libusb_handle_events_timeout.
>
> Not exactly. The OSX backend is written in the expectation that one of the
> file descriptors will generate activity indicating a timeout event after
> 100ms. If this isn't happening (or doesn't happen), as you seem to be
> saying, then it's a bug.
>
> Daniel
>

--

-- 
Daniel Strawson

(Continue reading)

Daniel Drake | 3 Jan 2010 23:35
Favicon

Re: Timeout parameter in libusb_interrupt_transfer() doesn't work as expected

El 03/01/10 22:09, Daniel Strawson escribió:
> Not sure I understand your comment Daniel fully - in this case, there
> is no activity and the call to libusb_interrupt_transfer() blocks
> indefinitely.  Does this mean a bug?

Yes.

Daniel

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
Philip.Joslin | 4 Jan 2010 19:07
Favicon

Hotplug

I was curious, as stated below, whether there was going to be any simple mechanism in the new hotplug scheme to notify an app (which is communicating to a USB device through libusb) when a device has been unplugged or when a new device is plugged in (or a previously unplugged device is "re-plugged" in).
 
Thanks.
 

From: Philip.Joslin <at> microchip.com [mailto:Philip.Joslin <at> microchip.com]
Sent: Tuesday, December 01, 2009 11:27 AM
To: dan <at> reactivated.net; libusb-devel <at> lists.sourceforge.net
Subject: Re: [Libusb-devel] libusb-1.0.6 released

When you are addressing the hotplug capability it would be "nice" if:

1) A user could call a libusb method and specify a callback method to be invoked if a USB device with a given VID or given VID/PID is plugged in. From within that callback, the serial number or "other" unique identification could be retrieved (possibly via a call to libusb_get_device_descriptor without having to first call libusb_get_device_list).

2) Given a unique device as found in the return info from a call to libusb_get_device_list, the user could call a libusb method for that device and specify a callback method to be invoked when that unique device was unplugged. (This method would be available even if that device were not yet opened -- since descriptor info is available before opening the device.)

The reasons for this are:

1) In our application, we will have multiple units with the same VID/PID but unique serial numbers that we must keep track of (whether they are plugged in or not).

2) We keep a list of units plugged in when our app starts and that list will only grow during a "session" with that app (in that, if a device is unplugged, it is simply marked as unplugged but is not removed from our list; if a new unit is plugged in that is not on the list, it is added to the list; if a unit is plugged in that was on the list, it is simply marked as plugged in). Hence the need for serial number or "other" unique identification (especially when the unit is unplugged).

Our concern for the moment with libusb is Linux and the Mac. On Windows, using WinUSB, we can create a hidden window and register it with Windows for hotplug notifications (both plug and unplug events) and associate those events with our list appropriately.

Thanks for your efforts.

Philip Joslin
Microchip Technology



-----Original Message-----
From: Daniel Drake [mailto:dan <at> reactivated.net]
Sent: Sunday, November 22, 2009 10:47 AM
To: libusb-devel <at> lists.sourceforge.net
Subject: [Libusb-devel] libusb-1.0.6 released

https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.6/libusb-1.0.6.tar.bz2/download

Daniel Drake (3):
       Refine timerfd header check (#18)
       Increase libusb_handle_events() timeout to 60 seconds
       v1.0.6 release

Ludovic Rousseau (2):
       Darwin: fix warning in darwin_error_str()
       lsusb example: make print_devs() static

Nathan Hjelm (1):
       Darwin: allow devices to be opened multiple times


I now plan to work on libusb-1.1 for release before the end of the year.
  Changes:
  - hotplug through libudev
  - use dedicated timing thread for generating file-based timer events on
    systems where libusb-level time tracking is needed and timerfd is not
    available (i.e. no change of behaviour for Darwin and recent Linux
    platforms, and recent Linux platforms will still achieve "zero
    threads")
  - make libusb_handle_events() timeout unlimited

No incompatible API or ABI changes, but obviously a few functions will be added for hotplugging, the libusb_handle_events() change is a slight change in documented behaviour, and some functions will become redundant through the timing changes (e.g. libusb_get_next_timeout() will always return 0)

Hotplug backends for other platforms (Linux+HAL, linux-2.4, Darwin?) will hopefully follow soon after.

Daniel

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now.  http://p.sf.net/sfu/bobj-july _______________________________________________

Libusb-devel mailing list
Libusb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Libusb-devel mailing list
Libusb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Libusb-devel mailing list
Libusb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Pete Batard | 5 Jan 2010 15:11
Picon
Gravatar

Re: Working (preferably free) USB sniffer for Windows 7 x64?

Answering my own question there, as I just found that Microsoft's LogMan 
& NetMon can do the trick on Windows 7.

See

http://blogs.msdn.com/usbcoreblog/archive/2009/12/04/etw-in-the-windows-7-usb-core-stack.aspx 
for more details.
There's probably some limitation compared to a full fledged USB sniffer, 
but it should get you started (and it's free).

Also got some information that USBTrace by Sysnucleus works fine on 
Windows7 x64, with a 15 day eval - 256 KB trace limit version if you 
chose not to buy the product.

Regards,

/Pete

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
François Revol | 6 Jan 2010 01:05
Picon
Favicon
Gravatar

Call for participation to the "Alt-OS" devroom at FOSDEM (fwd)

Hello,
I tried to send this earlier but it didn't pass the moderation, so I 
had to register. Our official deadline has passed but I feel it'd be 
interesting to have a talk about porting libusb, specially the 1.x 
branch since it seems much more complex than the previous one.
So if anyone is interested in giving such a talk please mail me ASAP.

François.

------ Forwarded Message: ------
To: libusb-devel <at> lists.sourceforge.net
From: "François Revol" <revol <at> free.fr>
Subject: Call for participation to the "Alt-OS" devroom at FOSDEM
Date: Mon, 04 Jan 2010 18:45:20 +0100 CET

Hello,
This year, the FOSDEM (in Brussels, 6-7th February 2010) will host the
"Alt-OS" devroom on sunday from 9:00 to 17:00.

This devroom is meant as a place for Free and OpenSource Alternative
Operating System projects to share ideas and work on topics like:
 * distinguishing design and features,
 * device drivers and how to share them,
 * sharing code for internal components,
...

I believe a talk about the requirements to port libusb to another OS 
would be really interesting to us. I myself started porting the 0.1 
version to BeOS and Haiku some time ago, but it seems I'll have to 
start over.
Anyone interested in joining us ?

cf. the full details:
http://groups.google.com/group/rosetta-os/browse_thread/thread/16964e21bef27116

Deadline for submission is tomorrow (5th), so please don't be too late 
;-)

François.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Libusb-devel mailing list
Libusb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Johan Kanflo | 6 Jan 2010 17:05
Favicon

Mac OS X: dyld: lazy symbol binding failed: Symbol not found: _libusb_init

Hi,

I cannot get libusb-compat to work. It seems libusb-1.0.0.dylib is not loaded when a program loads
libusb-0.1.4.dylib. I have the following setup:

Mac OS X 10.6.2 with gcc i686-apple-darwin10-gcc-4.2.1

libusb-1.0.6 : 
./configure --prefix=/usr
make
sudo make install

libusb-compat-0.1.3:
export LIBUSB_1_0_LIBS=-L/usr/lib
export LIBUSB_1_0_CFLAGS=-I/usr/include/libusb-1.0
./configure --prefix=/usr
make
sudo make install

All goes well until i run libusb-compat's lsusb in the examples directory. Then I get the following error:

dyld: lazy symbol binding failed: Symbol not found: _libusb_init
  Referenced from: /Users/jhn/sandbox/trunk/development/avr/src/usb/libusb/libusb-compat-0.1.3/libusb/.libs/libusb-0.1.4.dylib
  Expected in: flat namespace

dyld: Symbol not found: _libusb_init
  Referenced from: /Users/jhn/sandbox/trunk/development/avr/src/usb/libusb/libusb-compat-0.1.3/libusb/.libs/libusb-0.1.4.dylib
  Expected in: flat namespace

Anyone?

Cheers,
Johan
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
Daniel Strawson | 6 Jan 2010 17:59
Picon

Re: Mac OS X: dyld: lazy symbol binding failed: Symbol not found: _libusb_init

I vaguely remember having this issue when I tried to use that library.
 I think I solved it by setting 'DYLD_INSERT_LIBRARIES' environmental
variable - read the manual for dyld (the OSX dynamic linker).  There's
a whole bunch of settings in there that might help you.  If nothing
else it helps understand how dynamic libraries work on OSX.  Also,
otool is a useful one to look at as well - on linux you have LDD but
otool does much the same thing I think and more.

Cheers,

Daniel

On Wed, Jan 6, 2010 at 4:05 PM, Johan Kanflo <watski <at> bitfuse.net> wrote:
> Hi,
>
> I cannot get libusb-compat to work. It seems libusb-1.0.0.dylib is not loaded when a program loads
libusb-0.1.4.dylib. I have the following setup:
>
> Mac OS X 10.6.2 with gcc i686-apple-darwin10-gcc-4.2.1
>
> libusb-1.0.6 :
> ./configure --prefix=/usr
> make
> sudo make install
>
> libusb-compat-0.1.3:
> export LIBUSB_1_0_LIBS=-L/usr/lib
> export LIBUSB_1_0_CFLAGS=-I/usr/include/libusb-1.0
> ./configure --prefix=/usr
> make
> sudo make install
>
> All goes well until i run libusb-compat's lsusb in the examples directory. Then I get the following error:
>
> dyld: lazy symbol binding failed: Symbol not found: _libusb_init
>  Referenced from: /Users/jhn/sandbox/trunk/development/avr/src/usb/libusb/libusb-compat-0.1.3/libusb/.libs/libusb-0.1.4.dylib
>  Expected in: flat namespace
>
> dyld: Symbol not found: _libusb_init
>  Referenced from: /Users/jhn/sandbox/trunk/development/avr/src/usb/libusb/libusb-compat-0.1.3/libusb/.libs/libusb-0.1.4.dylib
>  Expected in: flat namespace
>
> Anyone?
>
>
> Cheers,
> Johan
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Libusb-devel mailing list
> Libusb-devel <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libusb-devel
>

--

-- 
Daniel Strawson

tel: 07976 750383

daniel <at> strawson.net

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
Matt Hirsch | 7 Jan 2010 10:10
Picon

EPIPE in usb_control_msg

I have a USB device that requires a non-standard control message
packet to change modes. I want to duplicate the following packet,
captured by UsbSnoop under windows:

[305412 ms]  >>>  URB 915 going down  >>>
-- URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
  TransferBufferLength = 000000fe
  TransferBuffer       = 8630e65c
  TransferBufferMDL    = 00000000
  Index                = 000000fe
  DescriptorType       = 00000000 (<illegal descriptor type!>)
  LanguageId           = 000000fe
[305545 ms] UsbSnoop - MyInternalIOCTLCompletion(badbe126) :
fido=00000000, Irp=863a2c10, Context=8635ddf8, IRQL=2
[305545 ms]  <<<  URB 915 coming back  <<<
-- URB_FUNCTION_CONTROL_TRANSFER:
  PipeHandle           = 8663caa8
  TransferFlags        = 0000002b (USBD_TRANSFER_DIRECTION_IN,
USBD_SHORT_TRANSFER_OK)
  TransferBufferLength = 00000000
  TransferBuffer       = 8630e65c
  TransferBufferMDL    = 86700d38
  UrbLink              = 00000000
  SetupPacket          =
    00000000: 80 06 fe 00 fe 00 fe 00

I used the following code:

udev = usb_open(dev);
char blah[254];
memset(blah,0,254);
res = usb_control_msg(udev, USB_TYPE_STANDARD, USB_REQ_GET_DESCRIPTOR,
2, 0xfe, blah, 0xfe, 1000);

I always get res == -32 == -EPIPE. Can anyone give me a suggestion
about how to properly generate the above packet?

Thanks!

Matt

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 

Gmane