Some conversion like easymodbustcp
lucabecchetti opened this issue · 0 comments
lucabecchetti commented
In easymodbutcp I have this function:
public static float ConvertRegistersToFloat(int[] registers) throws IllegalArgumentException
{
if (registers.length != 2)
throw new IllegalArgumentException("Input Array length invalid");
int highRegister = registers[1];
int lowRegister = registers[0];
byte[] highRegisterBytes = toByteArray(highRegister);
byte[] lowRegisterBytes = toByteArray(lowRegister);
byte[] floatBytes = {
highRegisterBytes[1],
highRegisterBytes[0],
lowRegisterBytes[1],
lowRegisterBytes[0]
};
return ByteBuffer.wrap(floatBytes).getFloat();
}
Is there an alternative on this lib?