chschloetel ed3d0087b0 modified: include/ModBusConfig.cpp
modified:   include/ModBusConfig.h
modified:   src/main.cpp
2024-11-02 21:11:07 +01:00

37 lines
1.3 KiB
C++

#ifndef MODBUS_CONFIG_H
#define MODBUS_CONFIG_H
#include <Arduino.h>
class ModBusConfig {
public:
ModBusConfig(); // Konstruktor ohne Parameter
void SetModbusID(int ID);
void SetBaudRate(int BAUDRATE);
void ResetModbusID(); // Method to reset Modbus ID
void ResetBaudRate(); // Method to reset Baud Rate
int GetModbusID();
int GetBaudRate();
private:
/*
In diesem Beispiel wird Adresse 0 für die Modbus-ID und Adresse 2 für die Baudrate verwendet.
Diese Adressen sind willkürlich gewählt und sollten nicht mit anderen Daten im EEPROM überlappen.
*/
static const int MODBUS_ID_ADDRESS = 0; // Speicheradresse für Modbus-ID
static const int BAUD_RATE_ADDRESS = 2; // Speicheradresse für Baudrate
static const int MAX_BAUD_RATE = 38400; // Maximal unterstützte Baudrate
static const int MAX_MODBUS_ID_ADDRESS = 254; // Maximal unterstützte Baudrate
static const int STANDARD_MODBUS_ID = 22;
static const int STANDARD_MODBUS_BAUDRATE = 9600;
unsigned long lastWriteTimeID = 0; // Last write time for Modbus ID
unsigned long lastWriteTimeBaud = 0; // Last write time for Baud rate
const unsigned long WRITE_INTERVAL = 120000; // 2 minutes in milliseconds
};
#endif