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:
- 45:16b8162188ca
- Parent:
- 30:2964617e7676
- Child:
- 73:f6f378311c8d
--- a/SequenceController/SequenceController.cpp Wed Feb 14 21:58:44 2018 +0000 +++ b/SequenceController/SequenceController.cpp Thu Feb 15 02:39:13 2018 +0000 @@ -14,14 +14,13 @@ char value[256]; //read configuration file stored on MBED - if (!read_sequence_cfg.read("/local/sequence.cfg")) { - pc().printf("\n\rERROR:Failure to read sequence.cfg file."); + if (!read_sequence_cfg.read("/local/sequence.txt")) { + pc().printf("\n\rERROR:Failure to read sequence.txt file."); } - else { - int array_size = sizeof(_sequence_array)/sizeof(_sequence_array[0]); - + else { /* Read values from the file until you reach an "exit" character" */ - for (int i = 0; i < 1024; i++) { //works + //up to 256 items in the sequence + for (int i = 0; i < 256; i++) { //works /* convert INT to string */ char buf[256]; sprintf(buf, "%d", i); //searching for 0,1,2,3... @@ -51,28 +50,31 @@ /* CONVERT STRING TO CHAR ARRAY */ /* DIVE */ - if (randomstring.find("dive") != -1) { + //this can only be in the first position + if ((signed int) randomstring.find("dive") != -1) { loadStruct.title = "dive"; loadStruct.state = MULTI_DIVE; //NEW: separate state handles multiple dives } /* DIVE */ /* PITCH */ - if (randomstring.find("neutral") != -1) { + if ((signed int) randomstring.find("neutral") != -1) { loadStruct.title = "neutral"; + pc().printf("\n\rLOAD neutral. %d", randomstring.find("neutral")); loadStruct.state = FIND_NEUTRAL; } /* PITCH */ /* EXIT */ - if (randomstring.find("exit") != -1) { + if ((signed int) randomstring.find("exit") != -1) { loadStruct.title = "exit"; + pc().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) } /* EXIT */ /* DEPTH TO FLOAT */ - if (randomstring.find("depth") != -1) { + if ((signed int) randomstring.find("depth") != -1) { if (randomstring.find("neutral") || randomstring.find("dive")) { int depth_pos = randomstring.find("depth") + 6; //11 in example literally "depth=" char depth_array[256] = {0}; //clear memory @@ -93,7 +95,7 @@ /* DEPTH TO FLOAT */ /* PITCH TO FLOAT */ - if (randomstring.find("pitch") != -1) { + if ((signed int) randomstring.find("pitch") != -1) { if (randomstring.find("neutral") || randomstring.find("dive")) { int pitch_pos = randomstring.find("pitch") + 6; //11 in example char pitch_array[256] = {0}; //clear memory @@ -114,14 +116,14 @@ /* PITCH TO FLOAT */ /* PAUSE */ - if (randomstring.find("pause") != -1) { + if ((signed int) randomstring.find("pause") != -1) { loadStruct.title = "pause"; - pc().printf("\n\rPAUSE."); } /* PAUSE */ /* TIME TO FLOAT */ - if (randomstring.find("timeout") != -1) { + if ((signed int) randomstring.find("timeout") != -1) { + int time_pos = randomstring.find("timeout") + 8; //position of timeout + "timeout=" so 8 char time_array[256] = {0}; int time_counter = 0; @@ -142,12 +144,12 @@ } /* TIME TO FLOAT */ - /* EXIT */ - if (randomstring.find("exit") != -1) { - loadStruct.title = "exit"; - pc().printf("\n\rEXIT."); - } - /* EXIT */ +// /* EXIT */ +// if (randomstring.find("exit") != 0) { +// loadStruct.title = "exit"; +// pc().printf("\n\rEXIT."); +// } +// /* EXIT */ return loadStruct; //each iteration this returns a completed struct }