From 2f68d6a76f243b09e488d23f70f91e29024b605c Mon Sep 17 00:00:00 2001 From: uhi22 Date: Fri, 26 May 2023 09:11:19 +0200 Subject: [PATCH] config: error handling and adding windows interface name to template --- configmodule.py | 11 +++++++++-- doc/pyPlc.ini.template | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/configmodule.py b/configmodule.py index 94299fc..f19ebf1 100644 --- a/configmodule.py +++ b/configmodule.py @@ -12,14 +12,21 @@ def getConfigValue(s): try: return config['general'][s] except: - print("Error: seems we have a problem with pyPlc.ini.") + print("Error: seems we have a problem with pyPlc.ini, with entry " + s) print("How to fix: Try to use the docs/pyPlc.ini.template,") print(" copy it into the pyPlc's main folder,") print(" rename it to pyPlc.ini, and edit it for your needs.") sys.exit() def getConfigValueBool(s): - return config.getboolean('general', s) + try: + return config.getboolean('general', s) + except: + print("Error: seems we have a problem with pyPlc.ini, with entry " + s) + print("How to fix: Try to use the docs/pyPlc.ini.template,") + print(" copy it into the pyPlc's main folder,") + print(" rename it to pyPlc.ini, and edit it for your needs.") + sys.exit() if __name__ == "__main__": print("Testing configmodule...") diff --git a/doc/pyPlc.ini.template b/doc/pyPlc.ini.template index 4ffbd77..8a6d71d 100644 --- a/doc/pyPlc.ini.template +++ b/doc/pyPlc.ini.template @@ -12,9 +12,13 @@ mode = PevMode is_simulation_without_modems = false # The Ethernet interface. Usually eth0 on Raspberry. -# Todo: This setting is considered only on linux. Find a clean solution for windows is to be done. +# This setting is considered only on linux. eth_interface = eth0 +# The Ethernet interface name on Windows. Something like +# \Device\NPF_{E4B8176C-8516-4D48-88BC-85225ABCF259} +eth_windows_interface_name = \Device\NPF_{E4B8176C-8516-4D48-88BC-85225ABCF259} + # If a display is connected via serial line, e.g. an WIFI-KIT-32 running the software from https://github.com/uhi22/SerialToOLED display_via_serial = yes @@ -97,4 +101,4 @@ udp_syslog_enable = Yes # REST callback for SoC states. Comment out to disable. Do not leave a trailing slash soc_callback_enabled = False -soc_callback_endpoint = http://1.1.1.1 \ No newline at end of file +soc_callback_endpoint = http://1.1.1.1