ModbusRtuSlave
Description
The ModbusRtuSlave object implements a Modbus RTU slave which communicates with a Modbus RTU master via a serial port.
This object was introduced in InCore 2.0.
- › 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 master.
- › 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 master.
- › Type:
- › Default:
- › Signal:
dataBitsChanged()
- › Attributes:
Writable
parity
This property holds the parity mode of the serial port used for communicating with the Modbus RTU master.
- › Type:
- › Default:
- › Signal:
parityChanged()
- › Attributes:
Writable
portName
This property holds the name of the serial port used for communicating with the Modbus RTU master.
- › 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 master.
- › Type:
- › Default:
- › Signal:
stopBitsChanged()
- › Attributes:
Writable
Example
import InCore.Foundation 2.5
import InCore.Modbus 2.5
import InCore.IO 2.5
Application {
name: "Modbus RTU slave example"
System {
id: system
Polling on cpuLoad { }
Polling on deviceHumidity { }
Polling on deviceTemperature { }
}
LED {
index: LED.StatusBlue
value: ledReg.data
}
ModbusRtuSlave {
id: slave
address: 1
portName: "ttyO1"
baudRate: SerialPort.Baud250000
// expose CPU load as float (address 0+1)
ModbusRegister {
type: ModbusRegister.Input
address: 0
dataType: ModbusRegister.Float
count: 2
data: system.cpuLoad
}
// expose device temperature and humidity at address 2+3
ModbusRegister {
type: ModbusRegister.Input
address: 2
count: 2
data: [ system.deviceTemperature, system.deviceHumidity ]
}
// control blue status LED through coil 0
ModbusRegister {
id: ledReg
type: ModbusRegister.Coil
address: 0
}
}
}