<< serialopen Serialport serialread >>

Serialport >> Serialport > serialport

serialport

Create high level object (tlist) of class serialport

Calling Sequence

sp = serialport(name,parameters)

Arguments

name

string, name of serial port

parameters

varargin, strings or numbers, baud rate, parity, data_bits and stop bits. These values can be combined in specified order in 1 to 4 string or numeric scalar arguments. Default values are 9600,'N',8,1.

Description

High level procedure.

Open serial port and return the object.

This object has following attributes and methods:

Attributes

fd

number, file handle.

baud

number, baud rate

data_bits

number, (5..8)

stop_bits

number, 1 or 2

parity

0 - none, 1 - Odd, 2 -Even

break

number, 0 or 1

flow_control

0 - none, 1 - Hard, 2 - Soft, 3 - Hard + Soft

dtr

DTR status

dsr

DSR status

rts

RTS status

cts

CTS status

dcd

DCD status

ri

RI status

timeout

Timeout in milliseconds

line_separator

Characters used to mark end of line, default ascii(10)

Methods

write(str1[,str2,..])

write string(s)

writeln(str1[,str2,..])

write string(s) and send line_separator after each row of each string

s = read(count[,binary])

Read and return string or bytes, default count is 1024.

s = readln()

Read up to line_separator, return string

close()

close serial port

Examples

sp = serialport('/dev/ttyS0', '19200,N, 8, 1')
disp( sp.ri )
sp.writeln('*idn?')
answer = sp.readln()  # NOTE! Brackets required.
mprintf( answer )
sp.close()

See Also. Low level functions:

Author


Report an issue
<< serialopen Serialport serialread >>