CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Modbus TCP

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

Modbus TCP
PostPosted: Tue Aug 18, 2015 12:57 am     Reply with quote

Hi guys,

In the CCS modbus code, there is a 5 minute timeout in <modbus_app_layer_tcpip.c> in ModbusTCPTask(), case MODBUS_TCP_STATE_CONNECTED.

Any ideas why this is there? It contravenes the Modbuf Implementation guide http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf

Quote:
page 10 "It is recommended to keep the TCP connection opened with a remote device and not
to open and close it for each MODBUS/TCP transaction"
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

Re: Modbus TCP
PostPosted: Tue Aug 18, 2015 2:36 am     Reply with quote

oxo wrote:
Hi guys,

In the CCS modbus code, there is a 5 minute timeout in <modbus_app_layer_tcpip.c> in ModbusTCPTask(), case MODBUS_TCP_STATE_CONNECTED.

Any ideas why this is there? It contravenes the Modbuf Implementation guide http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf

Quote:
page 10 "It is recommended to keep the TCP connection opened with a remote device and not
to open and close it for each MODBUS/TCP transaction"


Contravene is rather a strong word in this context. You can't contravene a recommendation. Also unless the specification specifies otherwise, I'd take the term "transaction" in the modbus context as being a command and response pair, not an open-ended connection, which I would term a "session", but I doubt Modbus, which was originally developed pre-TCP/IP, has such a concept.

I didn't design or write the CCS Modbus code, and it certainly has a few quirks and non-conformances, but the idea that any TCP connection, once opened, is there forever come what may, is nonsense. An inacticvity timeout, which is what a five minute timeout sounds like, sounds a very sensible precaution to me. Furthermore, if there really hasn't been any activity after that time, a transaction can hardly be said to be still taking place.

Given that, I'd suggest keeping the connection alive with an occasional "heartbeat" or "keepalive" command. Some read of a status register or something, every ten seconds or so maybe.

I certainly won't clamour for a change to the driver to remove what I feel to be a pretty sensible precautionary timeout.
Ttelmah



Joined: 11 Mar 2010
Posts: 19542

View user's profile Send private message

PostPosted: Tue Aug 18, 2015 2:43 am     Reply with quote

and in fact, I don't think the timeout even disagrees with the recommendation.

The recommendation is saying not to have a system that makes a connection, does one transaction, and then breaks the connection. Disconnecting if nothing at all is happening, does not disagree with this....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group