LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus TCP/IP read timeout

The code below was taken from the NI Modbus library:

Modbus snippet.png

 

 

The first TCP Read VI, reads 7 bytes as a binary string. The data string is then cast to the MBAP_Header data type.

The MBAP header contains a length field, that is used to determine the length of the Modbus PDU (i.e. remaining part of the TCP message)

The second TCP Read VI then gets the remaining part of the message.

 

Can I set the second read timeout to 0?

For reqular Ethernet, the maximum packet payload is 1500 bytes.

1500 bytes is larger than any Modbus message, so I would not expect segmentation of Modbus messages.

Is this correct?

 

In general, if the application data is less than 1500 bytes (on regular Ethernet) and data is read in two parts, is it a good idea to set the second read timeout to 0.

Is there any other reason why I should not do this?

 

Thanks.

Message Edited by sparkymark567 on 01-28-2010 03:59 AM
Message Edited by sparkymark567 on 01-28-2010 04:01 AM
0 Kudos
Message 1 of 2
(4,103 Views)

Hey,

The second read should not have a time out of 0.  The first read only gets the first 8 bits of data, it does not buffer the rest of the package so the second read still needs time to receive the remaining data and hence will need at least some sort of time out value. 

On the subject of segmentation, I believe you are correct.  As long as your message doesn't excede 1492 bytes (I think the 1500 includes the overhead of the Ethernet package), it should come down in one package.  

 

The best thing you can do is to try it out.  

 

Kind regards,

Dominic Walker
Cardiff University
Electrical and Electronic Engineering Student
0 Kudos
Message 2 of 2
(4,063 Views)