serialport

Connects and Communicates with Serial port.

Attention: Valid only with Altair Communication Extension.

Syntax

spobj = serialport(Port, Baudrate)

spobj = serialport(Port, [Name, Value])

Inputs

Port
Serial port interface path.
Type: string
Baudrate
Baudrate value.
Type: scalar
Name, Value
Name
Type: string
Valid options are:
Name
Value
Baudrate
Baudrate value.
Type: scalar
Timeout
Numeric value in seconds. Negative value to wait forever.
Type: double
Stopbits
Number of stopbits to use.
Type: scalar
Parity
Parity setting 'none', 'even', 'odd'. Default value 'none'.
Type: string
Databits
Number of bits to a byte (5 to 8).Default value 8.
Type: scalar
FlowControl
Flowcontrol values 'none', 'hardware', 'software'. Default value 'none'.
Type: scalar
UserData
User data to store in serialport object.
Type: scalar | vector | matrix | struct | cell | Boolean | string

Outputs

spobj
serialport object.
Type: serial port
property, values
Type: string
Valid options are:
Property Name
Description/Values
Baudrate
Baudrate value.
Type: scalar
Timeout
Numeric value in seconds. Negative value to wait forever.
Type: double
Stopbits
Number of stopbits to use.
Type: scalar
Parity
Parity setting 'none', 'even', 'odd'. Default value 'none'.
Type: string
Databits
Number of bits to a byte (5 to 8).Default value 8.
Type: scalar
FlowControl
Flowcontrol values 'none', 'hardware', 'software'. Default value 'none'.
Type: scalar
UserData
User data to store in serialport object.
Type: scalar | vector | matrix | struct | cell | Boolean | string
Function Name, Syntax
Type: string
Valid options are:
Function Name
Description/Syntax/Arguments
read
reads data.
data=read() data=read(NumberOfValues) data=read(NumberOfValues,DataType) NumberOfValues is a scalar. Supported "DataType" values are 'string', 'double' ,'float', 'int8','int16','int32','int64','uint8','uint16','uint32','uint64'.
write
writes data.
data=write(Data) data=write(Data,DataType) Supported type for "Data" is string, real number. Supported "DataType" values are 'string', 'double' ,'float','int8','int16','int32','int64','uint8','uint16','uint32','uint64'.
close
Closes Serialport.

Examples

Read/write string data:
spobj=serialport();
spobj.read()
spobj.write('Hello serialport','string');
spobj.close();
Read/write numeric data:
spobj=serialport();
data=9;
spobj.write(data,'double');
out=spobj.read(1,'double')
spobj.close();