Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of dgps by
Diff: handle/mavcommands.cpp
- Revision:
- 52:b4dddb28dffa
- Parent:
- 39:1acea80563cf
- Child:
- 53:d785a6f6abdd
diff -r 7b4d6043f533 -r b4dddb28dffa handle/mavcommands.cpp --- a/handle/mavcommands.cpp Wed Apr 23 04:09:06 2014 +0000 +++ b/handle/mavcommands.cpp Sat Apr 26 03:35:53 2014 +0000 @@ -20,7 +20,9 @@ issueTakeOff.targSys=1;issueTakeOff.targComp=1;issueTakeOff.lat=5.0f;issueTakeOff.lon=6.0f;issueTakeOff.alt=7.0f;issueTakeOff.cmd=22;issueTakeOff.seq=0;issueTakeOff.current=1; // Issue start issueStart.targSys=1;issueStart.targComp=1;issueStart.lat=5.0f;issueStart.lon=6.0f;issueStart.alt=7.0f;issueStart.cmd=22;issueStart.seq=0;issueStart.current=1; - + // Issue location request + issueStreamReq.targSys=1;issueStreamReq.targComp=1;issueStreamReq.streamID=6;issueStreamReq.rate=5;issueStreamReq.start=1; + // Local variables startSetup=true;// Set to true to initiate startup sequence readState=0; // Read State @@ -35,7 +37,7 @@ return NULL; }else{ char input=Mav::getSerial().getc(); - USB::getSerial().printf("> %x %d %d\n",input,readState,realLen); + USB::getSerial().printf(">%x ",input); if(readState==0&&input==0xFE){ readState=1; readIndex=1; @@ -48,6 +50,7 @@ if(readState==2){ realLen--; if(realLen==0){ + USB::getSerial().printf("\n"); readState=0; char* output=new char[readIndex]; for(int i=0;i<readIndex;i++){output[i]=nextCmd[i];} @@ -70,10 +73,14 @@ startSetup=false; USB::getSerial().printf("Issue Command\n",myCmd[1],myCmd[5]); // Issue count to init waypoint entry - Mav::sendOutput(MAVLINK_MSG_ID_COUNT,(char*)&issueCount,sizeof(MAV_COUNT)); - }else{ - Mav::sendOutput(MAVLINK_MSG_ID_REQUEST_LIST,(char*)&req,sizeof(MAV_REQUEST_LIST)); - } + //Mav::sendOutput(MAVLINK_MSG_ID_COUNT,(char*)&issueCount,sizeof(MAV_COUNT)); + // Start sending location data + //Mav::sendOutput(MAVLINK_MSG_ID_REQUEST_DATA_STREAM,(char*)&issueStreamReq,sizeof(MAV_DATA_STREAM)); + }//else{ + // Start sending location data + Mav::sendOutput(MAVLINK_MSG_ID_REQUEST_DATA_STREAM,(char*)&issueStreamReq,sizeof(MAV_DATA_STREAM)); + //Mav::sendOutput(MAVLINK_MSG_ID_REQUEST_LIST,(char*)&req,sizeof(MAV_REQUEST_LIST)); + //} } // Check for mavlink message request if(myCmd[5]==MAVLINK_MSG_ID_MISSION_REQUEST){ @@ -92,9 +99,20 @@ // Take off Mav::sendOutput(MAVLINK_MSG_ID_ITEM,(char*)&issueTakeOff,sizeof(MAV_MISSION_ITEM)); wait(1); + // Start sending location data + Mav::sendOutput(MAVLINK_MSG_ID_REQUEST_DATA_STREAM,(char*)&issueStreamReq,sizeof(MAV_DATA_STREAM)); + wait(1); // Arm motors Mav::sendOutput(MAVLINK_MSG_ID_LONG,(char*)&issueArm,sizeof(MAV_APM)); } + // Check for GPS + if(myCmd[5]==33){ + for(int i=0;i<18;i++){USB::getSerial().printf("Got loc %d/18 %d\n",i,myCmd[6+i]);} + MAV_LOCDATA* input=(MAV_LOCDATA*)&myCmd[6]; + USB::getSerial().printf("Got lat %d\n",input->lat);// %d %d %d %d %d,input->lon,input->alt,input->x,input->y,input->z); + USB::getSerial().printf("Got lon %d\n",input->lon); + USB::getSerial().printf("Got alt %d\n",input->alt); + } // Check for waypoint count if(myCmd[5]==44){ USB::getSerial().printf("Waypoints tsys %d tcomp %d cnt %d\n",myCmd[8],myCmd[7],myCmd[6]);