I’d like to use the readFloatBE() function in my JavaScript codec. However, I get the following error:
"Exception generated by quickjs: ‘ieee754’ is not defined at readFloatBE (buffer:1385) at decodeUplink (eval_script:15) at (eval_script:20) "
The codec works fine when testing locally on NodeJS. Is this function not supported by quickjs? From the documentation I got the impression that the whole buffer class should be available.
Here is the codec (I have commented out parts for testing purposes):
function decodeUplink(input){
/*
sn : bytes_buf.readUIntBE(0,4),
format : bytes_buf.readUIntBE(4,1),
byte_count : bytes_buf.readUIntBE(5,1),
voltage : +(bytes_buf.readFloatBE(6,4).toFixed(3)),
amps : +(bytes_buf.readFloatBE(10,4).toFixed(3)),
crc : bytes_buf.readUIntBE(18,2),
*/
const bytes_buf = Buffer.from(input.bytes)
return{
data:{
Eapp : +(bytes_buf.readFloatBE(14).toFixed(3)),
}
}
}
Thanks for your feedback. I have a similarly hacky solution running at the moment which is working fine. I’m simply trying to clean up the decoders and the builtin function would really help with that.