Bootloader crashing
I'm using your library for connection my Arduino Lenoardo ETH with another device via Modbus RTU.
Everything was going well before I come to my last function. This function have to write Float to 2 registers on the device.
I'm doing it with that function:
void WriteMultRegFloat(int adress,float Temp,int StartReg) { node.setTransmitBuffer(0x0,highWord(Temp)); node.setTransmitBuffer(0x1,lowWord(Temp)); node.writeMultipleRegisters(StartReg,2); node.clearTransmitBuffer(); }
And it crashes bootloader of my Arduino and I have to rewrite it with help of another Arduino via ICSP.
I presolved my issue.
I forgot about
node.begin(adress, Serial1); node.preTransmission(preTransmission); node.postTransmission(postTransmission);
Otherwise, I'm trying to write a Float value to my device. The byte order is High first, Low second. I'm doing it with that function:
void WriteMultRegFloat(int adress,float Temp,int StartReg)
{
Start(adress);
node.setTransmitBuffer(0x00,highWord(Temp));
node.setTransmitBuffer(0x01,lowWord(Temp));
int err=node.writeMultipleRegisters(StartReg,2);
ErrorCode(err);
node.clearTransmitBuffer();
}
Where Start(adress) uses node.begin to the required adress and ErrorCode prints error description to the Serial port.