Unsolved Qt Modbus RTS
-
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 -
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.
-
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? -
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();
-
@marco-pellin See @Astrinus example. That's what I was getting at.
-
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!