MATLAB: Do I have difficulties transmitting data through a serial connection from one xPC Target machine to another with xPC Target 3.2 (R2007a)

Simulink Real-Time

I want to run 2 xPC Target machines which exchange data through a serial connection. I also want to make use of FIFO buffers when sending and receiving this data. My model works fine when I cross-connect port A and B on one xPC Target machine to test my model's send and receive part. However, when sending data from one machine to another it seems only the first part of a long message gets transmitted.

Best Answer

The issue is that when sending data from one xPC Target machine to another there is a synchronization step missing for both machines.
If you are running a test on one machine by cross-connecting serial ports A and B then the send and receive part of the model are running on the same clock and there is no issue to receive the full message that was sent out.
However, if you run on 2 separate machines the receive part on the second machine might execute before the send part on the first machine finished and so you only read a part of the whole message.
You can use a FIFO binary read block to check if a message with specified header and length is available in the FIFO buffer. Details on this block can be found in the xPC Target Documentation.