Qt Modbus RTS
-
wrote on 2 Aug 2019, 09:48 last edited by Marco Pellin 8 Feb 2019, 09:50
Hi,
I'm working on an hardware that needs RTS software active on TX while working with Modbus RTU.
Is there a way to set it with Qt Modbus libraries?The answer will be useful both for Master and Slave devices, but right now I need it in particular for the Slave/Server case.
Thanks a lot,
Marco -
wrote on 5 Aug 2019, 00:36 last edited by
see QModbusDevice::setConnectionParameter(int parameter, const QVariant &value) and set the RTU comm device to be a comm port that has flow control properly set for your requirements.
-
wrote on 7 Aug 2019, 12:48 last edited by
Thanks for the answer.
Actually QModbusDevice::setConnectionParameter handles only a limited set of parameters (https://doc.qt.io/archives/qt-5.11/qmodbusdevice.html) none of them related to the flow control.
It seems to me that only the QSerialPort class manages the flow control (https://doc.qt.io/qt-5/qserialport.html).
Unfortunately I cannot find anything linking the port to the modbus device, so that the serial port settings may be used with the modbus communication.
Am I missing something? -
wrote on 7 Aug 2019, 13:09 last edited by
You can set up the port with QSerialPort (setting the port up works only if it is closed) and then use QModbusDevice (code written as it is, but currently untested):
QString mySerialPort{QStringLiteral("portname")}; // "portname" == "COM1" or "/dev/ttyS0" { QSerialPort sp(mySerialPort); sp.setFlowControl(QSerialPort::HardwareControl); } // ensure sp is not usable anymore QModbusServer ms; ms.setConnectionParameter(QModbusDevice::SerialPortNameParameter, mySerialPort); ms.connectDevice();
-
Thanks for the answer.
Actually QModbusDevice::setConnectionParameter handles only a limited set of parameters (https://doc.qt.io/archives/qt-5.11/qmodbusdevice.html) none of them related to the flow control.
It seems to me that only the QSerialPort class manages the flow control (https://doc.qt.io/qt-5/qserialport.html).
Unfortunately I cannot find anything linking the port to the modbus device, so that the serial port settings may be used with the modbus communication.
Am I missing something?wrote on 7 Aug 2019, 13:15 last edited by@marco-pellin See @Astrinus example. That's what I was getting at.
-
Thanks for the answer.
Actually QModbusDevice::setConnectionParameter handles only a limited set of parameters (https://doc.qt.io/archives/qt-5.11/qmodbusdevice.html) none of them related to the flow control.
It seems to me that only the QSerialPort class manages the flow control (https://doc.qt.io/qt-5/qserialport.html).
Unfortunately I cannot find anything linking the port to the modbus device, so that the serial port settings may be used with the modbus communication.
Am I missing something?Qt 5.14 will allow you to access the QSerialPort to configure special parameters QTBUG-76232. That will probably allow you to set the handshake parameters.
Meanwhile you can try @Astrinus example.
Regards
-
Qt 5.14 will allow you to access the QSerialPort to configure special parameters QTBUG-76232. That will probably allow you to set the handshake parameters.
Meanwhile you can try @Astrinus example.
Regards
@aha_1980
yes! thanks for the heads up.With 5.14 I‘ll be able to ditch my hackaround to send raw data!
1/7