a
Dependencies: HEPTA_CDH HEPTA_EPS HEPTA_SENSOR mbed
Revision 35:b26666d35b9d, committed 23 months ago
- Comitter:
- RyusukeIwata
- Date:
- Mon Nov 14 04:27:28 2022 +0000
- Parent:
- 34:90cbf7f982b0
- Commit message:
- fixed;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 14 01:55:42 2022 +0000
+++ b/main.cpp Mon Nov 14 04:27:28 2022 +0000
@@ -10,7 +10,7 @@
p13, p14,p25,p24);
HEPTA_COM com(p9,p10);
DigitalOut condition(LED1);
-RawSerial sat(USBTX,USBRX,9600);
+Serial sat(USBTX,USBRX,9600);
Timer sattime;
int rcmd = 0,cmdflag = 0; //command variable
//getting command and flag
@@ -41,86 +41,88 @@
int rcmd=0,cmdflag=0; //command variable
sattime.start();
eps.turn_on_regulator();//turn on 3.3V conveter
- for(int i = 0; i < 100; i++) {
- receive(rcmd,cmdflag);
-
- //satellite condition led
- condition = !condition;
- //Contents of command
- if (cmdflag == 1) {
- if (rcmd == 'a') {
- //SD mode
- char str[100];
- mkdir("/sd/mydir", 0777);
- FILE *fp = fopen("/sd/mydir/test.txt","w");
- if(fp == NULL) {
- error("Could not open file for write\r\n");
- }
- for(int i=0; i<10; i++)fprintf(fp,"Hello my name is HEPTA!\r\n");
- fclose(fp);
- fp = fopen("/sd/mydir/test.txt","r");
- for(int j = 0; j < 10; j++) {
- fgets(str,100,fp);
- sat.puts(str);
- }
- fclose(fp);
- sat.printf("Goodbye!!\r\n");
- }else if (rcmd == 'b') {
- float bt;
- for(int i = 0; i < 10; i++) {
- eps.vol(&bt);
- sat.printf("Vol = %f\r\n",bt);
- wait(0.5);
- }
- }else if (rcmd == 'c') {
- //Please insert your answer
- float temp;
- for (int i=0;i<10;i++) {
- sensor.temp_sense(&temp);
- sat.printf("temp = %f\r\n",temp);
- wait(0.5);
- }
- }else if (rcmd == 'd') {
- //Please insert your answer
- float ax,ay,az;
- float gx,gy,gz;
- float mx,my,mz;
- for(int i = 0; i<10; i++) {
- sensor.sen_acc(&ax,&ay,&az);
- sat.printf("acc : ax= %f, ay= %f, az= %f\r\n",ax,ay,az);
- sensor.sen_gyro(&gx,&gy,&gz);
- sat.printf("gyro: gx= %f, gy= %f, gz= %f\r\n",gx,gy,gz);
- sensor.sen_mag(&mx,&my,&mz);
- sat.printf("mag : mx= %f, my= %f, mz= %f\r\n",mx,my,mz);
- wait(0.5);
- }
- }else if (rcmd == 'e') {
- //Please insert your answer
- sensor.gps_setting();
- sat.printf("GPS Raw Data Mode\r\n");
- while(1) sat.putc(sensor.getc());
- }else if (rcmd == 'f') {
- FILE *dummy = fopen("/sd/dummy.txt","w");
- if(dummy == NULL) {
- error("Could not open file for write\r\n");
- }
- fclose(dummy);
-
- sat.printf("Camera Snapshot Mode\r\n");
- sat.printf("Hit Any Key To Take Picture\r\n");
- while(!sat.readable()) {}
- sensor.Sync();
- sensor.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240);
- sensor.test_jpeg_snapshot_picture("/sd/test.jpg");
- }else if (rcmd == 'g'){
- sat.printf("Xbee Count Up Mode\r\n");
- for(int i = 0; i < 10; i++) {
- com.printf("num = %d\r\n",i);
- wait(0.5);
- }
+ //for(int i = 0; i < 100; i++) {
+ rcmd = sat.getc();
+ cmdflag = 1;
+ //receive(rcmd,cmdflag);
+
+ //satellite condition led
+ condition = !condition;
+ //Contents of command
+ if (cmdflag == 1) {
+ if (rcmd == 'a') {
+ //SD mode
+ char str[100];
+ mkdir("/sd/mydir", 0777);
+ FILE *fp = fopen("/sd/mydir/test.txt","w");
+ if(fp == NULL) {
+ error("Could not open file for write\r\n");
+ }
+ for(int i=0; i<10; i++)fprintf(fp,"Hello my name is HEPTA!\r\n");
+ fclose(fp);
+ fp = fopen("/sd/mydir/test.txt","r");
+ for(int j = 0; j < 10; j++) {
+ fgets(str,100,fp);
+ sat.puts(str);
+ }
+ fclose(fp);
+ sat.printf("Goodbye!!\r\n");
+ }else if (rcmd == 'b') {
+ float bt;
+ for(int i = 0; i < 10; i++) {
+ eps.vol(&bt);
+ sat.printf("Vol = %f\r\n",bt);
+ wait(0.5);
+ }
+ }else if (rcmd == 'c') {
+ //Please insert your answer
+ float temp;
+ for (int i=0;i<10;i++) {
+ sensor.temp_sense(&temp);
+ sat.printf("temp = %f\r\n",temp);
+ wait(0.5);
}
- rcmd=0,cmdflag=0;
+ }else if (rcmd == 'd') {
+ //Please insert your answer
+ float ax,ay,az;
+ float gx,gy,gz;
+ float mx,my,mz;
+ for(int i = 0; i<10; i++) {
+ sensor.sen_acc(&ax,&ay,&az);
+ sat.printf("acc : ax= %f, ay= %f, az= %f\r\n",ax,ay,az);
+ sensor.sen_gyro(&gx,&gy,&gz);
+ sat.printf("gyro: gx= %f, gy= %f, gz= %f\r\n",gx,gy,gz);
+ sensor.sen_mag(&mx,&my,&mz);
+ sat.printf("mag : mx= %f, my= %f, mz= %f\r\n",mx,my,mz);
+ wait(0.5);
+ }
+ }else if (rcmd == 'e') {
+ //Please insert your answer
+ sensor.gps_setting();
+ sat.printf("GPS Raw Data Mode\r\n");
+ while(1) sat.putc(sensor.getc());
+ }else if (rcmd == 'f') {
+ FILE *dummy = fopen("/sd/dummy.txt","w");
+ if(dummy == NULL) {
+ error("Could not open file for write\r\n");
+ }
+ fclose(dummy);
+
+ sat.printf("Camera Snapshot Mode\r\n");
+ sat.printf("Hit Any Key To Take Picture\r\n");
+ while(!sat.readable()) {}
+ sensor.Sync();
+ sensor.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240);
+ sensor.test_jpeg_snapshot_picture("/sd/test.jpg");
+ }else if (rcmd == 'g'){
+ sat.printf("Xbee Count Up Mode\r\n");
+ for(int i = 0; i < 10; i++) {
+ com.printf("num = %d\r\n",i);
+ wait(0.5);
+ }
}
+ rcmd=0,cmdflag=0;
}
+ //}
}
}