Hello,
I'm using the modbus master library direct from the IDE (ModbusMaster.h)
I'm reading registers of a device which works pretty fine.
But sometimes the slave shows an CRC error. So i sniffed the communication with "device monitoring studio" and see that the arduino sometimes send a request beginning with a lot of zeroes:
01 03 10 01 00 06 90 C8 <--- Good request
01 03 10 01 00 06 90 C8 <--- Good request
01 03 10 01 00 06 90 C8 <--- Good request
....
00 00 00 00 00 00 00 00 01 03 10 01 00 06 90 C8 <--- Bad request with CRC error
But all request are fired from the same function.
I don't understand why it sends the request sometimes with 8 nulled words.
This are the functions:
void readModbusRegister()
{
ecu.readHoldingRegisters(4097, 6); //read 6 registers beginning from offest 4097
if (result == ecu.ku8MBSuccess) //if transmission is good, decode Data
{
decodeModbusRegister();
}
}
void decodeModbusRegister() //read single word registers and write into data array
{
for (j = 0; j < 6; j++)
{
data[j] = ecu.getResponseBuffer(j);
}
printValues(); //after decoding, print data
}
Can it be old data in the serialbuffer?
regards
Bastian