Download LEIBnix Reference Manual
Transcript
Read Config File I'm using a regular text file for configuration - I was thinking about using XML but the overhead seemed to big, but this may come in future. Example of Config File The default name of the config file is EIBCONFIG.INI and looks like this: [Header] version = 3.00 [GroupAddrs] 10/0/0 = Room1 set Dimmer 10/0/2 = Room1 status Dimmer 10/1/0 = Ventilation 2/2/4 = Main Door 2/2/5 = Main Door |+|*|off|on| |+|*|=off|=on| |-|*|off|on| |+|*|=closed|=open| |+|*|unlocked|locked| [System] SYSTEMENABLE = 8/0/0 SYSTEMSTATE = 8/0/1 [Schedule] SETTIME | 05:00:00 SETTIME | 01:30:00 SETTIME | 04:00:00 SUNDOWN | +01:30:01 | 31/7/255 | 1 | | 10/1/0 | 1 | | 10/1/0 | 0 | | 3/2/9 | 1 | MDMDFSS MDMDFSS MDMDFSS MDMDFSS | | | | reload config ventilation on ventilation off blindfolds down [Rules] 10/7/1 = 0 | 12 | 10/7/2 = 0 | stop blindfold after 12 secs [StatusObjs] 2/2/4 |grn|red| main door open-close 2/2/5 |red|grn| main door is locked 2/1/1 |grn|ylo| windows 1st floor The function ReadConfig() opens the config file and reads it line by line. According to the section header, each line is parsed using a sscanf() call and the information is the stored into tables. I decided to use static tables because the UNC has no MMU and I assume that the config file's size does not change too much. Most entries use a '=' or ' |' character to separate parameter fields, see examples above. [Header] this section is currently not used, the version tag is just for convenience [GroupAddrs] The purpose of this section is to register all group addresses. Format of the entries is like this 1. group address EIB group address in the form 'a/b/c' 2. description description of the group address as text 3. logging flag selects logging for incoming EIB messages