Hello everyone,
I'm trying to set up an Arduino Nano into a Modbus RTU slave over RS232 using that library http://code.google.com/archive/p/arduino-modbus-slave/downloads
yet, whenever i try to compile the code, i get the following error:
no matching function for call to 'modbusSlave::setBaud(int)'
highlighting the line where "slave.setBaud(9600);" is, although when i see example sketches of that library and those that are similar, it's always written as such, so I wonder what could be wrong in my code or anywhere in the library.
Here is my code where i try to toggle two LEDs
#include <modbusSlave.h>
#include <modbusDevice.h>
#include <modbus.h>
#include <modbusRegBank.h>
modbusDevice regBank;
modbusSlave slave;
#define LED1 2
#define LED2 3
void setup()
{
//Assign the modbus device ID.
regBank.setId(1);
/*
modbus registers follow the following format
00001-09999 Digital Outputs, A master device can read and write to these registers
10001-19999 Digital Inputs, A master device can only read the values from these registers
30001-39999 Analog Inputs, A master device can only read the values from these registers
40001-49999 Analog Outputs, A master device can read and write to these registers
Analog values are 16 bit unsigned words stored with a range of 0-32767
Digital values are stored as bytes, a zero value is OFF and any nonzer value is ON
*/
regBank.add(1);
regBank.add(2);
slave._device = ®Bank;
slave.setBaud(9600);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop()
{
while(1){
int DO1 = regBank.get(1);
if (DO1 <= 0 && digitalRead(LED1) == HIGH) digitalWrite(LED1, LOW);
if (DO1 >= 1 && digitalRead(LED1) == LOW) digitalWrite(LED1, HIGH);
int DO2 = regBank.get(2);
if (DO2 <= 0 && digitalRead(LED2) == HIGH) digitalWrite(LED2, LOW);
if (DO2 >= 1 && digitalRead(LED2) == LOW) digitalWrite(LED2, HIGH);
slave.run();
}
}
I'm using Arduino IDE 1.8.9
Any help greatly appreciated
/MaverickRF