smarmengol / Modbus-Master-Slave-for-Arduino

Modbus Master-Slave library for Arduino
GNU Lesser General Public License v2.1
483 stars 330 forks source link

Compilation error for Arduino Due: #22

Closed counters closed 4 years ago

counters commented 7 years ago

The "SoftwareSerial" library is not compatible with Arduino Due. Please modify the library without "SoftwareSeries".

*****\libraries\SoftwareSerial\src\SoftwareSerial.cpp:45:30: fatal error: util/delay_basic.h: No such file or directory

include <util/delay_basic.h>

                          ^

compilation terminated.

graynet-dev commented 5 years ago

Arduino DUE does not have SoftwareSerial.h . For normal library operation, insert a check on the hardware platform. ModbusRtu.h

if defined (AVR)

   #include <SoftwareSerial.h>

endif

if defined (AVR)

 SoftwareSerial *softPort; //!< Pointer to SoftwareSerial class object

endif

if defined (AVR)

  void begin(SoftwareSerial *sPort, long u32speed);
  void begin(SoftwareSerial *sPort, long u32speed, uint8_t u8txenpin);

endif

ModbusRtu.cpp

if defined (AVR)

void MODBUS_RTU::begin(SoftwareSerial *sPort, long u32speed, uint8_t u8txenpin){ //pinMode(SerialTxControl, OUTPUT); this->u8txenpin=u8txenpin; softPort=sPort;

softPort->begin(u32speed);

if (u8txenpin > 1)   // pin 0 & pin 1 are reserved for RX/TX
{
    // return RS485 transceiver to transmit mode
    pinMode(u8txenpin, OUTPUT);
    digitalWrite(u8txenpin, LOW);
}

while(softPort->read() >= 0);
u8lastRec = u8BufferSize = 0;
u16InCnt = u16OutCnt = u16errCnt = 0;

}

endif

And further in the text where there are challenges SoftwareSerial.h