This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ASCII Decode V2

ASCII Decode V2


Simulink® Real-Time™ Library for RS-232


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

It makes the converted values available to a Simulink program. It assumes that the input vector was prepared using an output format specifier similar to printf and uses an input format specifier similar to scanf.

The input vector to the ASCII Decode block can be either 8-bit or 16-bit and signed or unsigned. If the data format is 16-bit, the ASCII Decode block ignores the upper 8 bits of each entry.

This block generates inline code for the target computer. You cannot use it for Simulink simulation.

Block Parameters


Enter a scanf like format string. Each format specifier such as %d must match a corresponding part of the input vector. Literal character vectors in the format must match the first character plus the number of characters. Acceptable format specifiers are the following, enclosed in single quotes. Failure to include these quotes causes simulation failures: %c, %d, %i, %o, %u, %x, %e, %f, and %g. These follow the normal description for scanf. The number of format specifiers actually satisfied by the input character vector is known as the count output.

An example format string is:

'foo %d bar %f\n'

In this example, assume that the data from the FIFO read is 'foo 5'. In this case, the count output is 1 and the second output will be unchanged from the last time both were found in a character vector. If the model expects two values, and the returned count output value is less than two, the model detects an error in the data.

Introduced in R2008a

Was this topic helpful?