QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
dylanembed123
Date:
Wed Apr 23 04:00:32 2014 +0000
Revision:
39:1acea80563cf
Parent:
33:ad63e7013801
Child:
52:b4dddb28dffa
Waypoints now work;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dylanembed123 24:e65416d6de22 1 #include "mbed.h"
dylanembed123 24:e65416d6de22 2 #include "mavcontrol.h"
dylanembed123 24:e65416d6de22 3 #include "adapt/usb.h"
dylanembed123 24:e65416d6de22 4 #include <algorithm>
dylanembed123 24:e65416d6de22 5
dylanembed123 24:e65416d6de22 6 typedef struct MAV_REQUEST_LIST_S{
dylanembed123 24:e65416d6de22 7 char targSys;
dylanembed123 24:e65416d6de22 8 char targComp;
dylanembed123 24:e65416d6de22 9 }MAV_REQUEST_LIST;
dylanembed123 24:e65416d6de22 10
dylanembed123 24:e65416d6de22 11 typedef struct MAV_COUNT_S{
dylanembed123 24:e65416d6de22 12 uint16_t count;
dylanembed123 24:e65416d6de22 13 char targSys;
dylanembed123 24:e65416d6de22 14 char targComp;
dylanembed123 24:e65416d6de22 15 }MAV_COUNT;
dylanembed123 24:e65416d6de22 16
dylanembed123 24:e65416d6de22 17 typedef struct MAV_REQ_S{
dylanembed123 24:e65416d6de22 18 char targSys;
dylanembed123 24:e65416d6de22 19 char targComp;
dylanembed123 24:e65416d6de22 20 char other;
dylanembed123 24:e65416d6de22 21 char count;
dylanembed123 24:e65416d6de22 22 }MAV_REQ;
dylanembed123 24:e65416d6de22 23
dylanembed123 24:e65416d6de22 24 typedef struct MAV_APM_S{
dylanembed123 24:e65416d6de22 25 float parm1;
dylanembed123 24:e65416d6de22 26 float parm2;
dylanembed123 24:e65416d6de22 27 float parm3;
dylanembed123 24:e65416d6de22 28 float parm4;
dylanembed123 24:e65416d6de22 29 float parm5;
dylanembed123 24:e65416d6de22 30 float parm6;
dylanembed123 24:e65416d6de22 31 float parm7;
dylanembed123 24:e65416d6de22 32 uint16_t cmd;
dylanembed123 24:e65416d6de22 33 uint8_t targSys;
dylanembed123 24:e65416d6de22 34 uint8_t targComp;
dylanembed123 24:e65416d6de22 35 uint8_t confirm;
dylanembed123 24:e65416d6de22 36 } MAV_APM;
dylanembed123 24:e65416d6de22 37
dylanembed123 24:e65416d6de22 38 typedef struct MAV_MISSION_ITEM_S{
dylanembed123 24:e65416d6de22 39 float parm1;
dylanembed123 24:e65416d6de22 40 float parm2;
dylanembed123 24:e65416d6de22 41 float parm3;
dylanembed123 24:e65416d6de22 42 float parm4;
dylanembed123 24:e65416d6de22 43 float lat;
dylanembed123 24:e65416d6de22 44 float lon;
dylanembed123 24:e65416d6de22 45 float alt;
dylanembed123 24:e65416d6de22 46 uint16_t seq;
dylanembed123 24:e65416d6de22 47 uint16_t cmd;
dylanembed123 24:e65416d6de22 48 uint8_t targSys;
dylanembed123 24:e65416d6de22 49 uint8_t targComp;
dylanembed123 24:e65416d6de22 50 uint8_t frame;
dylanembed123 24:e65416d6de22 51 uint8_t current; // set to true/1 to make current
dylanembed123 24:e65416d6de22 52 uint8_t autoContinue;// set to true/1 to auto continue
dylanembed123 24:e65416d6de22 53 uint8_t confirm;
dylanembed123 24:e65416d6de22 54 } MAV_MISSION_ITEM;
dylanembed123 24:e65416d6de22 55
dylanembed123 39:1acea80563cf 56 typedef struct MAV_DATA_STREAM_S{
dylanembed123 39:1acea80563cf 57 uint8_t targSys;
dylanembed123 39:1acea80563cf 58 uint8_t targComp;
dylanembed123 39:1acea80563cf 59 uint8_t streamID;
dylanembed123 39:1acea80563cf 60 uint16_t rate; // Hz
dylanembed123 39:1acea80563cf 61 uint8_t start; // Set to 1 to start and 0 to stop
dylanembed123 39:1acea80563cf 62 } MAV_DATA_STREAM;
dylanembed123 39:1acea80563cf 63
dylanembed123 24:e65416d6de22 64 class MavCmd{
dylanembed123 24:e65416d6de22 65 private:
dylanembed123 24:e65416d6de22 66 MAV_REQUEST_LIST req;
dylanembed123 24:e65416d6de22 67 MAV_APM issueArm;
dylanembed123 24:e65416d6de22 68 MAV_APM issueDisArm;
dylanembed123 24:e65416d6de22 69 MAV_COUNT issueCount;
dylanembed123 24:e65416d6de22 70 MAV_MISSION_ITEM issueItem;
dylanembed123 33:ad63e7013801 71 MAV_MISSION_ITEM issueStart;
dylanembed123 24:e65416d6de22 72 MAV_MISSION_ITEM issueTakeOff;
dylanembed123 24:e65416d6de22 73
dylanembed123 24:e65416d6de22 74 // Local variables
dylanembed123 24:e65416d6de22 75 bool startSetup; // Set to true to initiate startup sequence
dylanembed123 24:e65416d6de22 76 int readState; // Read State
dylanembed123 24:e65416d6de22 77 int realLen; // How many more bytes need to be read
dylanembed123 24:e65416d6de22 78 char nextCmd[512+1]; // Temperary storage of next command
dylanembed123 24:e65416d6de22 79 int readIndex; // Current index in next cmd (also the size)
dylanembed123 24:e65416d6de22 80 static MavCmd* mavcmd;
dylanembed123 24:e65416d6de22 81 bool initialized;
dylanembed123 24:e65416d6de22 82 public:
dylanembed123 24:e65416d6de22 83 MavCmd():initialized(false){}
dylanembed123 24:e65416d6de22 84 char* getNextCmd();
dylanembed123 24:e65416d6de22 85 void handleNextCmd();
dylanembed123 24:e65416d6de22 86 void setupCmds();
dylanembed123 24:e65416d6de22 87 void setup(){if(!initialized){setupCmds();initialized=true;}}
dylanembed123 25:b7f861fc8ddd 88 void run(){setup();handleNextCmd();}
dylanembed123 24:e65416d6de22 89 static MavCmd& get(){if(mavcmd==NULL){mavcmd=new MavCmd();}return *mavcmd;}
dylanembed123 24:e65416d6de22 90 };