I\'m using a front-end of Lua which is unfortunately outdated, so I\'m stuck with version 5.1 here, meaning the bit32
library is out of reach (which I probably
The issue I faced was trying to convert from the Hex back to a Float; You can use that tonumber(x, 16) to convert it in combination with "Error - Syntactical Remorse's" response. The string.sub is only there because my Modbus driver does not swap the bytes :)
function convertFloatSwapWord(number) -- number is string of format = 0x########
local x = 0
x = float2hex(number)
x = intToHex(x)
x = string.sub(x,5,6) .. string.sub(x,3,4) .. string.sub(x,9,10) .. string.sub(x,7,8)
x = hex2float(tonumber(x, 16))
return x
end