Main Content

SCI Receive

Configure host-side serial communications interface to receive data from serial port

  • Library:
  • Embedded Coder / Embedded Targets / Host Communication

  • SCI Receive block

Description

The SCI Receive block specifies the configuration of a data package that is received from a target computer by this block.

Ports

Output

expand all

Data package, specified as a scalar or vector, which is received from a target computer. The package can consist of headers, terminators, and data elements. The package size is limited to 16 bytes of ASCII characters, including headers and terminators. Calculate the size of a package by adding the byte sizes of headers, terminators, and the data.

This table lists the number of bytes for supported data types.

Data TypeByte Count
single4 bytes
int8 and uint81 byte
int16 and uint162 bytes
int32 anduint324 bytes

For example, if your data package includes a 1-byte package header, 'S', and a 1-byte package terminator, 'E', 14 bytes remain for data. If your data is of type int8, the data can consist of up to 14 data elements. If your data is of type uint16, the data can consist of up to 7 data elements. If your data is of type int32, the data package can consist of up to 3 data elements with 2 bytes left over. Because you cannot mix data types in a package, the remaining 2 bytes are not used.

The number of data elements that can fit into a data package determine the data length (see the Data length parameter). In the preceding example, the 14 data elements of type int8 and the 7 data elements of type uint16 are the data lengths for each data package, respectively. When the data length exceeds 16 bytes, unexpected behavior, including run-time errors, can result.

Data Types: single | int8 | int16 | int32 | uint8 | uint16 | uint32

Optional error status value for data transmissions.

Possible status values are listed in this table.

Status valueCondition
0

No errors.

1Connection timed out while block was waiting to receive data.
2Checksum error. Received data contains an error.
3SCI parity error. Character was received with a mismatch.
4SCI framing error. Expected stop bit was found.

Port Dependencies

To enable this port, select parameter Output receiving status.

Parameters

expand all

Specify the name of the COM port that you are configuring for this SCI Receive block. You can configure up to four COM ports for a model, one COM port for each SCI Receive block in the model.

Specify the header of the received data package as an ASCII value in single quotes. The value can be text or a number in the range 0 to 255. The quotes are not received and are not included in the package byte count.

The header is not part of the data being received. Typically, the header marks the start of the data. The header that you specify must match the header specified for the corresponding target computer SCI Transmit block.

Specify the terminator of the received data package as an ASCII value in single quotes. The value can be text or a number in the range 0 to 255. The quotes are not received and are not included in the package byte count.

The terminator is not part of the data being received. Typically, the terminator marks the end of the data. The terminator that you specify must match the terminator specified for the corresponding target computer SCI Transmit block.

Specify the data type of the input port of the corresponding target computer SCI Transmit block. The data type and corresponding byte count are inherited from the input port.

Specify the number of data elements of the specified data type that the block receives from the target computer SCI Transmit block. A value other than 1 is treated as a vector. The data length is inherited from the length of the target computer SCI Transmit block input data.

Specify a value that the block outputs as the last value received when these conditions exist:

  • Parameter Action taken when connection times out is set to Output the last received value.

  • No data has been received.

  • A connection times out.

Parameter Dependencies

To enable this parameter, set Action taken when connection times out to Output the last received value.

Specify the output value that the block writes when a connection times out. The block can write the last value received or a custom value.

Parameter Dependencies

If you specify Output custom value, use parameter Output value when connection times out to set the custom value.

Specify the custom value to output when a connection times out.

Parameter Dependencies

To enable this parameter, set Action taken when connection times out to Output custom value.

Specify the frequency at which the scheduler calls the SCI Receive block in seconds. To achieve either of these conditions, set this parameter to -1:

  • The block inherits the sample time setting of the model.

  • The block executes asynchronously.

Select this parameter to create a status block output port that provides the status of data transmissions.

Extended Capabilities

Introduced in R2011a