I think your device is simply echoing the command that it's acknowledging. I know from experience, that some devices do that. To test this hypothesis, connect to your serial device via some terminal application (e.g. If you see the 'test ok' response too, then it indeed is just the device echoing the command. From there you have two options: Remember the command and literally remove it from the response, if it matches. Something like this: @if (s.startsWith(theCommand)) s.remove(0, theCommand.size);@ The other option might be to tell the device to stop echoing.
Most devices that echo have a command for that. Yes, also problem with an echo can be occurs from an 'bad' of RS 422/485 converter. I mean that exists such converters where an input/output direction control is processed with an 'manual' set/reset level on the DTR pin. But it is very cheap and very old converters. Usual, for these devices (good devices) the direction handles automatically by HW himself.
Currently I use the Qt 4.7 for Windows but in documentation I. Modbus is just a serial protocol using RS485. This kind of converter acts like a serial port.
Of course, this problem can be if you use an such converter.:) UPD: QtSerialPort does not read back an write data! Somewhere you something do wrong.:).
Shows how to use the synchronous API of QSerialPort in a worker thread. Shows how to use the synchronous API of QSerialPort in a non-GUI thread. Shows how to get information about serial devices in a system.
Shows how to receive data asynchronously over serial port. Shows how to receive data synchronously over serial port. Shows how to send data asynchronously over serial port. Shows how to send data synchronously over serial port.
Shows how to display information about serial devices in a system. Shows how to use various features of QSerialPort. © 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. In Finland and/or other countries worldwide. All other trademarks are property of their respective owners.