I am reading how to interact with USB, and having issues.
The docs say you can just attach an event listener like so: Serial.onEvent(ARDUINO_HW_CDC_RX_EVENT, _onUsbEvent0);
- the intention is to get called when there is any data to read from Serial
.
However, the _onUsbEvent0
function never gets invoked. Is there any special configuration that is needed?
Just to make sure that things are wired correctly, I created a task that wakes up every 10ms and checks that Serial.available() > 0
, and in that case reads from it. This works as intended - I can see the data show up, and I can read the data. So it really is about onEvent
specifically.
This is LilyGo based on ESP32-S3, in case this matters.
Ok, by popular request, here's the reproducer.
There's not much to see - main.cpp basically initialized comms using some default config (which is just defaults). The meat of the problem is in comms.cpp, the initialization routine.
If I use it as is - i.e. as presented in the commit - I am able to communicate. If I comment out lines 85..86, and uncomment line 83 alone or together with line 84, then I don't see any _onUsbEvent0
calls, and no communication happens.
Communication is performed using scan.c
in the same project. It opens a fixed USB device, writes a command, and waits for N responses.