ModbusRtuMaster
Description
The ModbusRtuMaster object implements a Modbus RTU master which communicates with Modbus slaves via a serial port.
- › Inherits:
Overview
Properties
Methods
Signals
Enumerations
Properties
baudRate
This property holds the data baud rate of the serial port used for communicating with the Modbus RTU slave.
- › Type:
- › Default:
- › Signal:
baudRateChanged()
- › Attributes:
Writable
busInterface
This property holds the bus interface to use for communication. See the BusInterface enumeration for details.
This property was introduced in InCore 2.8.
- › Type:
BusInterface
- › Default:
- › Signal:
busInterfaceChanged()
- › Attributes:
Writable
dataBits
This property holds the number of data bits of the serial port used for communicating with the Modbus RTU slave.
- › Type:
- › Default:
- › Signal:
dataBitsChanged()
- › Attributes:
Writable
interFrameDelay
This property holds the amount of microseconds for the silent interval between two consecutive Modbus messages. By default, a pre-calculated value according to the Modbus specification is used. An active or running connection is not affected by such delay changes. If this property is set to -1 or to a number less than the pre-calculated delay then the pre-calculated value is used as frame delay.
- › Type:
SignedInteger
- › Signal:
interFrameDelayChanged()
- › Attributes:
Writable
parity
This property holds the parity mode of the serial port used for communicating with the Modbus RTU slave.
- › Type:
- › Default:
- › Signal:
parityChanged()
- › Attributes:
Writable
portName
This property holds the name of the serial port used for communicating with the Modbus RTU slave. The value is ignored if busInterface is not set to BusInterface.SerialPort.
- › Type:
String
- › Signal:
portNameChanged()
- › Attributes:
Writable
queueSizeLimit
This property holds the a limit for the internal requests queue. If its size exceeds this value further requests are dropped until the queue size is below the limit again.
This property was introduced in InCore 2.8.
- › Type:
SignedInteger
- › Default:
100- › Signal:
queueSizeLimitChanged()
- › Attributes:
Writable
stopBits
This property holds the number of stop bits of the serial port used for communicating with the Modbus RTU slave.
- › Type:
- › Default:
- › Signal:
stopBitsChanged()
- › Attributes:
Writable
turnaroundDelay
This property holds the amount of milliseconds for the silent interval between a Modbus broadcast and a consecutive Modbus messages. Typically the turnaround delay is in the range of 100 to 200 milliseconds.
This property was introduced in InCore 2.5.
- › Type:
SignedInteger
- › Signal:
turnaroundDelayChanged()
- › Attributes:
Writable
Example
import InCore.Foundation 2.5
import InCore.Modbus 2.5
Application {
name: "Modbus RTU master example"
ModbusRtuMaster {
// set serial port parameters
portName: "ttyO1"
baudRate: SerialPort.Baud500000
dataBits: SerialPort.Data8
parity: SerialPort.NoParity
stopBits: SerialPort.OneStop
ModbusSlave {
// talk to slave with ID 5
address: 5
// read pressure from input register 7
ModbusRegister {
id: pressure
type: ModbusRegister.Input
address: 7
onDataChanged: console.log("Pressure", data)
}
// read registers every 100 ms
Polling on registers { interval: 100 }
}
// print error message if something goes wrong
onErrorOccurred: console.log(errorString)
}
}