Reading Floating Point Numbers using Locators
2012-10-11 06:25:27 PDT
I can not find any examples on how to read floating point numbers from registers using locators. I am using modbus4j 1.1
In my investigations on line I have seen references to 'NumericLocator' but am unable to find this type in modbus4j or serotonin jars.
Can anyone direct me to an example on how to read floating point numbers using locators?
BTW. I have looked at other java modbus implementations and have found that modbus4j to be superior.
I apologize, but the jar files uploaded at SF are probably not terribly up to date. You're much better off using the version checked into the CVS. Source is there as well, including the ANT build script in case you're feeling adventurous.
NumericLocator is in the package com.serotonin.modbus4j.locator. There are multiple floating point data types available, as listed in the com.serotonin.modbus4j.code.DataType class:
public static final int FOUR_BYTE_FLOAT = 8; public static final int FOUR_BYTE_FLOAT_SWAPPED = 9; public static final int EIGHT_BYTE_FLOAT = 14; public static final int EIGHT_BYTE_FLOAT_SWAPPED = 15;
Hope this helps.
Thanks for the fast response. It turned out as you suspected. I downloaded the cvs version and it worked. btw, the NumericLocator was not required.