Modbus TCP Client - state connecting
-
Hi,
I have a little problem....
to check connection with my Modbus Client I use this slot:void MyMbClient::onModbusStateChanged(int state) { if (state == QModbusDevice::UnconnectedState){ qDebug() <<"Modbus TCP Client Disconnected"; tim_reconnect.start(10000); emit modbusTCPClientConnectedState(true); } else if (state == QModbusDevice::ConnectedState){ qDebug() <<"Modbus TCP Client Connected"; tim_reading_inputRegisters.start(1000); emit modbusTCPClientConnectedState(false); } else if (state == QModbusDevice::ConnectingState){ qDebug() << "Modbus TCP Client Connecting"; emit modbusTCPClientConnectedState(true); }else { qDebug() <<"Modbus TCP Client Disconnected"; tim_reconnect.start(10000); emit modbusTCPClientConnectedState(true); } }
When I close app with modbus Server the state changing in above slot on Disconnected. But when I plug off form power the PC with server Modbus application the state not change, why ?
-
Hi,
I have a little problem....
to check connection with my Modbus Client I use this slot:void MyMbClient::onModbusStateChanged(int state) { if (state == QModbusDevice::UnconnectedState){ qDebug() <<"Modbus TCP Client Disconnected"; tim_reconnect.start(10000); emit modbusTCPClientConnectedState(true); } else if (state == QModbusDevice::ConnectedState){ qDebug() <<"Modbus TCP Client Connected"; tim_reading_inputRegisters.start(1000); emit modbusTCPClientConnectedState(false); } else if (state == QModbusDevice::ConnectingState){ qDebug() << "Modbus TCP Client Connecting"; emit modbusTCPClientConnectedState(true); }else { qDebug() <<"Modbus TCP Client Disconnected"; tim_reconnect.start(10000); emit modbusTCPClientConnectedState(true); } }
When I close app with modbus Server the state changing in above slot on Disconnected. But when I plug off form power the PC with server Modbus application the state not change, why ?
@Damian7546 said in Modbus TCP Client - state connecting:
But when I plug off form power the PC with server Modbus application the state not change, why ?
Probably because the client has no way to notify the server in this case.
-
@Damian7546 said in Modbus TCP Client - state connecting:
But when I plug off form power the PC with server Modbus application the state not change, why ?
Probably because the client has no way to notify the server in this case.
@jsulm So how resolve case when the pc will be plug off power , and my client it knew that connection was lost ?
-
@jsulm So how resolve case when the pc will be plug off power , and my client it knew that connection was lost ?
@Damian7546 try exchanging data, if the answer times out -> connection lost
-
@Damian7546 try exchanging data, if the answer times out -> connection lost
@J-Hilk do you mean that i should change value in server for example in Input Register, cyclically 0,1,0..etc and in the Modbus TCP Client check if this vale is changing ?
-
@J-Hilk do you mean that i should change value in server for example in Input Register, cyclically 0,1,0..etc and in the Modbus TCP Client check if this vale is changing ?
@Damian7546 no need to change a value, make a cyclic read request