most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
Diff: ConfigFileIO/ConfigFileIO.cpp
- Revision:
- 82:0981b9ada820
- Parent:
- 79:3688c3a0d7f4
- Child:
- 86:ba3a118b0080
--- a/ConfigFileIO/ConfigFileIO.cpp Thu Nov 08 22:30:32 2018 +0000 +++ b/ConfigFileIO/ConfigFileIO.cpp Fri Feb 15 16:00:17 2019 +0000 @@ -53,6 +53,29 @@ xbee().printf("\n\rFile batt.txt successful written.\n\r"); } } +void ConfigFileIO::saveLogVersData(int logversion, int diagversion) { + ConfigFile write_logvers_txt; //write to the config file + + char string_log[128]; + sprintf(string_log, "%d", logversion); + write_logvers_txt.setValue("LogFileVers", string_log); + + char string_diag[128]; + sprintf(string_diag, "%i", diagversion); + write_logvers_txt.setValue("DiagFileVers", string_diag); + + + + //SAVE THE DATA! + xbee().printf("Saving logfile version numbers !"); + + if (!write_logvers_txt.write("/local/logvers.txt")) { + xbee().printf("\n\rERROR: (SAVE)Failure to write logvers.txt file."); + } + else { + xbee().printf("\n\rFile logvvrs.txt successful written.\n\r"); + } +} void ConfigFileIO::savePitchData(float pitch_p_gain, float pitch_i_gain, float pitch_d_gain, float pitch_zeroOffset, float pitch_filter_freq, float pitch_deadband) { ConfigFile write_pitch_txt; //write to the config file @@ -310,18 +333,55 @@ xbee().printf("\n\rFile heading.txt successful written.\n\r"); } } - -int ConfigFileIO::load_BATT_config() { +int ConfigFileIO::load_LogVers_config(int print_diag) { // I could copy this mode to read one line of a leg_mission file. One line or multiple lines? ConfigFile cfg; int count = 0; - if (!cfg.read("/local/batt.txt")) { + int version = 0; + if (!cfg.read("/local/logvers.txt")) { // "/local/leg_mission.txt" + error("Lognames version file logvers.txt File Read Error"); + } + char value[BUFSIZ]; + + + if (cfg.getValue("LogFileVers", &value[0] , sizeof(value))) { + version = atoi(value); + char buf[256]; + sprintf(buf, "LOG%03d.csv", version); + logFilesStruct.logFileName = buf; + logFilesStruct.logversion = version; + count++; + } + if (cfg.getValue("DiagFileVers", &value[0] , sizeof(value))) { + version = atoi(value); + char buf[256]; + + sprintf(buf, "in configfileIO: diag file version number is %d\n", version); + if(print_diag == 1) {mbedLogger().appendDiagFile(buf,3);} + // buf[256]= {0}; + sprintf(buf, "in ConfigFileIO: diag file string is DIAG%03d.txt", version); + if(print_diag == 1) {mbedLogger().appendDiagFile(buf,3);} + // buf[256]= {0}; + sprintf(buf, "DIAG%03d.txt", version); + logFilesStruct.diagFileName = buf; + logFilesStruct.diagversion = version; + sprintf(buf, "in ConfigFileIO: diag info pulled from struct: filename = %s diagvernum = %d\n", logFilesStruct.diagFileName, + logFilesStruct.diagversion); + if(print_diag==1) {mbedLogger().appendDiagFile(buf,3);} + count++; + } + return count; +} +int ConfigFileIO::load_BATT_config() { // I could copy this mode to read one line of a leg_mission file. One line or multiple lines? + ConfigFile cfg; + int count = 0; + if (!cfg.read("/local/batt.txt")) { // "/local/leg_mission.txt" error("BATT File Read Error"); } char value[BUFSIZ]; if (cfg.getValue("PGain", &value[0] , sizeof(value))) { - batt().setControllerP(atof(value)); + batt().setControllerP(atof(value)); // but I want values in a legStructLoaded, not a function count++; } if (cfg.getValue("IGain", &value[0] ,sizeof(value))) {