Parse ASCII character vector into Simulink values
Simulink Real-Time / RS232
The ASCII Decode block parses an input vector produced by one of the following:
Serial port Receive block
Serial port FIFO Read block
ASCII Encode block
This block makes the converted values available to a real-time
application. It assumes that the
input vector was prepared using an output format specifier similar to
printf and uses an input format specifier similar to
This block generates inline code for the target computer. You cannot use it for Simulink® simulation.
Data— Input vector to parse
The input vector can be either 8-bit or 16-bit and signed or unsigned. If the data format is 16-bit, the block ignores the upper 8 bits of each entry.
cnt— Number of format specifiers satisfied by input
cnt receives the number of format specifiers
satisfied by the input character vector.
Value— Inlined ports that send Simulink values
Output ports corresponding to items in Format.
This block generates inline code for the target computer. You cannot use it for Simulink simulation.
Format— Format specifier for parsing input vector
scanf like format string. Each format
specifier such as
%d must match a corresponding part of
the input vector. Literal strings in the format must match the characters in
the input vector. The format specifiers follow the normal description for
scanf. The specifiers must be enclosed in single
quotes. Failure to include these quotes causes simulation failures.
An example format string is:
'alpha %d bravo %f\n'
In this example, the data from the FIFO read is
5'. In this case,
1 and the second output is unchanged from the last
time both were found in a character vector. If the model expects
2 values, and
cnt is less than
2, the model detects an error in the data.