I tried to verify the real time capability of the Real Time Windows Target. I built a Simulink model that send out a data from a laptop to an Arduino through the USB port. The Arduino immediate sent back the data. The model was run at a real time windows target. It read a one-byte signal through Packet input and sends a one-byte signal through Packet Output to an USB com port. The Packet Input is executed ahead of Packet Output. The execution order is enforced by setting the priority property.
I recorded the outputs of Packet Input and the input of Packet Output blocks. I expect to see one-step delay between them.
The test shows that the serial communication was not executed in real time in the Windows Target. Data seems to be stuck in the buffer of the UART chip some time. Once in a while, Rx Data Ready became false when the sampling period is 0.01 s. The signal is delayed one more step every time this happens. This is not acceptable for real time control.
The problem will not occur when the sampling time is larger, e.g., 0.02 s and happen more often with small sampling period.
Is this normal and unavoidable? Is there a way to clear the transmit buffer at the laptop to eliminate the accumulative delays?