Open GoogleCodeExporter opened 8 years ago
This is not a defect but a review.
I have attached the altered library and header file. I have tested it on the
Deumilanove.
Original comment by bester.j...@gmail.com
on 11 Dec 2013 at 12:42
Attachments:
Thanks, I ll test it.
Original comment by fisher...@gmail.com
on 12 Dec 2013 at 11:36
Hi again,
No its not working that way I expected. Or may be I missed smthng.
I m using this code (simplified just to make i shorter). And expect modbus ID
to be either 3 or 4 depend on which button I press but its not working this
way. It looks like modbus is not initiated properly. Could you direct me what I
did wrong?
#include <SimpleModbusSlave.h>
enum //Modbus declare
{
giHR_01,
giHR_02,
HOLDING_REGS_SIZE // leave this one
};
unsigned int holdingRegs[HOLDING_REGS_SIZE];
void setup()
{
}
void loop()
{
switch (key) // depending on which button was pushed, we configure modbus
{
case btnRIGHT: {
lcd.print("RIGHT ");
modbus_configure(&Serial, 9600, SERIAL_8N1, 4, 0, HOLDING_REGS_SIZE, holdingRegs);
break;
}
case btnLEFT: {
lcd.print("LEFT ");
modbus_configure(&Serial, 9600, SERIAL_8N1, 3, 0, HOLDING_REGS_SIZE, holdingRegs);
break;
}
break;
}
modbus_update();
}
Original comment by fisher...@gmail.com
on 12 Dec 2013 at 1:02
I tested the code below and it works flawlessly:
#include <SimpleModbusSlave.h>
enum //Modbus declare
{
giHR_01,
giHR_02,
HOLDING_REGS_SIZE // leave this one
};
unsigned int holdingRegs[HOLDING_REGS_SIZE];
void setup()
{
modbus_configure(&Serial, 9600, SERIAL_8N1, 1, 2, HOLDING_REGS_SIZE, holdingRegs); // this has to be called at least once in setup
}
void loop()
{
switch (key) // depending on which button was pushed, we configure modbus
{
case btnRIGHT: {
lcd.print("RIGHT ");
modbus_config_comms(9600, SERIAL_8N1, 4);
break;
}
case btnLEFT: {
lcd.print("LEFT ");
modbus_config_comms(9600, SERIAL_8N1, 3);
break;
}
break;
}
modbus_update();
}
Original comment by bester.j...@gmail.com
on 18 Dec 2013 at 11:12
Hi.
Will check it tomorrow.
Thanks
Original comment by fisher...@gmail.com
on 20 Dec 2013 at 2:15
Yes it works perfectly!
Thanks mate. Well done!
Original comment by fisher...@gmail.com
on 22 Dec 2013 at 12:49
Original issue reported on code.google.com by
fisher...@gmail.com
on 9 Dec 2013 at 11:40