1
General Discussion / Re: VNC2 re-enumeration after first remove the HID device
« on: July 06, 2023, 10:46:13 AM »
Hello,
I kept tried to modified my code and now I can use the modified example code "USBHostHIDKbd" to scan data for the three HID devices (USB reader, barcode scanner and keyboard) mentioned previously. And data can be successfully scanned after plugin, remove and re-plugin. This example code is used based on opening the USBHost driver and attaching the HID driver.
However, I used the example code "USBHostHID2" to try to get the same function previously. In this code, I used the same enumeration function "usbhost_connect_state" as mentioned before. However, I can only scan data at the very first plugin for the HID device. When I remove the HID device and re-plugin another HID device, the enumeration can fail all the time. I wonther that in this usbhost_connect_state function, is it can always get the PORT_STATE_ENUMERATED state during several connection try? or could the state after doing the usbhost_connect_state function always stay in PORT_STATE_CONNECTED or PORT_STATE_DISCONNECTED? (which means I will alway not get ready for enumeration.)
I sometimes see the value of status show in PORT_STATE_CONNECTED and then becomes to PORT_STATE_ENUMERATED after a while in checking this function in both "USBHostHIDKbd" and "USBHostHID2" example codes. May I ask what's the difference between the PORT_STATE_CONNECTED and PORT_STATE_ENUMERATED? In the example code, the if condition only allow the state of PORT_STATE_ENUMERATED to go into reading data process.
I also write another function to get the status of "usbhost_connect_state" until the status become PORT_STATE_ENUMERATED which is shown as follows.
If I found my code encounter the situation that the first enumeration could success but the second, third and other enumeration afterwards could fail, what could be the problem or any debug suggestions are appreciated in advanced!
Thank you so much!
Yvonne
I kept tried to modified my code and now I can use the modified example code "USBHostHIDKbd" to scan data for the three HID devices (USB reader, barcode scanner and keyboard) mentioned previously. And data can be successfully scanned after plugin, remove and re-plugin. This example code is used based on opening the USBHost driver and attaching the HID driver.
However, I used the example code "USBHostHID2" to try to get the same function previously. In this code, I used the same enumeration function "usbhost_connect_state" as mentioned before. However, I can only scan data at the very first plugin for the HID device. When I remove the HID device and re-plugin another HID device, the enumeration can fail all the time. I wonther that in this usbhost_connect_state function, is it can always get the PORT_STATE_ENUMERATED state during several connection try? or could the state after doing the usbhost_connect_state function always stay in PORT_STATE_CONNECTED or PORT_STATE_DISCONNECTED? (which means I will alway not get ready for enumeration.)
I sometimes see the value of status show in PORT_STATE_CONNECTED and then becomes to PORT_STATE_ENUMERATED after a while in checking this function in both "USBHostHIDKbd" and "USBHostHID2" example codes. May I ask what's the difference between the PORT_STATE_CONNECTED and PORT_STATE_ENUMERATED? In the example code, the if condition only allow the state of PORT_STATE_ENUMERATED to go into reading data process.
I also write another function to get the status of "usbhost_connect_state" until the status become PORT_STATE_ENUMERATED which is shown as follows.
Code: [Select]
status = usbhost_connect_state(hUSBHOST_1);
while (status != PORT_STATE_ENUMERATED) {
close_drivers();
vos_delay_msecs(100);
open_drivers();
status = usbhost_connect_state(hUSBHOST_1);
}
If I found my code encounter the situation that the first enumeration could success but the second, third and other enumeration afterwards could fail, what could be the problem or any debug suggestions are appreciated in advanced!
Thank you so much!
Yvonne