Closed yel-best closed 3 months ago
Hello @yel-best
Could you please specify and elaborate what do you mean by a following quote:
it enters a dead loop
Also, could you please specify all the changes, if any, you have made to the HID example code? Thank you.
Hello @yel-best
Could you please specify and elaborate what do you mean by a following quote:
it enters a dead loop
Also, could you please specify all the changes, if any, you have made to the HID example code? Thank you.
Oh, I didn't modify the logic code, I just added some esp_log, and I printed out every function execution point that the program ran. Then I found that the content of my QR code was "a"
but the result of scanning the code was keyCode = 57, and in the function:
hid_host_interface_callback
hid_host_keyboard_report_callback
hid_host_interface_callback
hid_host_keyboard_report_callback
key_event_callback 57
The loop jump does not output the result character "a"
I want.
I don’t know the reason, but the result I understand from the code scanner is actually characters such as abcdefg in the keyboard. Do I need to modify anything? I think the driver and character set in hid_usage_keyboard can be applied to the code scanner.
Hi @yel-best ,
To determine, where is the problem, is it possible to add the debug output for the raw report and share the log output?
The regular barcode scanner works a keyboard, so during the scanning it emulates the keyboard key pressing. That means that example should not do anything, when you are not scanning and show any data, when you scan the barcode. Is that right?
Then, example parses the data from scanner based on the default keyscan table, which is provided in the example hid_host_example.c#L90.
To add the debug output, please add ESP_LOG_BUFFER_HEX
In the line 386, hid_host_example.c
file:
...
case HID_HOST_INTERFACE_EVENT_INPUT_REPORT:
ESP_ERROR_CHECK(hid_host_device_get_raw_input_report_data(hid_device_handle,
data,
64,
&data_length));
ESP_LOG_BUFFER_HEX(TAG, data, data_length); // This is debug output for raw data input report
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
...
Thanks.
hid_host_device_get_raw_input_report_data
yes, you are right. The code scanner is actually simulating the keyboard for data output. I cannot recognize the USB HID device after running the example. I suspect that the code scanner I use is not standard enough. I will try to replace it with another one first. Scan code gun, and then add this code, I will update the log, please wait until I find a new code scanner, I will update again
thank you for your help
Hi @yel-best,
Hi @yel-best,
- I like to share my experience in making a connection with the Barcode scanner and ESP32 S3 Devkit M1 board, I used to upload code via Visual Studio Code, but I had an issue there, so I searched for that and found that it could be solved by using Official Espressif IDE.
- I am using Espressif-IDE Version: 2.12.0 and example code-named "hid_host_example.c"
Connection was as per the readme file and additionally, I have shared some images for better understanding. The connected barcode scanner was brought from Amazon and It was dismantled.
![]()
![]()
![]()
![]()
- And Here is the Output .....
![]()
oh, thank you very much for sharing, you are so kind, this will bring me a solution, thank you very much 😄
Hey @yel-best, Are there any updates?
I cannot recognize the USB HID device after running the example. I suspect that the code scanner I use is not standard enough.
Based on the debug output from hid example you had provided, it is a USB device that has one Keyboard interface. So the example found the "keyboard" and handle the key scan code. So, it should work.
If there anything new, please feel free to report.
Hi @yel-best, Are there any progress?
Hi @yel-best, Are there any progress?
Thank you for your concern. After trying it, I suspected that the protocol of the scanner hardware may not be standard. I suspected that it was a hardware compatibility issue. Then we replaced two scanner devices for USB connection. It worked without any code changes. Correctly obtain the corresponding barcode or QR code value, so this is how I currently solve my problem.
thanks 😄
@yel-best Thanks for the information.
I will close the issue then. If there will be anything else, feel free to re-open that issue or create a new one.
Answers checklist.
General issue report
I'm using this example https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/hid
Please tell me some ways or reasons,thanks
Through another project, usb_host_lib, the parameters of the scanning gun I am currently using are read as follows: