ASCII Encoding/Decoding Loopback Test
This model shows how to send ASCII data over a serial link.
The ASCII Encode block generates a message with three different sub messages along with some extraneous 'junk' to show how the FIFO Read HDRS block can remain synchronized to the valid byte stream even in the presence of transmission errors.
The FIFO Read HDRS block can handle an arbitrary number of headers; just add them as strings to the cell array in the block parameters dialog box. The messages must share the same termination string. In this example, it is a carriage return followed by a line feed: "\r\n".
open_system(fullfile(matlabroot,'toolbox','rtw','targets','xpc','xpcdemos','xpcserialasciitest')) set_param('xpcserialasciitest','StopTime','30'); sim('xpcserialasciitest')