Clearing Receive buffer Arduino simple modbus

Dear sir,

I have downloaded Modbus Library for arduino from Below link.
Link https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino/blob/master/ModbusRtu.h

I am trying to communicate multiple slave @ time with their different slave ID. I found with 2 device Communication work fine,When I add up 3 + slave device I am getting

1)Modbus Timeout error.
2) some time Invalid query from MODBUS device.

In library with Receive buffer function, they are not clearing buffer if it exceed the maxbuffer size. I would like to know how can I clear Receive buffer size.

int8_t Modbus::getRxBuffer() {
  boolean bBuffOverflow = false;

  if (u8txenpin > 1) digitalWrite( u8txenpin, LOW );

  u8BufferSize = 0;
  while ( port->available() ) {
    au8Buffer[ u8BufferSize ] = port->read();
    u8BufferSize ++;

    if (u8BufferSize >= MAX_BUFFER)
    {
    au8Buffer[ u8BufferSize ] ={};
    bBuffOverflow = true;
    }
  }
  u16InCnt++;

  if (bBuffOverflow) {
    u16errCnt++;
    return ERR_BUFF_OVERFLOW;
  }
  return u8BufferSize;
}

Its part of code How I am calling main function. Here I am checking set device Id & requested device valid or not
if device Id is valid read data from Modbuscall
else
clear the receive buffer & send exception.

#include <avr/wdt.h>
#include"glob.h"
Modbus *slave = 0;
int8_t state = 0;
uint16_t au16data[30];
float MINV_RANGE = 0.5;
//float MIDV_RANGE1=1.875;
float MAXV_RANGE = 4.5;


int SPD;
int DISCONNECTOR;


int array[8][3] = {
  {
    0, 0, 0
  }
  , {
    0, 0, 1
  }
  , {
    0, 1, 0
  }
  , {
    0, 1, 1
  }
  , {
    1, 0, 0
  }
  , {
    1, 0, 1
  }
  , {
    1, 1, 0
  }
  , {
    1, 1, 1
  }
};
void Take_Reading() {

  for (int row = 0; row < 8; row++)
  {
    //   // get rid of me:
    digitalWrite(SO_enable, array[row][0]);
    digitalWrite(S1_enable, array[row][1]);
    digitalWrite(S2_enable, array[row][2]);
    delay(20);
    analog_1_pv[row] = ANALOG_SCALING * analogRead(A0);
    analog_2_pv[row] = ANALOG_SCALING * analogRead(A1);
    analog_3_pv[row] = ANALOG_SCALING * analogRead(A2);
    if ( (analog_1_pv[row] <= MINV_RANGE || (analog_1_pv[row] >= MAXV_RANGE) ))
    {
      Current_Value1[row] =  0.0;
    }
    else
    {
      Current_Value1[row] =  (analog_1_pv[row] * 12.5) - 31.25;

    }

    if (  (analog_2_pv[row] <= MINV_RANGE || (analog_2_pv[row] >= MAXV_RANGE) ))
    {
      Current_Value2[row] =  0.0;
    }
    else
    {
      Current_Value2[row] =  (analog_2_pv[row] * 12.5) - 31.25;

    }

    if (  (analog_3_pv[row] <= MINV_RANGE || (analog_3_pv[row] >= MAXV_RANGE) ))
    {
      Current_Value3[row] =  0.0;
    }
    else
    {
      Current_Value3[row] =  (analog_3_pv[row] * 12.5) - 31.25;

    }


    Mod_current[row] = (uint16_t)(Mul_Factor * Current_Value1[row]);
    Mod_current[row + 8] = (uint16_t)(Mul_Factor * Current_Value2[row]);
    Mod_current[row + 16] = (uint16_t)(Mul_Factor * Current_Value3[row]);


  }



}


void modbus_call() {

  for (int i = 0; i < 8; i++)
  {
    au16data[i] = Mod_current[i];
    au16data[i + 8] = Mod_current[i + 8];
    au16data[i + 16] = Mod_current[i + 16];
  }

  au16data[25] =(uint16_t)temp_int;
  au16data[26] = ID_Check();
  au16data[27] = SPD;
  au16data[28] = DISCONNECTOR;

  // au16data[29]=slave->getInCnt();
  // au16data[30]=slave->getOutCnt();
  //  au16data[31]=slave.getErrCnt();
}



int ID_Check() {

  int ID_value;
  for (int row = 0; row < 8; row++)
  {
    digitalWrite(SO_enable, array[row][0]);
    digitalWrite(S1_enable, array[row][1]);
    digitalWrite(S2_enable, array[row][2]);
    Status_Out[row] = digitalRead(Output_Read);

  }

  ID_value = 1 * Status_Out[7] + 2 * Status_Out[6] + 4 * Status_Out[5] + 8 * Status_Out[4] + 16 * Status_Out[3] + 32 * Status_Out[2]
    + 64 * Status_Out[1] + 128 * Status_Out[0];
  //  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5
  + 64 * Status_Out[6] + 128 * Status_Out[7];

  return (ID_value);

}

void setup()
{
  wdt_enable(WDTO_8S);

  //analogReference(INTERNAL);

  pinMode(3, OUTPUT);
  pinMode(SO_enable, OUTPUT) ;// pin can enable/disable using digital IO 7 of arduino
  pinMode(S1_enable, OUTPUT) ;// pin can enable/disable using digital IO 6 of arduino
  pinMode(S2_enable, OUTPUT) ;// pin can enable/disable using digital IO 5 of arduino
  //  pinMode(Enablepin, OUTPUT) ;// pin can enable/disable using digital IO 4 of arduino
  pinMode(A0, INPUT) ;
  pinMode(A5, INPUT) ;
  //spd & DC STATUS
  pinMode(SPD_STATUS_PIN, INPUT);
  pinMode(DC_STATUS_PIN, INPUT);

  if (millis() < 10000)
  {
    Device_ID = ID_Check();
  }
   slave = new Modbus(Device_ID, 0, 0);
    slave->begin(9600);
  Serial.begin(9600);
}



void loop() {
  wdt_reset();
  Take_Reading();
  temp_int=Take_Temp_Reading();
 SPD= SPD_Check();
DISCONNECTOR=  DC_Status();
  Take_HV_Reading();
 Device_ID = ID_Check();
 
  if (slave->getID()==Device_ID)
  {
  modbus_call();
 // slave->setTimeOut(1000);
  }else
  {
   // slave->getRxBuffer();
  }
  
    slave->poll( au16data, 30 );
  

}