Main Content

SCI Read

Read serial data from UART port

Add-On Required: This feature requires the Simulink Coder Support Package for Beaglebone Blue Hardware add-on.

  • SCI Read block

Libraries:
Simulink Coder Support Package for BeagleBone Blue Hardware / Communication

Description

The SCI Read block reads an N-by-1 array of data from the Universal Asynchronous Receiver Transmitter (UART) on the hardware, where N is the length of data to be read.

If you simulate a model that contains the SCI Read block without connecting the hardware, the block outputs zeroes. See Block Produces Zeros or Does Nothing in Simulation.

This block operates in nonblocking mode.

Ports

Output

expand all

The Data port outputs the data read from the selected UART.

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

When the length of data received is greater than or equal to the length specified in the Data length (N) parameter, the block outputs 0. The value 0 indicates a successful read operation. When the length of data received is less than the length specified in the Data length (N) parameter, the block outputs a nonzero value.

For example, when the length of data received is 9 and N = 8, the Status port outputs 0, indicating a successful read operation. When the length of data received is 9 and N = 10, the Status port outputs 32, indicating that data is not available.

Length of Data Received = 9
PortData TypeData Length
N = 8N = 9N = 10
Datauint8899
Statusuint80032

Data Types: uint8

Parameters

expand all

Specify the serial port on the hardware that is connected to the serial device. For example, if the port UT0 is connected to a serial device, specify this parameter as /dev/ttyO0. To view the BeagleBone® Blue pinout, click the View pin map button.

Select the number of bits to receive per second. The received bits include the start bit, the data bits, the parity bit (if defined), and the stop bits.

Select a parity to provide simple error checking for the received data. The table shows the types of parity checking.

Parity TypeDescription
NoneNo parity checking.
EvenThe data bits plus the parity bit result in an even number of 1s.
OddThe data bits plus the parity bit result in an odd number of 1s.

The parity checking process follows these steps:

  1. The transmitting device sets the parity bit to 0 or 1, depending on the data bit values and the type of parity-checking selected.

  2. The receiving device checks if the parity bit is consistent with the transmitted data. If it is, the data bits are accepted. If it is not, an error is returned.

For example, suppose the data bits 01110001 are transmitted to your computer. If even parity is selected, the parity bit is set to 0 by the transmitting device to produce an even number of 1s. If odd parity is selected, the parity bit is set to 1 by the transmitting device to produce an odd number of 1s.

Note

Parity checking can detect only 1-bit errors. Multiple-bit errors can appear as valid data.

Select the number of stop bits used to indicate the end of a byte.

  • 1 — One stop bit is transmitted to indicate the end of a byte.

  • 2 — Two stop bits are transmitted to indicate the end of a byte.

Select the type of data to be read from the UART port.

Specify the number of values to be read from the UART port for the selected data type.

Specify the time interval to read data from the UART port, specified in seconds. When you set this parameter to -1, Simulink® determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2019a

See Also