eclipse-threadx / usbx

Eclipse ThreadX - USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Eclipse ThreadX RTOS
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/usbx/index.md
MIT License
154 stars 89 forks source link

_ux_host_class_hid_transfer_request_completed 中的内存浪费 #49

Open HelloByeAll opened 2 years ago

HelloByeAll commented 2 years ago

_ux_host_class_hid_transfer_request_completed.c 中处理接收数据时,为什么申请的大小为item的数量而不是实际需要的大小?

对于下面这个设备来说, item的数量是264个, 但实际需要处理的数据只有8个, 在32位上需要的内存也仅只有 (8+6) << 3, 比这里的264<<3,所需要的内存要小很多 image

image

xiaocq2001 commented 2 years ago

Thanks for the feedback.

Yes. The first byte is extracted to 8 items, the second byte is extracted to 1 item, the following bytes are extracted to 1 item for each byte. But currently difference of 1st byte against others are not logged for extraction (and if the position is changed, e.g., if there were bit fields after bytes in custom report, the calculation is more complex), so for safer operation currently max memory size is allocated.

We will analyze and try to create better solution. Your suggestion is also appreciated.