Introduction

The Instrument Control toolkit is a set of low level I/O functions for serial, i2c, spi, modbus, parallel, tcp, gpib, vxi11, udp and usbtmc interfaces

Table of Contents


1 Installing and loading

The Instrument Control toolkit must be installed and then loaded to be used.

It can be installed in GNU Octave directly from octave-forge, or can be installed in an off-line mode via a downloaded tarball.

The toolkit must be then be loaded once per each GNU Octave session in order to use its functionality.

1.1 Requirements

For GPIB support (Linux only), linux-gpib must be installed before installing instrument-control. GPIB support is also available for windows by following the information from the wiki: https://wiki.octave.org/Instrument_control_package#Requirements

For VXI11 support, rpcgen, and libtirpc-devel must be installed before installing instrument-control.

For MODBUS support, the libmodbus-devel must be installed before installing instrument-control.

1.2 Windows install

If using the GNU Octave installer in Windows, the toolkit will have already been installed, and does not need to be re-installed unless a newer version is available.

Run the following command to verify if the toolkit is available:

pkg list instrument-control

1.3 Online Direct install

With an internet connection available, toolkit can be installed from octave-forge using the following command within GNU Octave:

pkg install -forge instrument-control

The latest released version of the toolkit will be downloaded, compiled and installed.

1.4 Off-line install

With the toolkit package already downloaded, and in the current directory when running GNU Octave, the package can be installed using the following command within GNU Octave:

pkg install instrument-control-0.9.5.tar.gz

1.5 Loading

Regardless of the method of installing the toolkit, in order to use its functions, the toolkit must be loaded using the pkg load command:

pkg load instrument-control

The toolkit must be loaded on each GNU Octave session.


2 Basic Usage Overview


2.1 Authors

The Instrument control package provides low level I/O functions for serial, i2c, spi, parallel, tcp, gpib, vxi11, udp and usbtmc interfaces.

It was written mainly by the following developers:

  • Andrius Sutas <andrius.sutasg at mail.com>
  • Stefan Mahr <dac922 at gmx.de>
  • John Donoghue <john.donoghue at ieee.org>

2.2 Available Interfaces

The ability to use each interface is dependent on OS and what libraries were available during the toolkit install.

To verify the available interfaces, run the following command in octave:

instrhwinfo

The function will return information on the supported interfaces that are available, similar to below:

    ToolboxVersion = 0.7.0
    ToolboxName = octave instrument control package
    SupportedInterfaces =
    {
      [1,1] = gpib
      [1,2] = i2c
      [1,3] = parallel
      [1,4] = serial
      [1,5] = serialport
      [1,6] = tcp
      [1,7] = tcpclient
      [1,8] = udp
      [1,9] = udpport
      [1,10] = usbtmc
      [1,11] = vxi11
    }

Most interfaces have two types of functions:

  • somewhat compatible matlab functions such as fread, fwrite
  • interface specific lower level functions such as udp_read, udp_write

2.3 Basic Serial

2.3.1 Serial

NOTE: The serial object has been deprecated and may not appear in newer versions of the instrument-control toolbox. Instead new code should use the serialport object.

The serial port can be opened using the serial function:

s = serial("/dev/ttyUSB1", 115200) 

The first parameter is the device name and is OS specific. The second parameter is the baudrate.

A list of available serial ports can be retrieved using the function:

seriallist

After creating the interface object, properties of the device can be set or retrieved using get or set functions or as property access.

s = serial("/dev/ttyUSB1", 115200) 
br = get(s, "baudrate") # gets the baudrate
br = s.baudrate  # also gets the baudrate

set(s, "baudrate", 9600) # set the baudrate
s.baudrate = 9600 # also sets the baudrate

The device can be written and read from using fread, fwrite and srl_read and slr_write functions.

srl_write(s, "hello world") # write hello world
fprintf(s, "hello again")

val = srl_read(s, 10) # attempt to read
val = fread(s, 10)

The device can be closed using fclose or srl_close.

fclose(s)

2.3.2 SerialPort

The recommended method of accessing serial ports is through the serialport object.

The serial port can be opened using the serialport function:

s = serialport("/dev/ttyUSB1", 115200) 

The first parameter is the device name and is OS specific. The second parameter is the baudrate.

A list of available serial ports can be retrieved using the function:

serialportlist

After creating the interface object, properties of the device can be set or retrieved using get or set functions or as property access.

s = serialport("/dev/ttyUSB1", 115200) 
br = get(s, "BaudRate") # gets the baudrate
br = s.BaudRate  # also gets the baudrate

set(s, "BaudRate", 9600) # set the baudrate
s.BaudRate = 9600 # also sets the baudrate

The device can be written and read from using read and write functions.

write(s, "hello world") # write hello world

val = read(s, 10)

The device can be closed by clearing the serialport object.

clear s

2.4 Basic TCP

2.4.1 TCP

NOTE: The TCP object has been deprecated and may not appear in newer versions of the instrument-control toolbox. Instead new code should use the tcpclient object.

A TCP connection can be opened using the tcp or tcpip function:

s = tcp("127.0.0.1", 80) 

The first parameter is the IP address to connect to. The second parameter is the port number. And optional timeout value can be also be provided.

A more matlab compatible function is available as tcpip to also open a tcp port:

s = tcpip("gnu.org", 80) 

The first parameter is a hostname or ip address, the second the port number. Additional parameter/value pairs can be provided after the port.

After creating the interface object, properties of the device can be set or retrieved using get or set functions or as property access.

s = tcp("127.0.0.1", 80)
oldtimeout = get(s, "timeout") # get timeout

set(s, "timeout", 10) # set the timeout
s.timeout = oldtimeout # also sets the timeout

The device can be written and read from using fread, fwrite and tcp_read and tcp_write functions.

tcp_write(s, "HEAD / HTTP/1.1\r\n\r\n")

val = tcp_read(s, 100, 500) # attempt to read 100 bytes

The device can be closed using fclose or tcp_close.

fclose(s)

2.4.2 TCP Client

The recommended method of creating a tcp connection is through the tcpclient object.

A TCP connection can be opened using the tcpclient function:

s = tcpclient("127.0.0.1", 80) 

The first parameter is the IP address or hostname to connect to. The second parameter is the port number.

Additional parameter/value pairs can be provided after the port.

After creating the interface object, properties of the device can be set or retrieved using get or set functions or as property access.

s = tcpclient("127.0.0.1", 80)
oldtimeout = get(s, "Timeout") # get timeout

set(s, "Timeout", 10) # set the timeout
s.Timeout = oldtimeout # also sets the timeout

The device can be written and read from using read and write functions.

write(s, "HEAD / HTTP/1.1\r\n\r\n")

val = read(s, 100) # attempt to read 100 bytes

The device can be closed by clearing the object variable.

clear s

2.5 Basic UDP

2.5.1 UDP

NOTE: The UDP object has been deprecated and may not appear in newer versions of the instrument-control toolbox. Instead new code should use the udpport object.

A UDP connection can be opened using the udp function:

s = udp("127.0.0.1", 80) 

The first parameter is the IP address data will be to. The second parameter is the port number.

If and ip address and port is not provides, it will default to "127.0.0.1" and 23.

The address and port can be changed after creation using the remotehost and remoteport properties.

s = udp() 
s.remotehost = "127.0.0.1";
s.remoteport = 100;

After creating the interface object, other properties of the device can be set or retrieved using get or set functions or as property access.

s = udp("127.0.0.1", 80)
oldtimeout = get(s, "timeout") # get timeout

set(s, "timeout", 10) # set the timeout
s.timeout = oldtimeout # also sets the timeout

The device can be written and read from using fread, fwrite and udp_read and udp_write functions.

udp_write(s, "test")

val = udp_read(s, 5)

The device can be closed using fclose or udp_close.

fclose(s)

2.5.2 UDP Port

The recommended method of creating a udp socket is through the udpport object.

A udpport object can be created using the udpport function:

s = udpport()

Additional parameter/value pairs can be provided during creation of the object.

After creating the interface object, properties of the device can be set or retrieved using get or set functions or as property access.

s = udpport()
oldtimeout = get(s, "Timeout") # get timeout

set(s, "Timeout", 10) # set the timeout
s.Timeout = oldtimeout # also sets the timeout

The device can be written and read from using read and write functions.

The destination address and port to send data to must be specified at least on the first time write is used.

write(s, "test", "127.0.0.1", s.LocalPort)

val = read(s)

The device can be closed by clearing the object variable.

clear s

3 Function Reference

The functions currently available in the toolkit are described below.


3.1 Common Functions

3.1.1 flushinput

: flushinput (dev)

Flush the instruments input buffers

Inputs

dev - connected device or array of devices

Outputs

None

See also: flushoutput.

3.1.2 flushoutput

: flushoutput (dev)

Flush the instruments output buffers

Inputs

dev - connected device or array of devices

Outputs

None

See also: flushinput.

3.1.3 readbinblock

: data = readbinblock (dev)
: data = readbinblock (dev, datatype)

read a binblock of data from a instrument device

Inputs

dev - connected device

datatype - optional data type to read data as (default ’uint8’)

Outputs

data - data read

See also: flushoutput.

3.1.4 readline

: data = readline (dev)

read data from a instrument device excluding terminator value

Inputs

dev - connected device

Outputs

data - ASCII data read

See also: flushoutput.

3.1.5 writebinblock

: writebinblock (dev, data, datatype)

Write a IEEE 488.2 binblock of data to a instrument device

binblock formatted data is defined as:

#<A><B><C>

where: <A> ASCII number containing the length of part <B>

<B> ASCII number containing the number of bytes of <C>

<C> Binary data block

Inputs

dev - connected device

data - binary data to send

datatype - datatype to send data as

Outputs

None

See also: flushoutput.

3.1.6 writeline

: writeline (dev, data)

Write data to a instrument device including terminator value

Inputs

dev - connected device

data - ASCII data to write

Outputs

None

See also: flushoutput.

3.1.7 writeread

: data = writeread (dev, command)

write a ASCII command and read data from a instrument device.

Inputs

dev - connected device

command - ASCII command

Outputs

data - ASCII data read

See also: readline, writeline.


3.2 General

3.2.1 instrhelp

: instrhelp ()
: instrhelp (funcname)
: instrhelp (obj)

Display instrument help

Inputs

funcname - function to display help about.
obj - object to display help about.

If no input is provided, the function will display and overview of the package functionality.

Outputs

None

3.2.2 instrhwinfo

Function File: [list] = instrhwinfo ()
Function File: list = instrhwinfo (interface)

Query available hardware for instrument-control

When run without any input parameters, instrhwinfo will provide the toolbox information and a list of supported interfaces.

Inputs

interface is the instrument interface to query. When provided, instrhwinfo will provide information on the specified interface.

Currently only interface "serialport","i2c" and "spi" and is supported, which will provide a list of available serial ports or i2c ports.

Outputs

If an output variable is provided, the function will store the information to the variable, otherwise it will be displayed to the screen.

Example

 instrhwinfo
 scalar structure containing the fields:

    ToolboxVersion = 0.4.0
    ToolboxName = octave instrument control package
    SupportedInterfaces =
    {
      [1,1] = i2c
      [1,2] = parallel
      [1,3] = serialport
      [1,4] = tcp
      [1,5] = udp
      [1,6] = usbtmc
      [1,7] = vxi11
    }

3.2.3 resolvehost

Loadable Function: name = resolvehost (host)
Loadable Function: [name, address] = resolvehost (host)
Loadable Function: out = resolvehost (host, returntype)

Resolve a network host name or address to network name and address

Inputs

host - Host name or IP address string to resolve.
name - Resolved IP host name.
returntype - ’name’ to get host name, ’address’ to get IP address.

Outputs

name - Resolved IP host name.
address - Resolved IP host address.
out - host name if returntype is ’name’, ipaddress if returntype is ’address’

Example

%% get resolved ip name and address of www.gnu.org
[name, address] = resolvehost ('www.gnu.org');

%% get ip address of www.gnu.org
ipaddress = resolvehost ('www.gnu.org', 'address');

See also: tcp, udp.


3.3 GPIB

3.3.1 @octave_gpib/fclose

Function File: res = fclose (obj)

Closes connection to GPIB device obj

3.3.2 @octave_gpib/fopen

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

Opens connection to GPIB device obj This currently is a dummy function to improve compatibility to MATLAB

3.3.3 @octave_gpib/fprintf

Function File: fprintf (obj, cmd)
Function File: fprintf (obj, format, cmd)
Function File: fprintf (obj, cmd, mode)
Function File: fprintf (obj, format, cmd, mode)

Writes string cmd to GPIB instrument

obj is a GPIB object

cmd String format Format specifier mode sync

3.3.4 @octave_gpib/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 GPIB instrument

obj is a GPIB object

size Number of values to read. (Default: 100) precision precision of data

count values read errmsg read operation error message

3.3.5 @octave_gpib/fscanf

Function File: res = fscanf (obj)
Function File: res = fscanf (obj, format)
Function File: res = fscanf (obj, format, size)
Function File: [res,count] = fscanf (obj, ...)
Function File: [res,count,errmsg] = fscanf (obj, ...)

Reads data res from GPIB instrument

obj is a GPIB object

format Format specifier size number of values

count values read errmsg read operation error message

3.3.6 @octave_gpib/fwrite

Function File: fwrite (obj, data)
Function File: fwrite (obj, data, precision)
Function File: fwrite (obj, data, mode)
Function File: fwrite (obj, data, precision, mode)

Writes data to GPIB instrument

obj is a GPIB object

data data to write precision precision of data mode sync

3.3.7 clrdevice

Function File: clrdevice (obj)

Send clear command to Clear GPIB instrument.

obj is a GPIB object

3.3.8 gpib

Loadable Function: gpib = gpib ([gpibid], [timeout])

Open gpib interface.

gpibid - the interface number.
timeout - the interface timeout value. If omitted defaults to blocking call.

The gpib() shall return instance of octave_gpib class as the result gpib.

3.3.9 gpib_close

Loadable Function: gpib_close (gpib)

Close the interface and release a file descriptor.

gpib - instance of octave_gpib class.

3.3.10 gpib_read

Loadable Function: [data, count, eoi] = gpib_read (gpib, n)

Read from gpib interface.

gpib - instance of octave_gpib class.
n - number of bytes to attempt to read of type Integer.

The gpib_read() shall return number of bytes successfully read in count as Integer and the bytes themselves in data as uint8 array. eoi indicates read operation complete

3.3.11 gpib_timeout

Loadable Function: gpib_timeout (gpib, timeout)
Loadable Function: t = gpib_timeout (gpib)

Set new or get existing gpib interface timeout parameter. The timeout value is valid from 0 to 17.

gpib - instance of octave_gpib class.
timeout - Value of 0 means never timeout, 11 means one second and 17 means 1000 seconds (see GPIB documentation (ibtmo) for further details)

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

3.3.12 gpib_write

Loadable Function: n = gpib_write (gpib, data)

Write data to a gpib interface.

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

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

3.3.13 spoll

Function File: out = spoll (obj)
Function File: [out,statusByte] = spoll (obj)

Serial polls GPIB instruments.

obj is a GPIB object or a cell array of GPIB objects

out GPIB objects ready for service statusByte status Byte

3.3.14 trigger

Function File: trigger (obj)

Triggers GPIB instrument.

obj is a GPIB object


3.4 I2C

3.4.1 @octave_i2c/fclose

Function File: res = fclose (obj)

Closes I2C connection obj

3.4.2 @octave_i2c/fopen

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

Opens I2C connection obj

This currently is a dummy function to improve compatibility to MATLAB

3.4.3 @octave_i2c/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 I2C instrument

Inputs

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

Outputs

data data values.
count number of values read.
errmsg read operation error message.

3.4.4 @octave_i2c/fwrite

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

Writes data to I2C instrument

Inputs

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

Outputs

returns number of bytes written.

3.4.5 @octave_i2c/get

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

Get the properties of i2c object.

Inputs

i2c - instance of octave_i2c 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_i2c/set.

3.4.6 @octave_i2c/set

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

Set the properties of i2c object.

Inputs

obj - instance of octave_i2c 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

’name’

Set the name for the i2c socket.

’remoteaddress’

Set the remote address for the i2c socket.

Outputs

None

See also: @octave_i2c/get.

3.4.7 i2c

Loadable Function: i2c = i2c ([port_path], [address])

Open i2c interface.

Inputs

port_path - the interface device port/path of type String. If omitted defaults to ’/dev/i2c-0’.
address - the slave device address. If omitted must be set using i2c_addr() call.

Outputs

i2c - An instance of octave_i2c class.

Properties

The i2c object has the following properties:

name

Name of the object

remoteaddress

the slave device address

port

The interface driver port (readonly)

3.4.8 i2c_addr

Loadable Function: i2c_addr (i2c, address)
Loadable Function: addr = i2c_addr (i2c)

Set new or get existing i2c slave device address.

Inputs

i2c - instance of octave_i2c class.
address - i2c slave device address of type Integer. The address is passed in the 7 or 10 lower bits of the argument.

Outputs

addr - If address parameter is omitted, the i2c_addr() shall return current i2c slave device address.

3.4.9 i2c_close

Loadable Function: i2c_close (i2c)

Close the interface and release a file descriptor.

Inputs

i2c - instance of octave_i2c class.

Outputs

None

3.4.10 i2c_read

Loadable Function: [data, count] = i2c_read (i2c, n)

Read from i2c slave device.

Inputs

i2c - instance of octave_i2c class.
n - number of bytes to attempt to read of type Integer.

Outputs

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

3.4.11 i2c_write

Loadable Function: n = i2c_write (i2c, data)

Write data to a i2c slave device.

Inputs

i2c - instance of octave_i2c class.
data - data, of type uint8, to be written to the slave device.

Outputs

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


3.5 Modbus

3.5.1 @octave_modbus/get

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

Get the properties of modbus object.

Inputs

dev - instance of octave_modbus 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_modbus/set.

3.5.2 @octave_modbus/maskWrite

: data = maskWrite (dev, address, andmask, ormask)
: data = maskWrite (dev, address, andmask, ormask, serverid)

Read holding register at address from modbus device dev apply masking and write the change data.

writeregister value = (readregister value AND andMask) OR (orMask AND (NOT andMask))

Inputs

dev - connected modbus device

address - address to read from.

andmask - AND mask to apply to the register

ormask - OR mask to apply to the register

serverId - address to send to (0-247). Default of 1 is used if not specified.

Outputs

data - data read from the device

See also: modbus.

3.5.3 @octave_modbus/read

: data = read (dev, target, address)
: data = read (dev, target, address, count)
: data = read (dev, target, address, count, serverId, precision)

Read data from modbus device dev target target starting at address address.

Inputs

dev - connected modbus device

target - target type to read. One of ’coils’, ’inputs’, ’inputregs’ or ’holdingregs’

address - address to start reading from.

count - number of elements to read. If not provided, count is 1.

serverId - address to send to (0-247). Default of 1 is used if not specified.

precision - Optional precision for how to interpret the read data. Currently known precision values are uint16 (default), int16, uint32, int32, uint64, uint64, single, double.

Outputs

data - data read from the device

See also: modbus.

3.5.4 @octave_modbus/set

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

Set the properties of modbus object.

Inputs

obj - instance of octave_modbus 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

’Name’

Set the stored string name of the object.

’Timeout’

Set the timeout value.

’Numretries’

Set the numretries value.

’ByteOrder’

Set the byteorder value

’WordOrder’

Set the wordorder value

’UserData’

Set the userdata value

Outputs

None

See also: @octave_modbus/get.

3.5.5 @octave_modbus/write

: write (dev, target, address, values)
: read (dev, target, address, values, serverId, precision)

Write data data to modbus device dev target target starting at address address.

Inputs

dev - connected modbus device

target - target type to read. One of ’coils’ or ’holdingregs’

address - address to start reading from.

data - data to write.

serverId - address to send to (0-247). Default of 1 is used if not specified.

precision - Optional precision for how to interpret the write data. Currently known precision values are uint16 (default), int16, uint32, int32, uint64, uint64, single, double.

Outputs

None

See also: modbus.

3.5.6 @octave_modbus/writeRead

: data = writeRead (dev, writeAddress, values, readAddress, readcount)
: data = writeRead (dev, writeAddress, values, readAddress, readcount, serverId)
: data = writeRead (dev, writeAddress, values, writePrecision, readAddress, readCount, readPrecision)

Write data values to the modbus device dev holding registers starting at address writeAddress and then read readCount register values starting at address readAddress.

Inputs

dev - connected modbus device

writeAddress - address to start writing to.

values - data to write to the device.

readAddress - address to start reading from.

readCount - number of elements to read.

serverId - address to send to (0-247). Default of 1 is used if not specified.

precision - Optional precision for how to interpret the read data. Currently known precision values are uint16 (default), int16, uint32, int32, uint64, uint64, single, double.

Outputs

data - data read from the device

See also: modbus.

3.5.7 modbus

Loadable Function: dev = modbus ('tcpip', deviceaddress)
Loadable Function: dev = modbus ('tcpip', deviceaddress, remoteport)
Loadable Function: dev = modbus ('tcpip', deviceaddress, name, value)
Loadable Function: dev = modbus ('serialrtu', serialport)
Loadable Function: dev = modbus ('serialrtu', serialport, name, value)

Open modbus interface using a specified transport of ’tcpip’ or ’serialrtu’.

Inputs

deviceaddress - the device ip address of type String.
remoteport - the device remote port number. If not specified, a default of 502 will be used.
name, value - Optional name value pairs for setting properties of the object.
serialport - the name of the serial port to connect to. It must be specified when transport is ’serialrtu’.

Common Input Name, Value pairs

Timeout

timeout value used for waiting for data

NumRetries

number of retries after a timeout

UserData

Additional data to attach to the object

Serial RTU Input Name, Value pairs

BaudRate

Baudrate for the serial port

DataBits

number of databits for serial port

Parity

Parity for serial port (’odd’, ’even’ or ’none’)

StopBits

number of stopbits for serial port

Outputs

The modbus() shall return instance of octave_modbus class as the result modbus.

Properties

The modbus object has the following public properties:

Name

name assigned to the modbus object

Type

instrument type ’modbus’ (readonly)

Port

Remote port number or serial port name (readonly)

DeviceAddress

Device address if transport was ’tcpip’ (readonly)

Status

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

Timeout

timeout value used for waiting for data

NumRetries

number of retries after a timeout

UserData

Additional data to attach to the object


3.6 Parallel

3.6.1 @octave_parallel/fclose

Function File: res = fclose (obj)

Closes parallel connection obj

3.6.2 @octave_parallel/fopen

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

Opens parallel interface obj

This currently is a dummy function to improve compatibility to MATLAB

3.6.3 @octave_parallel/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 parallel instrument

Inputs

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

Outputs

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

3.6.4 @octave_parallel/fwrite

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

Writes data to parallel instrument

Inputs

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

Outputs

returns number of bytes written.

3.6.5 parallel

Loadable Function: parallel = parallel ([path], [direction])

Open Parallel interface.

Inputs

path - the interface path of type String. If omitted defaults to ’/dev/parport0’.
direction - the direction of interface drivers of type Integer, see: PP_DATADIR for more info. If omitted defaults to 1 (Input).

Outputs

The parallel() shall return instance of octave_parallel class as the result parallel.

3.6.6 pp_close

Loadable Function: pp_close (parallel)

Close the interface and release a file descriptor.

Inputs

parallel - instance of octave_serial class.

Outputs

None

3.6.7 pp_ctrl

Loadable Function: pp_ctrl (parallel, ctrl)
Loadable Function: c = pp_ctrl (parallel)

Sets or Read the Control lines.

Inputs

parallel - instance of octave_parallel class.
ctrl - control parameter to be set of type Byte.

Outputs

If ctrl parameter is omitted, the pp_ctrl() shall return current Control lines state as the result c.

3.6.8 pp_data

Loadable Function: pp_data (parallel, data)
Loadable Function: d = pp_data (parallel)

Sets or Read the Data lines.

Inputs

parallel - instance of octave_parallel class.
data - data parameter to be set of type Byte.

Outputs

If data parameter is omitted, the pp_data() shall return current Data lines state as the result d.

3.6.9 pp_datadir

Loadable Function: pp_datadir (parallel, direction)
Loadable Function: dir = pp_datadir (parallel)

Controls the Data line drivers.

Normally the computer’s parallel port will drive the data lines, but for byte-wide transfers from the peripheral to the host it is useful to turn off those drivers and let the peripheral drive the signals. (If the drivers on the computer’s parallel port are left on when this happens, the port might be damaged.)

Inputs

parallel - instance of octave_parallel class.
direction - direction parameter of type Integer. Supported values: 0 - the drivers are turned on (Output/Forward direction); 1 - the drivers are turned off (Input/Reverse direction).

Outputs

If direction parameter is omitted, the pp_datadir() shall return current Data direction as the result dir.

3.6.10 pp_stat

Loadable Function: stat = pp_stat (parallel)

Reads the Status lines.

Inputs

parallel - instance of octave_parallel class.

Outputs

The pp_stat() shall return current Status lines state as the result stat.


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.


3.8 Serial Port

3.8.1 @octave_serialport/configureTerminator

Function File: configureTerminator (serial, term)
Function File: configureTerminator (serial, readterm, writeterm)

Set terminator for ASCII string manipulation

Inputs

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.

Outputs

None

See also: serialport.

3.8.2 @octave_serialport/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the serial port buffers

Inputs

dev - connected serialport device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: serialport.

3.8.3 @octave_serialport/fprintf

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

Writes formatted string template using optional parameters to serialport instrument

Inputs

obj is a serialport object.
template Format template string

Outputs

numbytes - number of bytes written to the serial device.

3.8.4 @octave_serialport/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 port instrument

Inputs

obj is a serialport object.
size Number of values to read.
precision precision of data.

Outputs

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

3.8.5 @octave_serialport/fwrite

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

Writes data to serial port instrument

Inputs

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

Outputs

returns number of bytes written.

3.8.6 @octave_serialport/get

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

Get the properties of serialport object.

Inputs

serial - instance of octave_serialport 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.8.7 @octave_serialport/getpinstatus

Function File: status getpinstatus (serial)

Get status of serial pins

Inputs

serial - serial object

Outputs

status - a structure with the logic names of ClearToSend, DataSetReady, CarrierDetect, and RingIndicator

See also: serialport.

3.8.8 @octave_serialport/read

: data = read (dev, count)
: data = read (dev, count, precision)

Read a specified number of values from a serialport using optional precision for valuesize.

Inputs

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

Outputs

data - data read from the device

See also: serialport.

3.8.9 @octave_serialport/serialbreak

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

Send a break to the serial port

Inputs

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

Outputs

None

See also: serial.

3.8.10 @octave_serialport/set

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

Set the properties of serialport object.

Inputs

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.

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_serialport/-get.

3.8.11 @octave_serialport/setDTR

: setDTR (dev, true_false)

Set the state of the DTR line

Inputs

dev - connected serial device.
true_false - state to set the line.

Outputs

None

See also: serialport, getpinstatus, setRTS.

3.8.12 @octave_serialport/setRTS

: setRTS (dev, true_false)

Set the state of the RTS line

Inputs

dev - connected serial device.
true_false - state to set the line.

Outputs

None

See also: serialport, getpinstatus.

3.8.13 @octave_serialport/write

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

Writes data to serialport instrument

Inputs

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

Outputs

returns number of bytes written.

3.8.14 serialport

Loadable Function: serial = serialport ([path], [baudrate])
Loadable Function: serial = serialport ([path], [propname, propvalue])

Open serial port interface.

Inputs

path - the interface path of type String.
baudrate - the baudrate of interface.
propname,propvalue - property name/value pairs.

Known input properties:

BaudRate

Numeric baudrate value

Timeout

Numeric timeout value in seconds or -1 to wait forever

StopBits

number of stopbits to use

Parity

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

DataBits

Number of bits to a byte (5 to 8)

FlowControl

Number of bits to a byte ’none’, ’hardware’, ’software’

Tag

User settable string to identify the port.

Outputs

The serialport() shall return an instance of octave_serialport 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

NumBytesAvailable

number of bytes currently available to read (readonly)

NumBytesWritten

number of bytes written (readonly)

StopBits

number of stopbits to use

Parity

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

DataBits

Number of bits to a byte (5 to 8)

BaudRate

Baudrate setting

FlowControl

Number of bits to a byte ’none’, ’hardware’, ’software’

PinStatus

current state of pins (readonly)

UserData

user defined data

Tag

user defined tag name

3.8.15 serialportlist

Function File: list = serialportlist ()
Function File: list = serialportlist ("all")
Function File: list = serialportlist ("available")

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

Inputs

’all’ - show all serial ports (same as providing no arguments) ’available’ - show only serial ports that are available for use

Outputs

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

See also: instrhwinfo("serialport").


3.9 SPI

3.9.1 @octave_spi/fclose

Function File: res = fclose (obj)

Closes SPI connection obj

3.9.2 @octave_spi/fopen

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

Opens SPI connection obj

This currently is a dummy function to improve compatibility to MATLAB

3.9.3 @octave_spi/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 a SPI instrument

Inputs

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

Outputs

data data values.
count number of values read.
errmsg read operation error message.

3.9.4 @octave_spi/fwrite

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

Writes data to SPI instrument

Inputs

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

Outputs

returns number of bytes written.

3.9.5 @octave_spi/get

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

Get the properties of spi object.

Inputs

spi - instance of octave_spi class.

property - name of property.

Properties

’name’

Name for the spi socket.

’bitrate’

The bitrate for the spi object.

’clockpolarity’

The clock polarity for the spi object of ’idlehigh’ or ’idlelow’.

’clockphase’

The clock phase for the spi object of ’firstedge’ or ’secondedge’.

’port’

The device port name.

’status’

The device status of ’open’ or ’closed’

Outputs

When property was specified, return the value of that property.
otherwise return the values of all properties as a structure.

See also: @octave_spi/set.

3.9.6 @octave_spi/read

Function File: data = read (obj)
Function File: data = read (obj, size)

Reads data from SPI instrument

Inputs

obj is a SPI object.
size Number of values to read. (Default: 10).

Outputs

data data values.

3.9.7 @octave_spi/set

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

Set the properties of spi object.

Inputs

obj - instance of octave_spi 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

’name’

Set the name for the spi socket.

’bitrate’

Set the bitrate for the spi object.

’clockpolarity’

Set the clock polarity for the spi object of ’idlehigh’ or ’idlelow’.

’clockphase’

Set the clock phase for the spi object of ’firstedge’ or ’secondedge’.

Outputs

None

See also: @octave_spi/get.

3.9.8 @octave_spi/write

Function File: numbytes = fwrite (obj, data)

Writes data to SPI instrument

Inputs

obj is a SPI object.
data data to write.

Outputs

returns number of bytes written.

3.9.9 @octave_spi/writeAndRead

Function File: data = writeAndRead (obj, wrdata)

Writes and reads data from SPI instrument

Inputs

obj is a SPI object.
wrdata Data to write.

Outputs

data data values read.

3.9.10 spi

Loadable Function: spi = spi ([port_path])
Loadable Function: spi = spi ([port_path], [propname, propvalue])

Open a spi interface.

Inputs

port_path - the interface device port/path of type String. If omitted defaults to ’/dev/spi-0’.
propname,propvalue - property name/value pairs.

Known input properties:

name

Name of the object

bitrate

Numeric bitrate value

clockpolarity

Clock polarity: idlehigh or idlelow.

clockphase

Clock phase value: firstedge or secondedge

Outputs

spi - An instance of octave_spi class.

Properties

The spi object has the following properties:

name

Name of the object

status

Open or closed status of object (readonly).

bitrate

Numeric bitrate value

clockpolarity

Clock polarity: idlehigh or idlelow.

clockphase

Clock phase value: firstedge or secondedge

port

The interface driver port (readonly)

3.9.11 spi_close

Loadable Function: spi_close (spi)

Close the interface and release a file descriptor.

Inputs

spi - instance of octave_spi class.

Outputs

None

3.9.12 spi_read

Loadable Function: [data, count] = spi_read (spi, n)

Read from spi slave device.

Inputs

spi - instance of octave_spi class.
n - number of bytes to attempt to read of type Integer.

Outputs

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

3.9.13 spi_write

Loadable Function: n = spi_write (spi, data)

Write data to a spi slave device.

Inputs

spi - instance of octave_spi class.
data - data, of type uint8, to be written to the slave device.

Outputs

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

3.9.14 spi_writeAndRead

Loadable Function: rddata = spi_writeAndRead (spi, wrdata)

Write data to a spi slave device and then read same number of values.

Inputs

spi - instance of octave_spi class.
wrdata - data, of type uint8, to be written to the slave device.

Outputs

Upon successful completion, spi_writeAndRead() shall return the bytes read.


3.10 TCP (Deprecated)

3.10.1 @octave_tcp/fclose

Function File: res = fclose (obj)

Closes TCP connection obj

3.10.2 @octave_tcp/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the tcp socket buffers

Inputs

dev - connected tcp device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: serialport.

3.10.3 @octave_tcp/flushinput

Loadable Function: flushinput (tcp)

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

Inputs

tcp - instance of octave_tcp class.

Outputs

None.

See also: flushoutput.

3.10.4 @octave_tcp/flushoutput

Loadable Function: flushoutput (tcp)

Flush the output buffer.

Inputs

tcp - instance of octave_tcp class.

Outputs

None.

See also: flushinput.

3.10.5 @octave_tcp/fopen

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

Opens TCP connection obj

This currently is a dummy function to improve compatibility to MATLAB

3.10.6 @octave_tcp/fprintf

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

Writes formatted string template using optional parameters to TCP instrument

Inputs

obj is a TCP object.
template Format template string

Outputs

Number of characters written

3.10.7 @octave_tcp/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 TCP instrument

Inputs

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

Outputs

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

3.10.8 @octave_tcp/fwrite

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

Writes data to TCP instrument

Inputs

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

Outputs

returns number of bytes written.

3.10.9 @octave_tcp/get

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

Get the properties of tcp object.

Inputs

tcp - instance of octave_tcp 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_tcp/set.

3.10.10 @octave_tcp/read

Function File: data = read (obj)
Function File: data = read (obj, size)
Function File: data = read (obj, size, datatype)

Reads data from TCP instrument

Inputs

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

Outputs

data data read.

3.10.11 @octave_tcp/set

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

Set the properties of tcp object.

Inputs

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

’name’

Set the name for the tcp socket.

’remotehost’

Set the remote host name for the tcp socket.

’remoteport’

Set the remote port for the tcp socket.

’timeout’

Set the timeout value in seconds. Value of -1 means a blocking call.

Outputs

None

See also: @octave_tcp/get.

3.10.12 @octave_tcp/write

Function File: numbytes = write (obj, data)
Function File: numbytes = write (obj, data, datatype)

Writes data to TCP instrument

Inputs

obj is a TCP object.
data data to write.
datatype datatype of data. If not specified, it defaults to "uint8".

Outputs

returns number of bytes written.

3.10.13 tcp

Loadable Function: tcp = tcp ()
Loadable Function: tcp = tcp (ipaddress)
Loadable Function: tcp = tcp (ipaddress, port)
Loadable Function: tcp = tcp (ipaddress, port, timeout)
Loadable Function: tcp = tcp (ipaddress, [propertyname, propertyvalue])
Loadable Function: tcp = tcp (ipaddress, port, [propertyname, propertyvalue])

Open tcp interface.

Inputs

ipaddress - the ip address of type String. If omitted defaults to ’127.0.0.1’.
port - the port number to connect. If omitted defaults to 23.
timeout - the interface timeout value. If omitted defaults to blocking call.
propname,propvalue - property name/value pairs.

Known input properties:

name

name value

timeout

Numeric timeout value or -1 to wait forever

Outputs

The tcp() shall return instance of octave_tcp class as the result tcp.

Properties

The tcp object has the following public properties:

name

name assigned to the tcp object

type

instrument type ’tcp’ (readonly)

localport

local port number (readonly)

remoteport

remote port number

remotehost

remote host

status

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

timeout

timeout value in seconds used for waiting for data

bytesavailable

number of bytes currently available to read (readonly)

3.10.14 tcp_close

Loadable Function: tcp_close (tcp)

Close the interface and release a file descriptor.

Inputs

tcp - instance of octave_tcp class.

Outputs

None

3.10.15 tcp_read

Loadable Function: [data, count] = tcp_read (tcp, n, timeout)

Read from tcp interface.

Inputs

tcp - instance of octave_tcp class.
n - number of bytes to attempt to read of type Integer
timeout - timeout in ms if different from default of type Integer

Outputs

count - number of bytes successfully read as an Integer
data - data bytes themselves as uint8 array.

3.10.16 tcp_timeout

Loadable Function: tcp_timeout (tcp, timeout)
Loadable Function: t = tcp_timeout (tcp)

Set new or get existing tcp interface timeout parameter used for tcp_read() requests. The timeout value is specified in milliseconds.

Inputs

tcp - instance of octave_tcp class.
timeout - tcp_read() timeout value in milliseconds. Value of -1 means a blocking call.

Outputs

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

3.10.17 tcp_write

Loadable Function: n = tcp_write (tcp, data)

Write data to a tcp interface.

Inputs

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

Outputs

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

3.10.18 tcpip

Function File: tcp = tcpip (host, [port], [PropertyName, PropertyValue...])

Matlab compatible wrapper to the tcp interface.

NOTE: tcpip has been deprecated. Use tcpclient instead

Inputs

host - the host name or ip.
port - the port number to connect. If omitted defaults to 80.
PropertyName, PropertyValue - Optional property name, value pairs to set on the tcp object.

Properties

Currently the only known properties are "timeout" and "name".

Outputs

tcpip will return an instance of octave_tcp class as the result.


3.11 TCP Client

3.11.1 @octave_tcpclient/configureTerminator

Function File: configureTerminator (tcp, term)
Function File: configureTerminator (tcp, readterm, writeterm)

Set terminator on a tcpclient object for ASCII string manipulation

Inputs

tcp - tcpclient 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.

Outputs

None

See also: tcpport.

3.11.2 @octave_tcpclient/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the tcpclient socket buffers

Inputs

dev - connected tcpclient device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: serialport.

3.11.3 @octave_tcpclient/get

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

Get the properties of tcpclient object.

Inputs

tcpclient - instance of octave_tcpclient 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_tcpclient/set.

3.11.4 @octave_tcpclient/read

Function File: data = read (obj)
Function File: data = read (obj, size)
Function File: data = read (obj, size, datatype)

Reads data from TCP instrument

Inputs

obj is a TCP object.
size Number of values to read. (Default: NumBytesAvailable).
datatype datatype of data.

Outputs

data data read.

3.11.5 @octave_tcpclient/set

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

Set the properties of tcpclient object.

Inputs

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

’Name’

Set the name for the tcpclient socket.

’UserData’

Set user data for the tcpclient socket.

’Timeout’

Set the timeout value in seconds. Value of -1 means a blocking call.

’Tag’

Set user tag to identify the port

Outputs

None

See also: @octave_tcpclient/get.

3.11.6 @octave_tcpclient/write

Function File: numbytes = write (obj, data)
Function File: numbytes = write (obj, data, datatype)

Writes data to TCP instrument

Inputs

obj is a TCPclient object.
data data to write.
datatype datatype of data. If not specified, it defaults to "uint8".

Outputs

returns number of bytes written.

3.11.7 tcpclient

Loadable Function: tcpclient = tcpclient (ipaddress, port)
Loadable Function: tcpclient = tcpclient (ipaddress, port, [propertyname, propertyvalue])

Open tcpclient interface.

Inputs

ipaddress - the ip address of type String.
port - the port number to connect.
propname,propvalue - property name/value pairs.

Known input properties:

Name

name value

Tag

tag value

Timeout

Numeric timeout value or -1 to wait forever

EnableTransferDelay

Boolean to enable or disable the nagle algorithm for delay transfer.

UserData

User data value.

Outputs

The tcpclient() shall return instance of octave_tcpclient class as the result tcpclient.

Properties

The tcpclient object has the following public properties:

Name

name assigned to the tcpclient object

Tag

user tag assigned to the tcpclient object

Type

instrument type ’tcpclient’ (readonly)

Port

remote port number (Readonly)

Address

remote host address (Readonly)

Status

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

Timeout

timeout value in seconds used for waiting for data

NumBytesAvailable

number of bytes currently available to read (readonly)

NumBytesWritten

number of bytes currently available to read (readonly)

ByteOrder

Byte order for data (currently not used)

Terminator

Terminator value used for string data (currently not used)

UserData

User data

EnableTransferDelay

Bool for whether transfer delay is enabled. (Read only)


3.12 TCP Server

3.12.1 @octave_tcpserver/configureTerminator

Function File: configureTerminator (tcp, term)
Function File: configureTerminator (tcp, readterm, writeterm)

Set terminator on a tcpserver object for ASCII string manipulation

Inputs

tcp - tcpserver 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.

Outputs

None

See also: tcpport.

3.12.2 @octave_tcpserver/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the tcpserver socket buffers

Inputs

dev - connected tcpserver device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: serialport.

3.12.3 @octave_tcpserver/get

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

Get the properties of tcpserver object.

Inputs

tcpserver - instance of octave_tcpserver 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_tcpserver/set.

3.12.4 @octave_tcpserver/read

Function File: data = read (obj)
Function File: data = read (obj, size)
Function File: data = read (obj, size, datatype)

Reads data from TCP instrument

Inputs

obj is a TCP Server object.
size Number of values to read. (Default: NumBytesAvailable).
datatype datatype of data.

Outputs

data data read.

3.12.5 @octave_tcpserver/set

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

Set the properties of tcpserver object.

Inputs

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

’Name’

Set the name for the tcpserver socket.

’UserData’

Set user data for the tcpserver socket.

’Timeout’

Set the timeout value in seconds. Value of -1 means a blocking call.

Outputs

None

See also: @octave_tcpserver/get.

3.12.6 @octave_tcpserver/write

Function File: numbytes = write (obj, data)
Function File: numbytes = write (obj, data, datatype)

Writes data to TCP instrument

Inputs

obj is a TCPServer object.
data data to write.
datatype datatype of data. If not specified, it defaults to "uint8".

Outputs

returns number of bytes written.

3.12.7 tcpserver

Loadable Function: tcpserver = tcpserver (ipaddress, port)
Loadable Function: tcpserver = tcpserver (port)
Loadable Function: tcpserver = tcpserver (…, [propertyname, propertyvalue])

Open tcpserver interface.

Inputs

ipaddress - the ip address of type String.
port - the port number to bind.
propname,propvalue - property name/value pairs.

Known input properties:

Name

name value

Timeout

Numeric timeout value or -1 to wait forever

UserData

User data value.

Outputs

The tcpserver() shall return instance of octave_tcpserver class as the result tcpserver.

Properties

The tcpserver object has the following public properties:

Connected

boolean flag for when connected to a client (Readonly)

ClientPort

connected client port number (Readonly)

ClientAddress

connected client address (Readonly)

Name

name assigned to the tcpserver object

Type

instrument type ’tcpserver’ (readonly)

ServerPort

server port number (Readonly)

ServerAddress

server address (Readonly)

Status

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

Timeout

timeout value in seconds used for waiting for data

NumBytesAvailable

number of bytes currently available to read (readonly)

NumBytesWritten

number of bytes currently available to read (readonly)

ByteOrder

Byte order for data (currently not used)

Terminator

Terminator value used for string data (currently not used)

UserData

User data


3.13 UDP (Deprecated)

3.13.1 @octave_udp/fclose

Function File: res = fclose (obj)

Closes UDP connection obj

3.13.2 @octave_udp/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the udp socket buffers

Inputs

dev - open udp device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: udp.

3.13.3 @octave_udp/flushinput

Loadable Function: flushinput (udp)

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

Inputs

udp - instance of octave_udp class.

Outputs

None

See also: flushoutput.

3.13.4 @octave_udp/flushoutput

Loadable Function: flushoutput (udp)

Flush the output buffer.

Inputs

udp - instance of octave_udp class.

Outputs

None

See also: flushinput.

3.13.5 @octave_udp/fopen

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

Opens UDP connection obj This currently is a dummy function to improve compatibility to MATLAB

3.13.6 @octave_udp/fprintf

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

Writes formatted string template using optional parameters to UDP instrument

Inputs

obj is a UDP object.
template Format template string.

Outputs

numbytes is the number of bytes written to the device

3.13.7 @octave_udp/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 UDP instrument

Inputs

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

Outputs

data data values.
count number of values read.
errmsg read operation error message.

3.13.8 @octave_udp/fwrite

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

Writes data to UDP instrument

Inputs

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

Outputs

returns number of bytes written.

3.13.9 @octave_udp/get

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

Get the properties of udp object.

Inputs

udp - instance of octave_udp 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_udp/set.

3.13.10 @octave_udp/read

Function File: data = read (obj)
Function File: data = read (obj, size)
Function File: data = read (obj, size, datatype)

Reads data from UDP instrument

Inputs

obj is a UDP object.
size Number of values to read. (Default: BytesAvailable).
datatype datatype of data.

Outputs

data data read.

3.13.11 @octave_udp/set

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

Set the properties of udp object.

Inputs

obj - instance of octave_udp 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

’name’

Set the name for the udp socket.

’remotehost’

Set the remote host name for the udp socket.

’remoteport’

Set the remote port for the udp socket.

’timeout’

Set the timeout value in seconds. Value of -1 means a blocking call.

Outputs

None

See also: @octave_udp/get.

3.13.12 @octave_udp/write

Function File: numbytes = write (obj, data)
Function File: numbytes = write (obj, data, destinationAddress, destinationPort))
Function File: numbytes = write (obj, data, datatype)
Function File: numbytes = write (obj, data, datatype, destinationAddress, destinationPort)

Writes data to UDP instrument

Inputs

obj is a UDP object.
data data to write.
datatype datatype of data. If not specified defaults to uint8.
destinationAddress ipaddress to send to. If not specified, use the remote address.
destinationPort port to send to. If not specified, use the remote port.

Outputs

returns number of bytes written.

3.13.13 udp

Loadable Function: udp = udp ()
Loadable Function: udp = udp (remoteipaddress, remoteport)
Loadable Function: udp = udp (remoteipaddress, remoteport, [propertyname, propertyvalue ...])

Open udp interface.

Inputs

remoteipaddress - the ip address of type String. If omitted defaults to ’127.0.0.1’.
remoteport - the port number to connect. If omitted defaults to 23.
localport - the local port number to bind. If omitted defaults to 0
propertyname, propertyvalue - property name/value pair

Outputs

The udp() shall return instance of octave_udp class as the result udp.

Properties

The udp object has the following public properties:

name

name assigned to the udp object

type

instrument type ’udp’ (readonly)

localport

local port number (readonly)

localhost

local host address (readonly)

remoteport

remote port number

remotehost

remote host

status

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

timeout

timeout value in seconds used for waiting for data

bytesavailable

number of bytes currently available to read (readonly)

3.13.14 udp_close

Loadable Function: udp_close (udp)

Close the interface and release a file descriptor.

Inputs

udp - instance of octave_udp class.

Inputs

None

3.13.15 udp_demo

Function File: result = udp_demo ()

Run test SNTP demonstration for udp class

See also: udp.

3.13.16 udp_read

Loadable Function: [data, count] = udp_read (udp, n, timeout)

Read from udp interface.

Inputs

udp - instance of octave_udp class.
n - number of bytes to attempt to read of type Integer
timeout - timeout in ms if different from default of type Integer

Outputs

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

3.13.17 udp_timeout

Loadable Function: udp_timeout (udp, timeout)
Loadable Function: t = udp_timeout (udp)

Set new or get existing udp interface timeout parameter used for udp_read() requests. The timeout value is specified in milliseconds.

Inputs

udp - instance of octave_udp class.
timeout - udp_read() timeout value in milliseconds. Value of -1 means a blocking call.

Outputs

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

3.13.18 udp_write

Loadable Function: n = udp_write (udp, data)

Write data to a udp interface.

Inputs

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

Outputs

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


3.14 UDP Port

3.14.1 @octave_udpport/configureMulticast

: data = configureMulticast((dev, address)
: data = configureMulticast((dev, "off")

Configure udpport device to receive multicast data

Inputs

dev - open udpport device

If address is ’off’ disable udp multicast. Otherwise it is the multicast address to use.

Outputs

None

See also: udpport.

3.14.2 @octave_udpport/configureTerminator

Function File: configureTerminator (udp, term)
Function File: configureTerminator (udp, readterm, writeterm)

Set terminator for ASCII string manipulation

Inputs

udp - udpport 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.

Outputs

None

See also: udpport.

3.14.3 @octave_udpport/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the udpport socket buffers

Inputs

dev - open udpport device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: udpport.

3.14.4 @octave_udpport/fprintf

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

Writes formatted string template using optional parameters to UDP instrument

Inputs

obj is a UDPPort object.
template Format template string.

Outputs

numbytes is the number of bytes written to the device

3.14.5 @octave_udpport/fread

Function File: data = fread (obj)
Function File: data = fread (obj, size)
Function File: data = fread (obj, size, precision)
Function File: <