Menu

inconsistent values read from static values

2015-10-21
2015-10-22
  • paul stanton

    paul stanton - 2015-10-21

    I've found that requesting 1 value I get inconsistent results for fields which should not change in reality.

    Testing against modpoll (command line modbus utility) shows that the field is consistent.

    The problem is that often the last value is returned as 0.

    I have found a work-around and that is to increase the wordCount by 1, and then ignore the extra bytes. When doing so, the desired value becomes static as expected.

    Ie, if I am trying to read 40268 with count of 1, I either get the expected value (30) or zero (0) intermittently.
    Ie, if I am trying to read 40268 with count of 2, I always get the expected value (30) and can ignore the 2nd value.

    Ie, if I am trying to read 40268 and 40269 by reading 40268 with count of 2, the first value is always the expected (30) and the 2nd value is either the expected value (2) or zero (0) intermittently.
    Ie, if I am trying to read 40268 and 40269 by reading 40268 with count of 3, the both values are always the expected value (30, 2).

    I've tried using both ReadMultipleRegistersRequest and ReadInputRegistersRequest and they behave similarly. In fact, apart from the function code (3/4) I can see no difference in their behavoir and wonder if Multiple=Holding rather than as in multiple values.

    advice appreciated.

     
  • Julie Haugh

    Julie Haugh - 2015-10-21

    I'd need to see the raw packet data. I'd also need to know the transport you're using -- RTU or TCP. RTU packets have their consistency protected with a CRC, so if you are seeing bad data, I'd like to know how it is getting through the error checking code.

    The class names were set by the original "jamod" package, and you're correct that ReadMultipleRegistersRequest() is actually a READ HOLDING REGISTERS command (function code 3).

     
  • paul stanton

    paul stanton - 2015-10-22

    I'm using TCP, the device I'm attached to does not do RTU. I'll try and follow up with some data at another time.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.