The field version of the solarnano grid on the ionQubes
Fork of SolarNanoGridv3 by
Diff: SolarNanoGrid.cpp
- Revision:
- 16:919e37e5a895
- Parent:
- 13:de43f28c0365
- Child:
- 22:93fde34d9a94
--- a/SolarNanoGrid.cpp Fri Jun 10 21:06:52 2016 +0000 +++ b/SolarNanoGrid.cpp Sat Jun 11 19:01:24 2016 +0000 @@ -149,4 +149,63 @@ nrf->printDetails(); #endif -} \ No newline at end of file +} + +SongSettings::SongSettings(void){ + // Just set everything to null: + role = NULL; + sdVersion = NULL; + communityID = NULL; + id = NULL; + chan = NULL; + return; +} + +bool SongSettings::LoadSongSettings(void){ + + char * name = "/sd/config.ini"; + bool result = true; + INFO("Loading configuration from %s", name); + FILE *fp; + INFO("Reading config file..."); + fp = fopen(name, "r"); + if(fp == NULL) { + ERR("Config file cannot be read, USE PC TO CREATE config.ini"); + return false; + }else{ + // Read config.ini + if (fscanf (fp,"%c %*c %*s",role )!=1){ + ERR("Config: cannot read role"); + result = false; + } + if (fscanf (fp,"%d %*c %*s",sdVersion )!=1){ + ERR("Config: cannot read version"); + result = false; + } + if (fscanf (fp,"%u %*c %*s",communityID )!=1){ + ERR("Config: cannot read community ID"); + result = false; + } + if (fscanf (fp,"%x %*c %*s",id)!=1){ + ERR("Config: cannot read ID"); + result = false; + } + if (fscanf (fp,"%x %*c %*s",chan )!=1){ + ERR("Locker config: cannot read channel"); + result = false; + } + + if(result == true){ + // create the log directory string, this does NOT create the directory! + sprintf(LogDir, "/sd/data/%02X%04X", (communityID&0XFF),(id&0XFFFF)); + // Print everything back: + INFO("config.ini: Version %u, Community %u ID %x Channel %x, Log Directory: %s",sdVersion, communityID, id, chan, LogDir); + }else{ + ERR("Some of the settings were not loaded correctly. Perhaps %s is corrupted.", name); + } + return result; + } + +} + + \ No newline at end of file