hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
4.66k stars 997 forks source link

tud_task() hangs when there are no more messages in the buffer due to the timeout_ms value is set to UINT32_MAX. It should be 0, right? #2692

Closed cornedoggen closed 3 days ago

cornedoggen commented 3 days ago

Operating System

Linux

Board

Custom

Firmware

custom firmware

What happened ?

when the function tud_task() is called, it will in its turn call tud_task_ext(UINT32_MAX, false). The problem with this is that if there are no more messages in the freertos queue, the timeout value of UINT32_MAX is like stay here forever.. and system hangs. I think the value of timeout could be set to 0 to immediatly return if there is no data available in the queue.

How to reproduce ?

try to comile a cdc example with stm32u5 and freertos configured.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

I dont have any logs.

Screenshots

No response

I have checked existing issues, dicussion and documentation

HiFiPhile commented 3 days ago

No, please take a look at FreeRTOS enabled examples, tud_task() is executed in it's own task, when there is no message it's blocked to free CPU.

https://github.com/hathach/tinyusb/tree/master/examples/device/cdc_msc_freertos