• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

Unable to start modbus polling again after stop polling!

Started by carsten, March 22, 2019, 07:51:03 am

Previous topic - Next topic

carsten

Hi,

I use nrmodbus for polling modbus data from flowmeter via nrsocket here is my setup:

nrmodbus -> nrsocket -> internet -> gsm modem -> flowmeter

All works well for a few weeks, then I get disconnected from flowmeter.
I do a nrmodbus->stoppolling and wait for 5 minutes, then I reconnect to flowmeter with nrSocket.
This is ok, I then start nrmodbus polling again, but the polling does not seem to start  :'(
After five minutes of not polling, the flowmeter disconnects the socket.

If I close the application and start it again all works ok again.

My nrmodbus->delaypoll is 1 minute.

What is the correct way to stop polling, and restart it again???

I poll for severel registers like this:


nrModbus->DelayPoll = 60000;
nrModbus->ReadRegister(80,1,1,true);
nrModbus->ReadRegister(502,1,1,true);


I Stop polling like this:


nrModbus->StopPolling();


But this does only work the first time when i launch my application, i am not able to restart polling after stopping it, why ?

Best Regards
Carsten

Roman Novgorodov

Hello

Can you show me a log from Modbus demo?
Does it contain timeout message?

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

carsten

Hi Roman

I am not able to use your demo program, as we are live and I need to transfer the modbus data to OPC server. But I have done some testing in the office.

Here is my log from the office. I have attached the log from my program and a logfile done with nrLogFile, and as you can see if the socket connection gets disconnected
the polling never starts again!

First time I start my program, and execute "nrModbus->ReadRegisters(80,1,1,true)" the polling queue starts immediately, if I then do "nrModbus->StopPolling()" and again do
"nrModbus->ReadRegisters(80,1,1,true)" the polling does not start immediately.

And in my case if the socket gets disconnected and i wait 3 minutes and I do a "nrModbus->ReadRegisters(80,1,1,true)" then the polling never starts, even though your log file shows
"nrModbus: ReadRegisters 0001 count: 2 addr:01 - Nothing happens"

if I kill my application and start it again everything works again.

What is the correct way to restart polling again with a polling delay of 1 min?

Best Regards
Carsten

Roman Novgorodov

Hello

I have tested ModbusDemo some minutes ago.

I run one copy as slave at remote PC in local netword and ran second copy at my PC.

I clicked several times Start Poll and Stop buttons.
All works fine and Modbus requests get replies.

Possible somehting wrong with socket connection with your server?

Can you test out modbus demo with your server for start stop poll? I do not understand why this is impossible.
You need to make a request that can not destroy your live server.

Roman Novgorodov
DeepSoftware llc

DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

carsten

The Server is not a Program, it is a GSM Hardware unit.

And I need to read severel different registers wide spread, I do the following:

Component Setup:

nrModbus->Timeout = 60000 + 5000;
nrModbus->DelayPoll = 60000;

nrSocket->Active = true;

To start polling I do:

nrModbus->ReadRegisters(80,1,1,true);
nrModbus->ReadRegisters(502,2,1,true);
nrModbus->ReadRegisters(94,1,1,true);

To stop polling I do:

nrModbus->StopPolling();

For some unknown reason the TCP connection sometimes get disconnected, I asume it is the GSM net.

After this to start polling I do:

nrModbus->ReadRegisters(80,1,1,true);
nrModbus->ReadRegisters(502,2,1,true);
nrModbus->ReadRegisters(94,1,1,true);

After this it looks like polling is startet in the log, but from wireshark logging I can see that nothing is send out
the socket, and the hardware GSM Unit drops connection after 5 minutes, if no modbus requests is reveived.

So I end in an endless loop.....

Connect
Readregisters (Nothing is send out the socket)
Disconnect from GSM Unit after 5 min

Connect
Readregisters
Disconnect from GSM Unit

Connect
Readregisters
Disconnect from GSM Unit

I need my software to be able to automatic connect to the hardware unit again after a socket disconnect!

Did you test with DelayPoll of 60000 msec.

I will do some more testing

Best Regards
Carsten



carsten

Hi Roman,

We have done some testing, and there is definitely some problems with your polling queue!

Please explain how to set up this senario?

We need polling for data every 60000 ms, with an allowed timeout of 2000 ms, what we have done is this

nrModbus->DelayPoll = 60000;
nrModbus->Timeout = 2000;

And even though our hardware devices reply to modbus request within 1000 ms we still get a modbus timeout,
and nrModbus queue races on with the next reguest...

Please Advise
Carsten Riisbjerg

Roman Novgorodov

Hello

Please attach TnrLogFile to your copy of TnrModbus component and set its DetailLevel = dlDebug
Also you can attach Log to TnrSocket instance.
Reproduce problem and show me result log file.

Possible I will find some usefl info in it.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

carsten

Hi Roman

Here are my log files, I did also include a wireshark file, to show you that the nrSocket is not sending anything out, even though the log file shows that nrSocket reconnects and I start
polling again.

You also did not answer my question, How do I setup polling every 60000ms with timeout og 2000ms ???

Best Regards
Carsten

Roman Novgorodov

Hello

Please tell me version of your Delphi.
We made some changes and you can test before we will release new version.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Roman Novgorodov

Hello

The new version v9.53 is available.

Please check it with your ptoblem.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

carsten

Hi Roman,

Thank you very much. We will test with version 9.53, and I will return with an update very soon  ;)

By the way I use RAD Studio 10.3 Rio C++.

Regards
Carsten

carsten

Hi Roman,

We have done some testing, and now our program works, we are now able to connect again after we have done a stop polling!
So the things you have changed are working ok.

But I still dont understand your timeout event!

If I do the following:

nrModbus->DelayPoll = 60000;
nrModbus->Timeout = 2000;

Even if my modbus device reply after 500ms I still get a modbus timeout!!
I have to set "nrModbus->Timeout" to a value that is bigger then "nrModbus->DelayPoll" or else I get a timeout after every query.

This clearly must be an error...

Hope you will fix this in the next version?

Best Regards
Carsten