i'm using ModbusMaster library (Repo) to read from a device some registers.
Many of them are float and i've no problem to read them using the following code:
//for float conversation
union
{
uint32_t i;
float f;
}u;
uint8_t result = node.readInputRegisters(address, 2); // for 3000xx registers
Serial.println("Result : " + String(result));// to get error type
if (result == node.ku8MBSuccess)
{
u.i=(((unsigned long)node.getResponseBuffer(0x01)<<16) | (node.getResponseBuffer(0x00)));// shifting 2nd register to left & stiching with 1st register
}
Serial.println("Reading is "+String(u.f));
But i have the energy registers that are 64 Bit unsigned int and i can't figure out how to adapt the above code in order to read them.
Anyone has a solution?
(r1 << 32) | r2
or(r2 << 32) | r1