stephane/modbusino — pull request #4 by GregRadion (2012-09-11 04:17:15+00:00)
Title: Modbusino

I downloaded and started using your Modbusino code for a project and I believe there is a couple of easily fixable bugs that you should be aware of.
1. i in reply() should be 16 bit not 8, when it is 8 bit the program will lock up if you try and read a register above 255.
2. nb_reg should also be 16 bit not 8, it is in a number of locations, comes into play when reading registers above 255.
3. if (address + nb > nb_reg) {
rsp_length = response_exception(
slave, function,
MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp);
}
in reply() should be followed with an else that is closed before send_msg(rsp, rsp_length);
As if it is not there the program will still form a reply and you can read memory beyond your register table, this is not desirable.
4. Checking for Arduino environment 1 is required as WProgram.h has been replaced with Arduino.h