ModbusRtuMaster

Description

The ModbusRtuMaster object implements a Modbus RTU master which communicates with Modbus slaves via a serial port.

› Inherits:ModbusClient
› Inherited by:ModbusBackplaneMaster

Properties

baudRate

This property holds the data baud rate of the serial port used for communicating with the Modbus RTU slave.

› Type:SerialPort.BaudRate
› Default:SerialPort.Baud115200
› Signal:baudRateChanged()
› Attributes:Writable

dataBits

This property holds the number of data bits of the serial port used for communicating with the Modbus RTU slave.

› Type:SerialPort.DataBits
› Default:SerialPort.Data8
› 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:SerialPort.Parity
› Default:SerialPort.NoParity
› Signal:parityChanged()
› Attributes:Writable

portName

This property holds the name of the serial port used for communicating with the Modbus RTU slave.

› Type:String
› Signal:portNameChanged()
› Attributes:Writable

stopBits

This property holds the number of stop bits of the serial port used for communicating with the Modbus RTU slave.

› Type:SerialPort.StopBits
› Default:SerialPort.OneStop
› 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)
    }
}