QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
dylanembed123
Date:
Tue Apr 22 14:21:01 2014 +0000
Revision:
26:06f1c9d70e9f
Parent:
mavcommands.h@25:b7f861fc8ddd
Child:
33:ad63e7013801
Move mav into handlers

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 24:e65416d6de22 56 class MavCmd{
dylanembed123 24:e65416d6de22 57 private:
dylanembed123 24:e65416d6de22 58 MAV_REQUEST_LIST req;
dylanembed123 24:e65416d6de22 59 MAV_APM issueArm;
dylanembed123 24:e65416d6de22 60 MAV_APM issueDisArm;
dylanembed123 24:e65416d6de22 61 MAV_COUNT issueCount;
dylanembed123 24:e65416d6de22 62 MAV_MISSION_ITEM issueItem;
dylanembed123 24:e65416d6de22 63 MAV_MISSION_ITEM issueTakeOff;
dylanembed123 24:e65416d6de22 64
dylanembed123 24:e65416d6de22 65 // Local variables
dylanembed123 24:e65416d6de22 66 bool startSetup; // Set to true to initiate startup sequence
dylanembed123 24:e65416d6de22 67 int readState; // Read State
dylanembed123 24:e65416d6de22 68 int realLen; // How many more bytes need to be read
dylanembed123 24:e65416d6de22 69 char nextCmd[512+1]; // Temperary storage of next command
dylanembed123 24:e65416d6de22 70 int readIndex; // Current index in next cmd (also the size)
dylanembed123 24:e65416d6de22 71 static MavCmd* mavcmd;
dylanembed123 24:e65416d6de22 72 bool initialized;
dylanembed123 24:e65416d6de22 73 public:
dylanembed123 24:e65416d6de22 74 MavCmd():initialized(false){}
dylanembed123 24:e65416d6de22 75 char* getNextCmd();
dylanembed123 24:e65416d6de22 76 void handleNextCmd();
dylanembed123 24:e65416d6de22 77 void setupCmds();
dylanembed123 24:e65416d6de22 78 void setup(){if(!initialized){setupCmds();initialized=true;}}
dylanembed123 25:b7f861fc8ddd 79 void run(){setup();handleNextCmd();}
dylanembed123 24:e65416d6de22 80 static MavCmd& get(){if(mavcmd==NULL){mavcmd=new MavCmd();}return *mavcmd;}
dylanembed123 24:e65416d6de22 81 };