3.7 Serial (Deprecated)

3.7.1 @octave_serial/fclose

Function File: res = fclose (obj)

Closes SERIAL connection obj

3.7.2 @octave_serial/flushinput

Loadable Function: flushinput (serial)

Flush the pending input, which will also make the BytesAvailable property be 0.

Inputs

serial - instance of octave_serial class.

Outputs

None

See also: srl_flush, flushoutput.

3.7.3 @octave_serial/flushoutput

Loadable Function: flushoutput (serial)

Flush the output buffer.

Inputs

serial - instance of octave_serial class.

Outputs

None

See also: srl_flush, flushinput.

3.7.4 @octave_serial/fopen

Function File: res = fopen (obj) (dummy)

Opens SERIAL interface obj

This currently is a dummy function to improve compatibility to MATLAB

3.7.5 @octave_serial/fprintf

Function File: numbytes = fprintf (obj, template ...)

Writes formatted string template using optional parameters to serial instrument

Inputs

obj is a serial object.
template Format template string

Outputs

numbytes - number of bytes written to the serial device.

3.7.6 @octave_serial/fread

Function File: data = fread (obj)
Function File: data = fread (obj, size)
Function File: data = fread (obj, size, precision)
Function File: [data,count] = fread (obj, ...)
Function File: [data,count,errmsg] = fread (obj, ...)

Reads data from serial instrument

Inputs

obj is a serial object.
size Number of values to read. (Default: 100).
precision precision of data.

Outputs

data The read data.
count values read.
errmsg read operation error message.

3.7.7 @octave_serial/fwrite

Function File: numbytes = fwrite (obj, data)
Function File: numbytes = fwrite (obj, data, precision)

Writes data to serial instrument

Inputs

obj is a serial object.
data data to write.
precision precision of data.

Outputs

returns number of bytes written.

3.7.8 @octave_serial/get

Function File: struct = get (serial)
Function File: field = get (serial, property)

Get the properties of serial object.

Inputs

serial - instance of octave_serial class.
property - name of property.

Outputs

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.

3.7.9 @octave_serial/serialbreak

Function File: serialbreak (serial)
Function File: serialbreak (serial, time)

Send a break to the serial port

Inputs

serial - serial object
time - number of milliseconds to break for. If not specified a value of 10 will be used.

Outputs

None

See also: serial.

3.7.10 @octave_serial/set

Function File: set (obj, property,value)
Function File: set (obj, property,value,…)

Set the properties of serial object.

Inputs

serial - instance of octave_serial 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.

Properties

’baudrate’

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.

’bytesize’

Set the bytesize. Supported values: 5, 6, 7 and 8.

’name’

Set the stored string name of the serial object.

’parity’

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

’stopbits’

Set the number of stopbits. Supported values: 1, 2.

’timeout’

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).

’requesttosend’

Set the requesttosend (RTS) line.

’dataterminalready’

Set the dataterminalready (DTR) line.

Outputs

None

See also: @octave_serial/get.

3.7.11 @octave_serial/srl_baudrate

Loadable Function: srl_baudrate (serial, baudrate)\
Loadable Function: br = srl_baudrate (serial)

Set new or get existing serial interface baudrate parameter. Only standard values are supported.

Inputs

serial - instance of octave_serial class.
baudrate - the baudrate value used. Supported values: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600 19200, 38400, 57600, 115200 and 230400.

If baudrate parameter is omitted, the srl_baudrate() shall return current baudrate value as the result br.

Outputs

br - The currently set baudrate

This function is obsolete. Use get and set method instead.

3.7.12 @octave_serial/srl_bytesize

Loadable Function: srl_bytesize (serial, bsize)
Loadable Function: bs = srl_bytesize (serial)

Set new or get existing serial interface byte size parameter.

Inputs

serial - instance of octave_serial class.
bsize - byte size of type Integer. Supported values: 5/6/7/8.

If bsize parameter is omitted, the srl_bytesize() shall return current byte size value or in case of unsupported setting -1, as the result bs.

This function is obsolete. Use get and set method instead.

Outputs

bs -the currently set byte size.

3.7.13 @octave_serial/srl_close

Loadable Function: srl_close (serial)

Close the interface and release a file descriptor.

Inputs

serial - instance of octave_serial class.

This function is obsolete. Use fclose() method instead.

Outputs

None

3.7.14 @octave_serial/srl_flush

Loadable Function: srl_flush (serial, [q])

Flush the pending input/output.

Inputs

serial - instance of octave_serial class.
q - queue selector of type Integer. Supported values:

0

flush untransmitted output

1

flush pending input

2

flush both pending input and untransmitted output.

If q parameter is omitted, the srl_flush() shall flush both, input and output buffers.

Outputs

None

3.7.15 @octave_serial/srl_parity

Loadable Function: srl_parity (serial, parity)
Loadable Function: p = srl_parity (serial)

Set new or get existing serial interface parity parameter. Even/Odd/None values are supported.

Inputs

serial - instance of octave_serial class.
parity - parity value of type String. Supported values: Even/Odd/None (case insensitive, can be abbreviated to the first letter only)

If parity parameter is omitted, the srl_parity() shall return current parity value as the result p.

This function is obsolete. Use get and set method instead.

Outputs

p - The currently set parity

3.7.16 @octave_serial/srl_stopbits

Loadable Function: srl_stopbits (serial, stopb)
Loadable Function: sb = srl_stopbits (serial)

Set new or get existing serial interface stop bits parameter. Only 1 or 2 stop bits are supported.

Inputs

serial - instance of octave_serial class.
stopb - number of stop bits used. Supported values: 1, 2.

Outputs

If stopb parameter is omitted, the srl_stopbits() shall return current stop bits value as the result sb.

This function is obsolete. Use get and set method instead.

3.7.17 @octave_serial/srl_timeout

Loadable Function: srl_timeout (serial, timeout)
Loadable Function: t = srl_timeout (serial)

Set new or get existing serial interface timeout parameter used for srl_read() requests. The timeout value is specified in tenths of a second.

Inputs

serial - instance of octave_serial class.
timeout - srl_read() timeout value in tenths of a second. A value of -1 means a blocking call. Maximum value of 255 (i.e. 25.5 seconds).

Outputs

If timeout parameter is omitted, the srl_timeout() shall return current timeout value as the result t.

This function is obsolete. Use get and set method instead.

3.7.18 serial

Loadable Function: serial = serial ([path], [baudrate], [timeout])

Open serial interface.

Inputs

path - the interface path of type String.
baudrate - the baudrate of interface. If omitted defaults to 115200.
timeout - the interface timeout value. If omitted defaults to blocking call.

Outputs

The serial() shall return an instance of octave_serial class as the result serial.

Properties

The serial object has the following public properties:

name

name assigned to the object

type

instrument type ’serial’ (readonly)

port

OS specific port name (readonly)

status

status of the object ’open’ or ’closed’ (readonly)

timeout

timeout value used for waiting for data

bytesavailable

number of bytes currently available to read (readonly)

stopbits

number of stopbits to use

requesttosend

request to send state - ’on’ or ’off’

parity

Parity setting ’none’, ’even’, ’odd’

bytesize

Number of bits to a byte (7 or 8)

baudrate

Baudrate setting

dataterminalready

state of dataterminal ready - ’on’ or ’off’

pinstatus

current state of pins (readonly)

3.7.19 seriallist

Function File: list = seriallist ()

Returns a list of all serial ports detected in the system.

Inputs

None

Outputs

list is a string cell array of serial ports names detected in the system.

See also: instrhwinfo("serial").

3.7.20 srl_read

Loadable Function: [data, count] = srl_read (serial, n)

Read from serial interface.

Inputs

serial - instance of octave_serial class.
n - number of bytes to attempt to read of type Integer.

Outputs

The srl_read() shall return number of bytes successfully read in count as Integer and the bytes themselves in data as uint8 array.

3.7.21 srl_write

Loadable Function: n = srl_write (serial, data)

Write data to a serial interface.

Inputs

serial - instance of octave_serial class.
data - data to be written to the serial interface. Can be either of String or uint8 type.

Outputs

Upon successful completion, srl_write() shall return the number of bytes written as the result n.