felis / USB_Host_Shield_2.0

Revision 2.0 of USB Host Library for Arduino.
https://chome.nerpa.tech
1.8k stars 779 forks source link

Stops detecting USB device insertion #425

Open riban-bw opened 6 years ago

riban-bw commented 6 years ago

Occasionally UHS2 stops detecting newly plugged device after previous device is removed. I have found that performing a USB::Reset seems to stop this behaviour so maybe something configured by USB::Reset is not being set during initialisation or being subsequently changed.

maustin-lpi commented 5 years ago

I'm seeing a similar issue with my XBOX ONE Controller using the XBOXONE sketch.

I can see the controller is recognised after being reconnected, based on the returned value from XBox.XboxOneConnected(), but its not reliably reading button presses, etc from the connected controller.

If I disconnect and reconnect the USB cable, I can usually get it to connect properly (sometimes on the first go, sometimes after a couple of disconnect/reconnects). I can also achieve this with a hardware reset of the Arduino or USB Shield.

I might try adding the USB::Reset approach you've mentioned above until this issue gets properly resolved

Ryzee119 commented 5 years ago

I had a similar issue with the XBONE sketch. I found that the JSTATUS and KSTATUS from getVbusState was not updating when I removed the device. I added pUsb->busprobe(); at the beginning of the XBOXONE::Poll() function and it seems to have resolved my issues.

Edit: If I just add Usb.busprobe() to my main loop just above Usb.Task() that seems to have also fixed my issue without modifying the libraries.

Lauszus commented 5 years ago

@Ryzee119 thanks for the feedback. Any change you could test the following PR: https://github.com/felis/USB_Host_Shield_2.0/pull/438 and see if that fixes the issue.

Lauszus commented 5 years ago

@felis please see the comment by @Ryzee119 seems like this could be called by always calling busprobe here:

https://github.com/felis/USB_Host_Shield_2.0/blob/ffaba6dad3f4bd41bf65f0833977adf65b628efd/usbhost.h#L570-L573

Sounds like the CONDETIRQ is not always set?