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: SequenceController/SequenceController.cpp
- Revision:
- 87:6d95f853dab3
- Parent:
- 86:ba3a118b0080
--- a/SequenceController/SequenceController.cpp Thu May 02 20:34:16 2019 +0000 +++ b/SequenceController/SequenceController.cpp Wed May 08 13:24:04 2019 +0000 @@ -228,7 +228,7 @@ if (read_leg_cfg.getValue(buf, &value[0], sizeof(value))) { xbee().printf("\n\rsequence %d = %s",i,value); - sprintf(bux2, "\n\r leg values sequence %d = %s",i,value); + sprintf(bux2, "\n\r leg values sequence %d = %s\n",i,value); mbedLogger().appendDiagFile(bux2,0); legStructLoaded[i] = process(value); //create the structs using process(string randomstring) @@ -279,20 +279,30 @@ } /* LPD */ - /* neutral */ - if ((signed int) randomstring.find("neutral") != -1) { - loadStruct.title = "neutral"; - xbee().printf("\n\rLOAD neutral. %d", randomstring.find("neutral")); - loadStruct.state = FIND_NEUTRAL; + /* start-swim */ + if ((signed int) randomstring.find("start_swim") != -1) { + loadStruct.title = "start_swim"; + xbee().printf("\n\rLOAD start-swim %d", randomstring.find("start_swim")); + loadStruct.state = START_SWIM; + sprintf(bux2, "\n\r process leg file: found START-SWIM label, setting state to same\n"); + mbedLogger().appendDiagFile(bux2,3); } - /* neutral */ - + /* start-swim */ + /* flying_idle */ + if ((signed int) randomstring.find("flying_idle") != -1) { + loadStruct.title = "flying_idle"; + xbee().printf("\n\rLOAD flying-idle found at %d", randomstring.find("flying_idle")); + loadStruct.state = FLYING_IDLE; + sprintf(bux2, "\n\r process leg file: found FLYING_IDLE label, setting state to FLYING_IDLE \n"); + mbedLogger().appendDiagFile(bux2,3); + } + /* flying_idle */ /* EXIT */ if ((signed int) randomstring.find("exit") != -1) { loadStruct.title = "exit"; xbee().printf("\n\rReminder. Exit command is state FLOAT_BROADCAST\n\r"); loadStruct.state = FLOAT_BROADCAST; //this is the new exit condition of the dive-rise sequence (11/4/17) - sprintf(bux2, "\n\r process legfile: found exit key callcount=%d\n", callcount); + sprintf(bux2, "\n\r process(valuestring) legfile: found exit key. Callcount=%d\n", callcount); mbedLogger().appendDiagFile(bux2,3); } /* EXIT */ @@ -300,67 +310,67 @@ /* max DEPTH TO cycle to */ if ((signed int) randomstring.find("max_depth") != -1) { - if (randomstring.find("neutral") || randomstring.find("leg")) { - int depth_pos = randomstring.find("max_depth") + 10; //11 in example literally "depth=" - char depth_array[256] = {0}; //clear memory - int depth_counter = 0; - for (int i = depth_pos; i < randomstring.length(); i++) { - if (cstr[i] == ',') - break; - else if (cstr[i] == ';') - break; - else { - depth_array[depth_counter] = cstr[i]; - depth_counter++; - } + + int depth_pos = randomstring.find("max_depth") + 10; //11 in example literally "depth=" + char depth_array[256] = {0}; //clear memory + int depth_counter = 0; + for (int i = depth_pos; i < randomstring.length(); i++) { + if (cstr[i] == ',') + break; + else if (cstr[i] == ';') + break; + else { + depth_array[depth_counter] = cstr[i]; + depth_counter++; } - loadStruct.max_depth = atof(depth_array); - sprintf(bux2, "\n\r process legfile: key=max_depth val=%g process(legstring)count=%d \n", atof(depth_array), callcount); - mbedLogger().appendDiagFile(bux2,3); } - } + loadStruct.max_depth = atof(depth_array); + sprintf(bux2, "\n\r process legfile: key=max_depth val=%g process(legstring)count=%d \n", atof(depth_array), callcount); + mbedLogger().appendDiagFile(bux2,3); + + } - if ((signed int) randomstring.find("min_depth") != -1) { - if (randomstring.find("neutral") || randomstring.find("leg")) { - int depth_pos = randomstring.find("min_depth") + 10; //11 in example literally "depth=" - char depth_array[256] = {0}; //clear memory - int depth_counter = 0; - for (int i = depth_pos; i < randomstring.length(); i++) { - if (cstr[i] == ',') - break; - else if (cstr[i] == ';') - break; - else { - depth_array[depth_counter] = cstr[i]; - depth_counter++; - } + if ((signed int) randomstring.find("min_depth") != -1) { + + int depth_pos = randomstring.find("min_depth") + 10; //11 in example literally "depth=" + char depth_array[256] = {0}; //clear memory + int depth_counter = 0; + for (int i = depth_pos; i < randomstring.length(); i++) { + if (cstr[i] == ',') + break; + else if (cstr[i] == ';') + break; + else { + depth_array[depth_counter] = cstr[i]; + depth_counter++; } - loadStruct.min_depth = atof(depth_array); - sprintf(bux2, "\n\r process legfile: key=min_depth val=%g \n", atof(depth_array)); - mbedLogger().appendDiagFile(bux2,3); - } - } - if ((signed int) randomstring.find("heading") != -1) { - if (randomstring.find("neutral") || randomstring.find("leg")) { + } + loadStruct.min_depth = atof(depth_array); + sprintf(bux2, "\n\r process legfile: key=min_depth val=%g \n", atof(depth_array)); + mbedLogger().appendDiagFile(bux2,3); + + } + if ((signed int) randomstring.find("heading") != -1) { + int depth_pos = randomstring.find("heading") + 8; //11 in example literally "depth=" char depth_array[256] = {0}; //clear memory int depth_counter = 0; for (int i = depth_pos; i < randomstring.length(); i++) { - if (cstr[i] == ',') + if (cstr[i] == ',') break; - else if (cstr[i] == ';') + else if (cstr[i] == ';') break; else { - depth_array[depth_counter] = cstr[i]; + depth_array[depth_counter] = cstr[i]; depth_counter++; - } + } } loadStruct.heading = atof(depth_array); sprintf(bux2, "\n\r process legfile: key=heading val=%g \n", atof(depth_array)); - mbedLogger().appendDiagFile(bux2,3); - } - } + mbedLogger().appendDiagFile(bux2,3); + + } /* DEPTH TO FLOAT */