KernelTimer mystery using USBDevice #551
Closed
u77345
started this conversation in
Development
Replies: 2 comments
-
|
A kernel timer handler is called at IRQ_LEVEL from the system timer IRQ
handler. At this level other IRQs are disabled, as long the kernel timer
handler runs. Writing to the a CUSBSerialDevice is a complex operation, which
includes steps, where the USB IRQ handler has to be called. Because IRQs are
forbidden, the USB driver waits forever for the USB IRQ and the system hangs.
The conclusion is, that you normally cannot write to a CUSBSerialDevice from a
kernel timer handler.
There's a solution, if you must write to a CUSBSerial device from a kernel
timer handler. You can use the class CWriteBufferDevice to buffer the writes in
the timer handler and complete the writes in your application's main loop at
TASK_LEVEL by calling CWriteBufferDevice::Update(). Please have a look at
sample/40-irqlatency, which uses the class CWriteBufferDevice to buffer writes
to CScreenDevice. You can use CUSBSerialDevice similar to CScreenDevice in
this sample.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thanks, Rene! What an elegant solution! It only took two prompts to Claude in Cursor to integrate. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What could be the reason the write to USBSerial device from kernel timer callback locks up?
The assertions pass, and the logger correctly finds and prints m_magic as expected. However, when I attempt to write the CDevice (CUSBSerial), the application locks up. What could be causing this, how can I further diagnose it?
Beta Was this translation helpful? Give feedback.
All reactions