Page 1 of 1

Understanding the OUT EP handling in Serial-over-USB driver

Posted: Thu Jun 22, 2017 3:06 am
by baoshi
Hi,
First let me say the driver works perfectly OK.

But when I digging into the code, some part I cannot understand. Here I'm based on ChibiOS 17.6.0, I think the part in 16.1.8 is identical.
When an OUT packet arrives at data EP, here is what happens:
1. The USB lld saves the packet to assigned buffer. When small packet received or buffer full, user callback (sduDataReceived) is called.
2. In sduDataReceived, received buffer is filled in ibqueue. CHN_INPUT_AVAILABLE is fired and waiting thread are waked up *later* to process the queue.
3. sduDataReceived prepares next receiving using sdu_start_receive()
4. sdu_start_receive() will start receiving if: USB state is ACTIVE or READY; USB is not receiving; ibqueue has an empty buffer.
Suppose the thread waiting for ibqueue is not fast enough to empty the queue, sdu_start_receive() will not start receiving, and subsequent USB OUT packet will be NAKed.

My question is: when the OUT endpoint will be armed again once ibqueue becomes empty? I'm not able to locate the code does this.

Thanks

Baoshi

Re: Understanding the OUT EP handling in Serial-over-USB driver

Posted: Thu Jun 22, 2017 10:33 am
by Giovanni
Hi,

The buffers object has callbacks, OUT transactions are restarted in callbacks.

Giovanni

Re: Understanding the OUT EP handling in Serial-over-USB driver

Posted: Thu Jun 22, 2017 12:05 pm
by baoshi
Got it. In ibnotify of hal_serial_usb.c
Thanks!