PORTS Forum

Ports and Interfaces => USB => Topic started by: ulao on August 12, 2020, 10:47:31 am

Title: linux vs windows behavior, can this be prevented?
Post by: ulao on August 12, 2020, 10:47:31 am
Bit confused on this TBH but I have proof..


Windows
enumerate usb gamepad
poll always


Linux
enumerate usb gamepad
poll a few times
stop, wait for the os to require USB, then beginning polling.
if the OS does not need it, stop polling

So code side I have this


while (!usbInterruptIsReady())
{   
   usbPoll();   
}    
usbSetInterrupt((void *)&reportBuffer, 8);    



For linux, after enumeration it enter this loop and exits about 20 or so times (verities) but will end up polling and I see the keep alive but never getts USB ready, so its stuck in the loop. Once I do something like jstest so that the OS needs data, it exits the loop as it should. Once I stop using jstest, it's back to not getting the ready, so it's stuck in the loop.  Windows just polls, always and exits the loop because it gets the ready USB flag.

Why is this, is there a way to tell Linux to just continue polling like windows does in the USB enumeration?

in the image, i have debug data that shows when its in the loop after I plug in the device. The debug will stop if the loop exits. As you can see linux stays in that loop. 

Title: Re: linux vs windows behavior, can this be prevented?
Post by: Renate on August 24, 2020, 02:52:16 pm
Windows polls after enumeration.
Linux polls only when required by something.
None of this is specified anywhere in the USB standard.
Title: Re: linux vs windows behavior, can this be prevented?
Post by: Jan Axelson on August 26, 2020, 05:41:21 pm
Yes, it's left to the OS to decide.