37 lines
1.3 KiB
C++
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 |