kosel | 1 Sep 12:00 2006
Picon

Disconnect detection in libusb

Hello,

is there a recommended way for disconnect detection for applications using 
libusb?
In the past I terminated my application if data transfer from device failed.
But this also hapens during start and end of suspend.
And for certification reasons, the application must not terminate during
suspend.

Greetings
	Juergen
--

-- 
mailto:Juergen.Kosel <at> ic-design.de
Phone: +49/851/94412-14
Fax:   +49/851/40141

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Dan Ellis | 1 Sep 21:07 2006

Re: Disconnect detection in libusb

kosel wrote:
>
> Hello,
>
>
> is there a recommended way for disconnect detection for applications using
> libusb?
> In the past I terminated my application if data transfer from device 
> failed.
> But this also hapens during start and end of suspend.
> And for certification reasons, the application must not terminate during
> suspend.
>
What certification problems are caused by your application terminating 
during suspend? Surely as long as it picks up again upon resume then it 
should be OK.

Dan.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
kosel | 4 Sep 11:21 2006
Picon

Re: Disconnect detection in libusb

Hello,

>From: Dan Ellis <dellis <at> newnhamresearch.com>
>
>kosel wrote:
>>
>> Hello,
>>
>>
>> is there a recommended way for disconnect detection for applications using
>> libusb?
>> In the past I terminated my application if data transfer from device 
>> failed.
>> But this also hapens during start and end of suspend.
>> And for certification reasons, the application must not terminate during
>> suspend.
>>
>What certification problems are caused by your application terminating 
>during suspend? Surely as long as it picks up again upon resume then it 
>should be OK.

USB-IF certification demands that host enters S1 suspend while application
is active.
After the host resumes, the application must continue without error.

My application is a simple shell application, as I wrote it for Linux.
So the application does not listen for Windows powermanagement messages.
So the application could not distinguish if errocode -5 from usb_bulk_read
is caused by a device disconnect or a device suspend.

(Continue reading)

kosel | 4 Sep 11:55 2006
Picon

Re: Disconnect detection in libusb

Hello,

>From: IC-Design <at> t-online.de (kosel)

>It seems, that this prevents the host (XP SP2) to wake up my device after S1 
>resume!
>I am also not sure, if allways all the certified USB 2.0 hubs have received a 
>resume.
>
>My loop:
>
>#ifdef unix
>// see ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1031/dnucmg/html/UCMGch09.htm
>#include <time.h>
>#define SECONDS 1 // unix measures time in sleep in seconds
>#else
>#include <windows.h>
>#define SECONDS 1000  // microsoft sleep uses milliseconds
>#define sleep(x) Sleep(x*SECONDS)
>#endif
>
>		while(!udev) {

if I call the sleep function in this line, no USB device resumes at all!
(At least all devices and hubs which are connected to the same root hub port.)

>		    udev = getUsbStepcounter(devicenumber);
>			fflush(stderr);
>			if(!udev) {
>				printf("Waiting for device %d to reconnect\n",
(Continue reading)

Dan Ellis | 4 Sep 12:42 2006

Re: Disconnect detection in libusb

kosel wrote:
> Hello,
> 
>> From: IC-Design <at> t-online.de (kosel)
> 
>> It seems, that this prevents the host (XP SP2) to wake up my device
>> after S1 resume! I am also not sure, if allways all the certified
>> USB 2.0 hubs have received a resume. 

Are you using the latest snapshot (27 August 2006)? It fixes a plethora
of bugs to do with going into suspend and power management over the
current release (from 2005).

The problems you are describing sound very much like ones I encountered
when keeping a handle open to the device and putting a laptop into
standby (and got fixed).

Dan.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
kosel | 4 Sep 13:20 2006
Picon

Re: Disconnect detection in libusb

Hello,

>From: "Dan Ellis" <Dan.Ellis <at> newnhamresearch.com>
>
>kosel wrote:
>> Hello,
>> 
>>> From: IC-Design <at> t-online.de (kosel)
>> 
>>> It seems, that this prevents the host (XP SP2) to wake up my device
>>> after S1 resume! I am also not sure, if allways all the certified
>>> USB 2.0 hubs have received a resume. 
>
>Are you using the latest snapshot (27 August 2006)? It fixes a plethora
>of bugs to do with going into suspend and power management over the
>current release (from 2005).

I am using CVS sources from august 28 (about 9 o'clock).
Compiled with msys/mingw and DDK 3790.
I go to download the snapshot.

Greetings
	Juergen

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)

kosel | 4 Sep 13:41 2006
Picon

Re: Disconnect detection in libusb

Hello,

>From: IC-Design <at> t-online.de (kosel)
>
>>From: "Dan Ellis" <Dan.Ellis <at> newnhamresearch.com>
>>
>>
>>Are you using the latest snapshot (27 August 2006)? It fixes a plethora
>>of bugs to do with going into suspend and power management over the
>>current release (from 2005).
>
>I am using CVS sources from august 28 (about 9 o'clock)

And it is still uptodate.

>Compiled with msys/mingw and DDK 3790.
>I go to download the snapshot.

Even if compile the snapshot without the DDK,
I got the same strange results.

Greetings
	Juergen

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)

kosel | 4 Sep 13:53 2006
Picon

Re: Disconnect detection in libusb

Hello again,

>From: "Dan Ellis" <Dan.Ellis <at> newnhamresearch.com>
>The problems you are describing sound very much like ones I encountered
>when keeping a handle open to the device and putting a laptop into
>standby (and got fixed).

it seems to be connected with your solved problem.

I commented out the
usb_close(udev);
which was executed after usb_bulk_read failed and before
the loop to research for the device is reentered.

Coul it be, that Windows unloads the driver, if no handle remains open
to the device?

Greetings
	Juergen

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
kosel | 4 Sep 14:47 2006
Picon

Re: Disconnect detection in libusb

Hello,

>From: IC-Design <at> t-online.de (kosel)
>
>>From: "Dan Ellis" <Dan.Ellis <at> newnhamresearch.com>
>>The problems you are describing sound very much like ones I encountered
>>when keeping a handle open to the device and putting a laptop into
>>standby (and got fixed).
>
>it seems to be connected with your solved problem.
>
>I commented out the
>usb_close(udev);
>which was executed after usb_bulk_read failed and before
>the loop to research for the device is reentered.

ups,
I forgot to wrote, that commenting out the call of usb_close
_seems_ to solve the problem for S1 suspend.
After resume from S1 everything seem to work fine.

But after resume from S3 suspend, there is still no wake up
for the USB. (Not only my libusb device.)

Greetings
	Juergen

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
(Continue reading)

Dan Ellis | 4 Sep 16:19 2006

Re: Disconnect detection in libusb

kosel wrote:
> Hello,
> 
>> From: IC-Design <at> t-online.de (kosel)
>> 
>>> From: "Dan Ellis" <Dan.Ellis <at> newnhamresearch.com> The problems you
>>> are describing sound very much like ones I encountered when keeping
>>> a handle open to the device and putting a laptop into standby (and
>>> got fixed).
>> 
>> it seems to be connected with your solved problem.
>> 
>> I commented out the
>> usb_close(udev);
>> which was executed after usb_bulk_read failed and before the loop to
>> research for the device is reentered.
> 
> ups,
> I forgot to wrote, that commenting out the call of usb_close _seems_
> to solve the problem for S1 suspend. 
> After resume from S1 everything seem to work fine.
> 
> But after resume from S3 suspend, there is still no wake up for the
> USB. (Not only my libusb device.) 

I think you may need a kernel debugger to get much further. Try
debugview from sysinternals (free).

You can update the driver (with any additional debug you put in) by just
putting the new build into WINDOWS\system32\drivers and replugging your
(Continue reading)


Gmane