From 813742332599c6139d9851fc8b519b5c630bd9de Mon Sep 17 00:00:00 2001 From: travis-farmer Date: Sun, 1 Dec 2024 12:26:12 -0500 Subject: [PATCH] IO_Modbus: board support limits --- IO_Modbus.cpp | 5 ++++- IO_Modbus.h | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/IO_Modbus.cpp b/IO_Modbus.cpp index 4e9da46..0ecb098 100644 --- a/IO_Modbus.cpp +++ b/IO_Modbus.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with CommandStation. If not, see . */ - +#if defined(MBEXPERIMENTAL) || defined(ARDUINO_ARCH_STM32) #include "IO_Modbus.h" #include "defines.h" void ModbusADU::setTransactionId(uint16_t transactionId) { @@ -504,6 +504,8 @@ Modbus::Modbus(uint8_t busNo, HardwareSerial &serial, unsigned long baud, uint16 _cycleTime = cycleTimeMS * 1000UL; // convert from milliseconds to microseconds. _waitA = waitA; _waitB = waitB; + if (_waitA < 3) _waitA = 3; + if (_waitB < 2) _waitB = 2; // Add device to HAL device chain IODevice::addDevice(this); @@ -643,3 +645,4 @@ Modbusnode::Modbusnode(VPIN firstVpin, int nPins, uint8_t busNo, uint8_t nodeID, } } +#endif \ No newline at end of file diff --git a/IO_Modbus.h b/IO_Modbus.h index 1a42c16..203929d 100644 --- a/IO_Modbus.h +++ b/IO_Modbus.h @@ -50,7 +50,7 @@ #ifndef IO_MODBUS_H #define IO_MODBUS_H - +#if defined(MBEXPERIMENTAL) || defined(ARDUINO_ARCH_STM32) #include "IODevice.h" class ModbusADU { public: @@ -406,5 +406,7 @@ public: return NULL; } }; - +#else +#error "You have included IO_Modbus on an unsupported board!" +#endif #endif // IO_MODBUS_H