configureTerminator

Set terminator for ASCII string communication on serial port

Description

example

configureTerminator(device,term) defines the terminator for both read and write communications with the specified serial port device. Allowed terminator values are "LF" (default), "CR", "CR/LF", and integer values from 0 to 255.

example

configureTerminator(device,readterm,writeterm) defines separate terminators for read and write communications with the specified serial port device.

Examples

collapse all

Set both the read and write terminators to "CR/LF", and then confirm the setting.

s = serialport("COM3",9600);
configureTerminator(s,"CR/LF")
s.Terminator
ans = 

    "CR/LF"

Set the read terminator to "CR" and the write terminator to 10, then confirm the settings.

s = serialport("COM3",9600);
configureTerminator(s,"CR",10)
s.Terminator
ans =

  1×2 cell array

    {["CR"]}    {[10]}

Input Arguments

collapse all

Serial port, specified as a serialport object.

Example: serialport()

ASCII terminator for serial port read and write communication, specified as a string, character vector, or numeric integer value 0 to 255. Use this form when setting the same terminator for both read and write. When reading from the port with a terminator value of "CR/LF", the read terminates on the occurrence of CR and LF together. When writing to the port with a terminator value of "CR/LF", the write terminates by adding both.

Example: "CR"

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

ASCII terminators for serial port read or write communication, specified as a string, character vector, or numeric integer value 0 to 255. Use this form when setting different terminators for read and write. When reading from the port with a terminator value of "CR/LF", the read terminates on the occurrence of CR and LF together. When writing to the port with a terminator value of "CR/LF", the write terminates by adding both.

Example: "CR"

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

Introduced in R2019b