When including this library in multiple files you get the the following error(s):
(.text+0x0): multiple definition of `Modbus::Modbus(unsigned char, Stream&, unsigned char)'
This is easily solved with the following modifications:
-
Placing a "ifndef" around the header code.
#ifndef MODBUS_RTU_H
#define MODBUS_RTU_H
....
#endif
-
creating a ModbusRtu.cpp file to split definition from declaration.
All code down from the next line must be moved to the .cpp file.
/* PUBLIC FUNCTIONS________________________________________________ */
-
and obviously include the header file at the top of the .cpp file. :)
#include <ModbusRtu.h>