Read serial data from UART port
Simulink Coder Support Package for BeagleBone Blue Hardware / Communication
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 (Simulink).
This block operates in nonblocking mode.
Data— Data read from UART
The Data port outputs the data read from the selected UART.
Status— Status of read operation
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
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
0, indicating a successful read operation.
When the length of data received is 9 and N = 10, the
Status port outputs
indicating that data is not available.
|Length of Data Received = 9|
|Port||Data Type||Data Length|
|N = 8||N = 9||N = 10|
Port— Serial port to which hardware is connected
/dev/ttyO1(default) | valid path and file name
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
Baudrate (in bits/s)— Serial baud rate
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.
Parity— Type of error checking for received data
Select a parity to provide simple error checking for the received data. The table shows the types of parity checking.
|No parity checking.|
|The data bits plus the parity bit result in an even number of 1s.|
|The data bits plus the parity bit result in an odd number of 1s.|
The parity checking process follows these steps:
The transmitting device sets the parity bit to 0 or 1, depending on the data bit values and the type of parity-checking selected.
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.
Parity checking can detect only 1-bit errors. Multiple-bit errors can appear as valid data.
Stop bits— Number of bits used to indicate end of byte
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.
Data type— Data type of data from UART port
Select the type of data to be read from the UART port.
Data length (N)— Number of data values to read from UART port
1(default) | nonnegative integer
Specify the number of values to be read from the UART port for the selected data type.
Sample time— How often to read data from UART port
-1| nonnegative integer
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.