Module Config
This module contains a method to parse the config.txt to a python dictionary object.
Methods
Example
The following code shows an example to print the application name and initialize a serial port with parameters from the config.txt file.
Example config.txt
# ----System---- #
omc048:
system_id: Description
substation_name: Docs
application: Example
# ----Sensor-Settings---- #
sensors:
- id: dummy
port: serial1
baudrate: 4800
sample_interval: "* * * * *"
supply_port: 3
wakeup_time: 60
Example main.py
from config import get_config
import omc048
config = get_config()
print('app name {}'.format(config['omc048']['application']))
sensor1 = config['sensors'][0]
s1 = omc048.serial(sensor1['port'])
s1.init(sensor1['baudrate'])
# do something with serial1...