Solved Modbus TCP Client write holding registers
-
@Damian7546 Then don't write registers if there is no connection...
-
@jsulm I was wrong, sometimes app was crash when I try write value. I get message like below :
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread QObject: Cannot create children for a parent that is in a different thread. (Parent is QModbusTcpClient(0x504f8fc), parent's thread is ClientTicketMach(0x1215a30), current thread is QThread(0x11c0b28) QObject::startTimer: Timers cannot be started from another thread Error Modbus TCP CLient read: QModbusDevice::TimeoutError QObject::killTimer: Timers cannot be stopped from another thread
-
@Damian7546 As all these errors tell you: do the threading properly!
-
This post is deleted! -
This post is deleted! -
@jsulm said in Modbus TCP Client write holding registers:
@Damian7546 As all these errors tell you: do the threading properly!
Can you explain me ?
-
@Damian7546 Look:
QObject: Cannot create children for a parent that is in a different thread. (Parent is QModbusTcpClient(0x504f8fc), parent's thread is ClientTicketMach(0x1215a30), current thread is QThread(0x11c0b28)
It seems like your QModbusTcpClient is used in different threads. Please analyse your code to see how you're using it.
I already mentioned in this thread that threads should only be used if really necessary.
-
This post is deleted! -
@jsulm This connect declared in
run()
function:
connect(this, &ClientTicketMach::holdRegArrayChanged,wr_redy);
runwr_redy
in other threadss..:/Do you have any idea how run
wr_redy
in my thread by change values in holdRegArray? -
@jsulm Now I use Modbus TCP Client without threads and everything works.