I am using SerialUsbDriver to realize simple protocol.
My device wait a command from host, do some actions and return a response.
Code: Select all
eventflags_t flags;
event_listener_t protocolDataEvent;
//.....
chEvtRegisterMask((event_source_t *)chnGetEventSource(&usb_serial),
&protocolDataEvent,
EVENT_MASK(CHN_INPUT_AVAILABLE));
while (true)
{
chEvtWaitOneTimeout(EVENT_MASK(CHN_INPUT_AVAILABLE), MS2ST(10));
flags = chEvtGetAndClearFlags(&protocolDataEvent);
if (flags & CHN_INPUT_AVAILABLE)
{
//WORK LOGIC...
}
}
I noticed a strange behavior (or bug)
when i send packet from host to device with Length(bytes) % 64 == 0(64, 128, 192 etc...) event not fired
after few second i can send one(or more) byte from host and event will fire.
Is it a magic feature? or i dont understand anything??
i suppose driver wait for another bytes, why??
Thanks.