send a Report Descriptor HID on the USB port with python in es32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
hamkalasi
Posts: 2
Joined: Fri Jul 08, 2022 6:47 am

send a Report Descriptor HID on the USB port with python in es32

Post by hamkalasi » Fri Jul 08, 2022 7:51 am

Hello

I want to use The boot.py file in the URL(https://github.com/pmvr/micropython-fid ... ff91999c91) to send my Report Descriptor HID to the USB port, but there is no support for the library(import pyb), I used from libraries(machine.UART() -serial - time ), able not send my Report Descriptor HID through the USB port!


I followed various links about libraries - sample codes and instructions, but I didn't get an answer
Please guide me.

My source code...

from machine import UART


HID_PACKET_SIZE = 64
HID_FIDO_ReportDesc = bytes((
0x06, 0xd0, 0xf1, # USAGE_PAGE (FIDO Alliance)
0x09, 0x01, # USAGE (Keyboard)
0xa1, 0x01, # COLLECTION (Application)

0x09, 0x20, # USAGE (Input Report Data)
0x15, 0x00, # LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255)
0x75, 0x08, # REPORT_SIZE (8)
0x95, HID_PACKET_SIZE, # REPORT_COUNT (64)
0x81, 0x02, # INPUT (Data,Var,Abs)
0x09, 0x21, # USAGE(Output Report Data)
0x15, 0x00, # LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255)
0x75, 0x08, # REPORT_SIZE (8)
0x95, HID_PACKET_SIZE, # REPORT_COUNT (64)
0x91, 0x02, # OUTPUT (Data,Var,Abs)

0xc0 # END_COLLECTION
))


uart = UART(115200)
if uart.any():
uart.write(HID_FIDO_ReportDesc, vid=0xaffe, pid=0x7b01)

#uart.init(115200, bits=8, parity=None, stop=1)


Thanks.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: send a Report Descriptor HID on the USB port with python in es32

Post by jimmo » Fri Jul 08, 2022 1:03 pm

hamkalasi wrote:
Fri Jul 08, 2022 7:51 am
I want to use The boot.py file in the URL(https://github.com/pmvr/micropython-fid ... ff91999c91) to send my Report Descriptor HID to the USB port, but there is no support for the library(import pyb), I used from libraries(machine.UART() -serial - time ), able not send my Report Descriptor HID through the USB port!
The ESP32 does not have USB support. The project you linked to is for the pyboard-d, which is based on an stm32 part with built-in USB support.

(The USB port on most ESP32 boards is connected via a dedicated USB-to-UART converter chip, and only supports being a serial port).

hamkalasi
Posts: 2
Joined: Fri Jul 08, 2022 6:47 am

Re: send a Report Descriptor HID on the USB port with python in es32

Post by hamkalasi » Fri Jul 08, 2022 3:20 pm

Thank you for your answer

From your talk, it can be understood that not able to use libraries (machine - serial)for USB port connection for the launch of any project on the esp32 board.
------------------------------------------------------------------------------------------

So can I use the TX and RX pins(UART) to connect to the computer's USB through USB Cables and run the project?
I mean:
from machine import UART
import time
uart = UART(1, baudrate=115200, tx=1, rx=3)

while True:
data = uart.any()
if data:
data = uart.read()
if data == b'reset':
uart = UART(0, baudrate=115200, tx=1, rx=3)
else:
uart.write(data)
-------------------------------------------------------------------------------

Excuse me, I have a question about the Report Descriptor HID that micropython firmware.
Does micropython firmware through USB port send Report myself descriptor HID?
Can we change the Report descriptor HID defined at micropython firmware and again compile source code?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: send a Report Descriptor HID on the USB port with python in es32

Post by jimmo » Mon Jul 11, 2022 6:00 am

hamkalasi wrote:
Fri Jul 08, 2022 3:20 pm
So can I use the TX and RX pins(UART) to connect to the computer's USB through USB Cables and run the project?
Yes.
hamkalasi wrote:
Fri Jul 08, 2022 3:20 pm
Excuse me, I have a question about the Report Descriptor HID that micropython firmware.
Does micropython firmware through USB port send Report myself descriptor HID?
Can we change the Report descriptor HID defined at micropython firmware and again compile source code?
Yes. The specifics depends which port/chip you're using though, so need more information.

Post Reply