Made the code more robust and universal.

This commit is contained in:
marcel
2025-08-01 17:32:53 +02:00
parent d93355098d
commit fb9de94312
11 changed files with 252 additions and 71 deletions

View File

@@ -1,30 +1,20 @@
'''
# A basic APRS iGate and APRS weather station with additional (optional) PE1RXF telemetry support
#
# This program reads the registers of the PE1RXF weather station via ModBus RTU and sends it as
# an APRS WX report over APRS. Additionally, it sends beacons and forwards received APRS messages
# to the APRS-IS network. All configurable via a YAML file called pe1rxf_aprs.yml.
#
# This program also has a PE1RXF APRS telemetry to MQTT bridge, which is configurable via pe1rxf_telemetry.yml
#
# Copyright (C) 2023, 2024 M.T. Konstapel https://meezenest.nl/mees
#
# This file is part of weather_station
#
# weather_station is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weather_station is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with weather_station. If not, see <https://www.gnu.org/licenses/>.
'''
""""
ModBus configuration file reader routines
Copyright (C) 2023-2025 M.T. Konstapel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import yaml
from yaml.loader import SafeLoader
@@ -64,7 +54,9 @@ class config_reader:
def test_global_settings(self):
# Test is all expected settings are present
try:
tmp = self.config_file_settings['global']['log-rf']
tmp = self.config_file_settings['global']['program-log']
tmp = self.config_file_settings['global']['data-log']
tmp = self.config_file_settings['global']['mqtt-server']
except:
print ("Error in the global section of the configuration file.")
return 0