struct =
get (dev)
¶field =
get (dev, property)
¶Get the properties of modbus object.
dev - instance of octave_modbus 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_modbus/set.
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))
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.
data - data read from the device
See also: modbus.
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.
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.
data - data read from the device
See also: modbus.
set
(obj, property,value)
¶set
(obj, property,value,…)
¶Set the properties of modbus object.
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.
Set the stored string name of the object.
Set the timeout value.
Set the numretries value.
Set the byteorder value
Set the wordorder value
Set the userdata value
None
See also: @octave_modbus/get.
(dev, target, address, values)
¶(dev, target, address, values, serverId, precision)
¶Write data data to modbus device dev target target starting at address address.
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.
None
See also: modbus.
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.
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.
data - data read from the device
See also: modbus.
dev =
modbus ('tcpip', deviceaddress)
¶dev =
modbus ('tcpip', deviceaddress, remoteport)
¶dev =
modbus ('tcpip', deviceaddress, name, value)
¶dev =
modbus ('serialrtu', serialport)
¶dev =
modbus ('serialrtu', serialport, name, value)
¶Open modbus interface using a specified transport of ’tcpip’ or ’serialrtu’.
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’.
timeout value used for waiting for data
number of retries after a timeout
Additional data to attach to the object
Baudrate for the serial port
number of databits for serial port
Parity for serial port (’odd’, ’even’ or ’none’)
number of stopbits for serial port
The modbus() shall return instance of octave_modbus class as the result modbus.
The modbus object has the following public properties:
name assigned to the modbus object
instrument type ’modbus’ (readonly)
Remote port number or serial port name (readonly)
Device address if transport was ’tcpip’ (readonly)
status of the object ’open’ or ’closed’ (readonly)
timeout value used for waiting for data
number of retries after a timeout
Additional data to attach to the object