MAX_MODBUS_ID_ADDRESS 255 und SetModbusID(22); Standardwert gesetzt
This commit is contained in:
parent
960140e9db
commit
d50d66743f
@ -25,6 +25,7 @@ private:
|
||||
static const int MODBUS_ID_ADDRESS = 0; // Speicheradresse für Modbus-ID
|
||||
static const int BAUD_RATE_ADDRESS = 1; // Speicheradresse für Baudrate
|
||||
static const int MAX_BAUD_RATE = 115200; // Maximal unterstützte Baudrate
|
||||
static const int MAX_MODBUS_ID_ADDRESS = 254; // Maximal unterstützte Baudrate
|
||||
};
|
||||
/*
|
||||
Konstruktor: Der Konstruktor initialisiert die Modbus-ID und die Baudrate auf Standardwerte (1 und 9600),
|
||||
@ -33,7 +34,7 @@ private:
|
||||
ModBusConfig::ModBusConfig() {
|
||||
// Optional: Initialisieren Sie die EEPROM-Werte, falls erforderlich
|
||||
if (EEPROM.read(MODBUS_ID_ADDRESS) == 0xFF) {
|
||||
SetModbusID(1); // Setze Standard ID
|
||||
SetModbusID(22); // Setze Standard ID
|
||||
}
|
||||
if (EEPROM.read(BAUD_RATE_ADDRESS) == 0xFF) {
|
||||
SetBaudRate(9600); // Setze Standard Baudrate
|
||||
@ -41,7 +42,7 @@ ModBusConfig::ModBusConfig() {
|
||||
}
|
||||
|
||||
void ModBusConfig::SetModbusID(int ID) {
|
||||
if (ID >= 0 && ID <= 255) { // Überprüfung, dass ID im gültigen Bereich liegt
|
||||
if (ID >= 0 && ID <= MAX_MODBUS_ID_ADDRESS) { // Überprüfung, dass ID im gültigen Bereich liegt
|
||||
EEPROM.write(MODBUS_ID_ADDRESS, ID);
|
||||
} else {
|
||||
Serial.println("Ungültige Modbus-ID. ID muss zwischen 0 und 255 liegen.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user