Main Content

writebinblock

Write one binblock of data to serial port

Description

example

writebinblock(device,data,precision) converts data into a binblock and writes it to the serial port. data can be a string, character vector, or numeric 1-by-N matrix. The written data has the specified precision regardless of the format in the matrix. The function blocks MATLAB and waits until the binblock data is written to the serial port.

Examples

collapse all

Convert [1,2,3,4,5] to a binblock and write it to the serial port as uint8.

s = serialport("COM3",9600);
 ⋮
writebinblock(s,1:5,"uint8")

Input Arguments

collapse all

Serial port, specified as a serialport object.

Example: serialport()

Numeric or ASCII data to write to serial port, specified as a string, character vector, or 1-by-N vector of numeric values. For all numeric precision types, data is a row vector of values.

Example: [20:24]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

Size and format of each value, specified as a character vector or string. precision determines the number of bits to write for each value and its format as a MATLAB data type. For ASCII text, you can specify precision as either 'char' or 'string'.

Example: 'int16'

Data Types: char | string

See Also

Functions

Introduced in R2019b