(serial, term)
¶(serial, readterm, writeterm)
¶Set terminator for ASCII string manipulation
serial - serialport object
term - terminal value for both read and write
readterm = terminal value type for read data
writeterm = terminal value for written data
The terminal can be either strings "cr", "lf" (default), "lf/cr" or an integer between 0 to 255.
None
See also: serialport.
data =
flush (dev)
¶data =
flush (dev, "input")
¶data =
flush (dev, "output")
¶Flush the serial port buffers
dev - connected serialport device
If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed
None
See also: serialport.
numbytes =
fprintf (obj, template ...)
¶Writes formatted string template using optional parameters to serialport instrument
obj is a serialport object.
template Format template string
numbytes - number of bytes written to the serial device.
data =
fread (obj)
¶data =
fread (obj, size)
¶data =
fread (obj, size, precision)
¶[data,count] =
fread (obj, ...)
¶[data,count,errmsg] =
fread (obj, ...)
¶Reads data from serial port instrument
obj is a serialport object.
size Number of values to read.
precision precision of data.
data The read data.
count number of values read.
errmsg read operation error message.
struct =
get (serial)
¶field =
get (serial, property)
¶Get the properties of serialport object.
serial - instance of octave_serialport class.
property - name of property.
When property was specified, return the value of that property.
otherwise return the values of all properties as a structure.
See also: @octave_serial/set.
status
getpinstatus (serial)
¶Get status of serial pins
serial - serial object
status - a structure with the logic names of ClearToSend, DataSetReady, CarrierDetect, and RingIndicator
See also: serialport.
data =
read (dev, count)
¶data =
read (dev, count, precision)
¶Read a specified number of values from a serialport using optional precision for valuesize.
dev - connected serialport device
count - number of elements to read
precision - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16, uint32, int32, uint64, uint64
data - data read from the device
See also: serialport.
set
(obj, property,value)
¶set
(obj, property,value,…)
¶Set the properties of serialport object.
serial - instance of octave_serialport class.
property - name of property.
If property is a cell so must be value, it sets the values of all matching properties.
The function also accepts property-value pairs.
Set the baudrate of serial port. Supported values by instrument-control: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200 and 230400. The supported baudrate of your serial port may be different.
Set the bytesize. Supported values: 5, 6, 7 and 8.
Set the stored string name of the serial object.
Set the parity value. Supported values: Even/Odd/None. This Parameter must be of type string. It is case insensitive and can be abbreviated to the first letter only
Set the number of stopbits. Supported values: 1, 2.
Set the timeout value in tenths of a second. Value of -1 means a blocking call. Maximum value of 255 (i.e. 25.5 seconds).
Set the requesttosend (RTS) line.
Set the dataterminalready (DTR) line.
None
See also: @octave_serialport/-get.
(dev, true_false)
¶Set the state of the DTR line
dev - connected serial device.
true_false - state to set the line.
None
See also: serialport, getpinstatus, setRTS.
(dev, true_false)
¶Set the state of the RTS line
dev - connected serial device.
true_false - state to set the line.
None
See also: serialport, getpinstatus.
serial =
serialport ([path], [baudrate])
¶serial =
serialport ([path], [propname, propvalue])
¶Open serial port interface.
path - the interface path of type String.
baudrate - the baudrate of interface.
propname,propvalue - property name/value pairs.
Known input properties:
Numeric baudrate value
Numeric timeout value in seconds or -1 to wait forever
number of stopbits to use
Parity setting ’none’, ’even’, ’odd’
Number of bits to a byte (5 to 8)
Number of bits to a byte ’none’, ’hardware’, ’software’
The serialport() shall return an instance of octave_serialport class as the result serial.
The serial object has the following public properties:
name assigned to the object
instrument type ’serial’ (readonly)
OS specific port name (readonly)
status of the object ’open’ or ’closed’ (readonly)
timeout value used for waiting for data
number of bytes currently available to read (readonly)
number of bytes written (readonly)
number of stopbits to use
Parity setting ’none’, ’even’, ’odd’
Number of bits to a byte (5 to 8)
Baudrate setting
Number of bits to a byte ’none’, ’hardware’, ’software’
current state of pins (readonly)
user defined data
list =
serialportlist ()
¶list =
serialportlist ("all")
¶list =
serialportlist ("available")
¶Returns a list of all serial ports detected in the system.
’all’ - show all serial ports (same as providing no arguments) ’available’ - show only serial ports that are available for use
list is a string cell array of serial ports names detected in the system.
See also: instrhwinfo("serialport").