error of MODBUS PROTOCOL when compiling

hello every one . i want to compile a MODBUS 485 program and using the

#include <SimpleModbusMaster.h>

i have this library installed on pc but this error is happening .

‘modbus_construct’ was not declared in this scope

would you please help me to solve it :frowning:

// MEGA MASTER

// reset master if slave comms lost
//connect an LED to pin 2 to SEE if comms are running, do the same on slave too.

#include <SimpleModbusMaster.h>
//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate
#define retry_count 10

// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2
#define LED 13

// The total amount of available memory on the master to store data
#define TOTAL_NO_OF_REGISTERS 1

// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
READ_FROM_SLAVE_1, // Letter 0
READ_FROM_SLAVE_2, // Letter 1
WRITE_TO_BOTH_SLAVES, // Letter 2
WRITE_TO_SLAVE_ONE, // Letter 3

TOTAL_NO_OF_PACKETS // leave this last entry
};

// Create an array of Packets to be configured
Packet packets[TOTAL_NO_OF_PACKETS];

// Masters register array
unsigned int regs[20]; // CHANGE THIS VALUE FOR HOW MANY REGS YOU HAVE/REQUIRE

//unsigned int regs[TOTAL_NO_OF_REGISTERS];

void setup()
{

// Initialize each packet
// modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 7, 5, 0); //Hello slave one. i have created a box to put this in called packet1. I want you to deliver to me your data in reg 7 and the next 5 regs (total), please put them in masters reg starting at reg0
// modbus_construct(&packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 4, 2, 0); //Hello slave one. i have created a box to put this in called packet2. I am delivering to you from my masters reg starting at 0 and the next 2 regs (total). please put them in your reg starting at reg4
//modbus_construct(&packets[READ_FROM_SLAVE_1], 1 , READ_HOLDING_REGISTERS, 0, 1, 0 ); // READ FROM ONE, DATA FROM SLAVE REGS0 (FIRST DIGIT) AND PUT IT IN MASTERS REGS0 (LAST DIGIT)
// modbus_construct(&packets[READ_FROM_SLAVE_2], 2 , READ_HOLDING_REGISTERS, 0, 1, 1 ); // READ FROM TWO, DATA FROM SLAVE REGS0 (FIRST DIGIT) AND PUT IT IN MASTERS REGS1 (LAST DIGIT)
// modbus_construct(&packets[WRITE_TO_BOTH_SLAVES], 0 , PRESET_MULTIPLE_REGISTERS, 1, 1, 2 ); //READ FROM MASTERS REGS2 (LAST DIGIT) AND WRIGHT TO ALL SLAVES (SLAVE ADDRES SET TO O) AND PUT DATA INTO SLAVES REGS1
// modbus_construct(&packets[READ_FROM_SLAVE_1], 1 , READ_HOLDING_REGISTERS, 0, 3, 0 ); // READ FROM slaveONE, DATA FROM SLAVE REGS 0 (first didit) to 3 (second DIGIT) AND PUT IT IN MASTERS from REGS0 (LAST DIGIT)
// the above are all working, i left them like this so you can SEE how to construct PACKET.

modbus_construct(&packets[WRITE_TO_SLAVE_ONE], 1 , PRESET_MULTIPLE_REGISTERS, 0, 5, 0 ); //READ FROM MASTERS REGS0 (LAST DIGIT) AND WRIGHT To SLAVE1 AND PUT DATA INTO SLAVES REGS0-5 (last digit)
modbus_construct(&packets[READ_FROM_SLAVE_1], 1 , READ_HOLDING_REGISTERS, 5, 5, 5 ); // READ FROM slaveONE, DATA FROM SLAVE REGS 5 (first digit) to 9 (second DIGIT i.e. from 5 for 5 more regs) AND PUT IT IN MASTERS from REGS5-9 (LAST DIGIT)

// Initialize the Modbus Finite State Machine
// modbus_configure(&Serial, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
modbus_configure(&Serial, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);

pinMode(LED, OUTPUT);
/* // removed
int slave_zero_value = regs[0]; // save value from slave 1 (regs[0]) to slave_one_value
int slave_one_value = regs[1]; // save value from slave 1 (regs[1]) to slave_two_value
int slave_two_value = regs[2]; // save value from slave 1 (regs[2]) to slave_three_value
int right_to_slave_one_reg4 = regs[3];
*/
// regs[2] = 123; // value 123 will be sent to all slave devices

//Reg Set for slave one to 5 inputs and 5 outputs

regs[0] =30; // send this data to slave
regs[1]= 31;
regs[2] = 32;
regs[3] = 33;
regs[4] = 34;

regs[5] = 45; // over write with data from slave
regs[6] = 46;
regs[7] = 47;
regs[8] = 48;
regs[9] = 49;
}

void loop()
{
modbus_update();

//display regs values via usb serial port
Serial.print ("IN_0 ");
Serial.println (regs[0]);
Serial.print ("IN_1 ");
Serial.println (regs[1]);
Serial.print ("IN_2 ");
Serial.println (regs[2]);
Serial.print ("IN_3 ");
Serial.println (regs[3]);
Serial.print ("In_4 ");
Serial.println (regs[4]);

Serial.print (" ");
Serial.print ("Out_5 ");
Serial.println (regs[5]);
Serial.print ("Out_6 ");
Serial.println (regs[6]);
Serial.print ("Out_7 ");
Serial.println (regs[7]);
Serial.print ("Out_8 ");
Serial.println (regs[8]);
Serial.print ("Out_9 “);
Serial.println (regs[9]);
Serial.print (” “);
Serial.print (” ");
delay (100);

}

let me do an update . no one answered but i found at last .... this error has gone ... the problem was very simple . i was using simplemodbusmaster.h that had downloaded from websites . but finally found that one person named JUAN B have the right and correct version . i downloaded from his web address . if one have same problem then can reach the real library from his website . i dont link his web because i have not permission of himself . but you can search his usefull sources and find