
simulate satellite program structure
Dependencies: mbed HeptaBattery SDFileSystem HeptaCamera_GPS Hepta9axis HeptaTemp HeptaXbee
Fork of Lab7-01_template by
Revision 20:8bc48b6ac23d, committed 2018-10-19
- Comitter:
- HEPTA
- Date:
- Fri Oct 19 11:08:33 2018 +0000
- Parent:
- 19:4a45050f7b19
- Child:
- 21:8df80d4e6003
- Commit message:
- HEPTA MBSE ver0
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Aug 21 05:59:42 2018 +0000 +++ b/main.cpp Fri Oct 19 11:08:33 2018 +0000 @@ -21,45 +21,53 @@ pc.baud(9600); float bt; float temper; + const char* warning; char str[100]; - char gx[4],gy[4],gz[4],ax[4],ay[4],az[4],mx[4],my[4],mz[4],lad[8],log[8],height[4],bat[4],temperature[4]; + float gx,gy,gz,mx,my,mz; + + int quality=0,stnum=0,gps_check=0; + char ns='A',ew='B',aunit='m'; + float time=0.0,latitude=0.0,longitude=0.0,hacu=0.0,altitude=0.0; + int flag = 0; int rcmd=0,cmdflag=0; + while(1) { battery.power_saving_mode(&flag,&bt); temp.temp_sense(&temper); wait(0.5); xbee.printf("flag = %d, bt = %.2f [V], temp = %.1f [C]\r\n",flag,bt,temper); + if(flag == 1) { - xbee.printf("Low Battery\r\n"); + warning = "Low Battery\r\n"; + xbee.printf("%s",warning); } else if(temper > 35.0) { - xbee.printf("High Temperaturer\n"); + warning = "High Temperature\r\n"; + xbee.printf("%s",warning); } else if((flag == 1) & (temper > 35.0)) { - xbee.printf("Low Battery and High Temperaturer\n"); - } + warning = "Low Battery and High Temperature\r\n"; + xbee.printf("%s",warning); + }else{} + xbee.xbee_receive(&rcmd,&cmdflag); if (cmdflag == 1) { xbee.printf("Command Get = %d\r\n",rcmd); + if (rcmd == 'a') { - for(int i = 0; i < 10; i++) { - xbee.printf("Count = %d\r\n",i); - wait(1.0); - } - } - if (rcmd == 'b') { - mkdir("/sd/mydir", 0777); - FILE *fp = fopen("/sd/mydir/battery.txt","w"); + mkdir("/sd/MissionData", 0777); + FILE *fp = fopen("/sd/MissionData/GyroMag.txt","w"); if(fp == NULL) { error("Could not open file for write\r\n"); } else { for(int i = 0; i < 10; i++) { - battery.vol(&bt); - fprintf(fp,"%f\r\n",bt); + n_axis.sen_gyro(&gx,&gy,&gz); + n_axis.sen_mag(&mx,&my,&mz); + fprintf(fp,"Wx = %f, Wy = %f, Wz = %f, mx = %f, my = %f, mz = %f\r\n",gx,gy,gz,mx,my,mz); wait(1.0); } fclose(fp); } - FILE *fp1 = fopen("/sd/mydir/battery.txt","r"); + FILE *fp1 = fopen("/sd/MissionData/GyroMag.txt","r"); if(fp1 == NULL) { error("Could not open file for read\r\n"); } else { @@ -70,17 +78,41 @@ } fclose(fp1); } - }// - if (rcmd == 'c') { - - } - if (rcmd == 'd') { + if (rcmd == 'b') { + mkdir("/sd/mydir", 0777); + FILE *fp = fopen("/sd/MissionData/Position.txt","w"); + if(fp == NULL) { + error("Could not open file for write\r\n"); + } else { + cam_gps.gps_setting(); + for(int i = 0; i < 10; i++) { + cam_gps.gga_sensing(&time, &latitude, &ns, &longitude, &ew, &quality, &stnum, &hacu, &altitude, &aunit, &gps_check); + fprintf(fp,"time: %f, lat: %f,%c, long: %f,%c, altitude:%f\r\n",time,latitude,ns,longitude,ew,altitude); + wait(1.0); + } + fclose(fp); + } + + FILE *fp1 = fopen("/sd/MissionData/Position.txt","r"); + if(fp1 == NULL) { + error("Could not open file for read\r\n"); + } else { + for(int i = 0; i < 10; i++) { + fgets(str,100,fp1); + xbee.printf("%s",str); + wait(1.0); + } + fclose(fp1); + } + }//b + + if (rcmd == 'c') { cam_gps.Sync(); cam_gps.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240); - cam_gps.test_jpeg_snapshot_data("/sd/test.jpg"); - } + cam_gps.test_jpeg_snapshot_data("/sd/MissionData/picture.jpg"); + }//c xbee.initialize(); } }