.. _object_ModbusRtuMaster: :index:`ModbusRtuMaster` ------------------------ Description *********** The ModbusRtuMaster object implements a Modbus RTU master which communicates with Modbus slaves via a serial port. :**› Inherits**: :ref:`ModbusClient ` Overview ******** Properties ++++++++++ .. hlist:: :columns: 3 * :ref:`baudRate ` * :ref:`busInterface ` * :ref:`dataBits ` * :ref:`interFrameDelay ` * :ref:`parity ` * :ref:`portName ` * :ref:`queueSizeLimit ` * :ref:`stopBits ` * :ref:`turnaroundDelay ` * :ref:`ModbusClient.numberOfRetries ` * :ref:`ModbusClient.slaves ` * :ref:`ModbusClient.timeout ` * :ref:`ModbusDevice.activityLed ` * :ref:`ModbusDevice.autoConnect ` * :ref:`ModbusDevice.error ` * :ref:`ModbusDevice.errorString ` * :ref:`ModbusDevice.state ` * :ref:`Object.objectId ` * :ref:`Object.parent ` Methods +++++++ .. hlist:: :columns: 1 * :ref:`ModbusClient.pollSlaves() ` * :ref:`ModbusDevice.connectDevice() ` * :ref:`ModbusDevice.disconnectDevice() ` * :ref:`Object.deserializeProperties() ` * :ref:`Object.fromJson() ` * :ref:`Object.serializeProperties() ` * :ref:`Object.toJson() ` Signals +++++++ .. hlist:: :columns: 1 * :ref:`ModbusClient.slavesDataChanged() ` * :ref:`ModbusDevice.connected() ` * :ref:`ModbusDevice.disconnected() ` * :ref:`ModbusDevice.errorOccurred() ` * :ref:`Object.completed() ` Enumerations ++++++++++++ .. hlist:: :columns: 1 * :ref:`ModbusDevice.BusInterface ` * :ref:`ModbusDevice.Error ` * :ref:`ModbusDevice.State ` Properties ********** .. _property_ModbusRtuMaster_baudRate: .. _signal_ModbusRtuMaster_baudRateChanged: .. index:: single: baudRate baudRate ++++++++ This property holds the data baud rate of the serial port used for communicating with the Modbus RTU slave. :**› Type**: :ref:`SerialPort.BaudRate ` :**› Default**: :ref:`SerialPort.Baud115200 ` :**› Signal**: baudRateChanged() :**› Attributes**: Writable .. _property_ModbusRtuMaster_busInterface: .. _signal_ModbusRtuMaster_busInterfaceChanged: .. index:: single: busInterface busInterface ++++++++++++ This property holds the bus interface to use for communication. See the :ref:`BusInterface ` enumeration for details. This property was introduced in InCore 2.8. :**› Type**: :ref:`BusInterface ` :**› Default**: :ref:`ModbusDevice.SerialPort ` :**› Signal**: busInterfaceChanged() :**› Attributes**: Writable .. _property_ModbusRtuMaster_dataBits: .. _signal_ModbusRtuMaster_dataBitsChanged: .. index:: single: dataBits dataBits ++++++++ This property holds the number of data bits of the serial port used for communicating with the Modbus RTU slave. :**› Type**: :ref:`SerialPort.DataBits ` :**› Default**: :ref:`SerialPort.Data8 ` :**› Signal**: dataBitsChanged() :**› Attributes**: Writable .. _property_ModbusRtuMaster_interFrameDelay: .. _signal_ModbusRtuMaster_interFrameDelayChanged: .. index:: single: interFrameDelay 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 .. _property_ModbusRtuMaster_parity: .. _signal_ModbusRtuMaster_parityChanged: .. index:: single: parity parity ++++++ This property holds the parity mode of the serial port used for communicating with the Modbus RTU slave. :**› Type**: :ref:`SerialPort.Parity ` :**› Default**: :ref:`SerialPort.NoParity ` :**› Signal**: parityChanged() :**› Attributes**: Writable .. _property_ModbusRtuMaster_portName: .. _signal_ModbusRtuMaster_portNameChanged: .. index:: single: portName portName ++++++++ This property holds the name of the serial port used for communicating with the Modbus RTU slave. The value is ignored if :ref:`busInterface ` is not set to :ref:`BusInterface.SerialPort `. :**› Type**: String :**› Signal**: portNameChanged() :**› Attributes**: Writable .. _property_ModbusRtuMaster_queueSizeLimit: .. _signal_ModbusRtuMaster_queueSizeLimitChanged: .. index:: single: queueSizeLimit 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 .. _property_ModbusRtuMaster_stopBits: .. _signal_ModbusRtuMaster_stopBitsChanged: .. index:: single: stopBits stopBits ++++++++ This property holds the number of stop bits of the serial port used for communicating with the Modbus RTU slave. :**› Type**: :ref:`SerialPort.StopBits ` :**› Default**: :ref:`SerialPort.OneStop ` :**› Signal**: stopBitsChanged() :**› Attributes**: Writable .. _property_ModbusRtuMaster_turnaroundDelay: .. _signal_ModbusRtuMaster_turnaroundDelayChanged: .. index:: single: turnaroundDelay 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_ModbusRtuMaster: Example ******* .. code-block:: qml 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) } }