mbed-xbee(ATmode/pc対マイコン) ,LPS25HBの統合一段階目。 cmdの初期化が問題となっている。errorがでない。 確かめ付けました(2022/08/10) f

Dependencies:   mbed LPS25HB_I2C

Revision:
3:c0d472625a4b
Parent:
2:39ad330d9ec8
Child:
4:0ab4ae3013ae
--- a/main.cpp	Tue Aug 09 14:07:28 2022 +0000
+++ b/main.cpp	Wed Aug 10 09:29:03 2022 +0000
@@ -57,56 +57,59 @@
        
         //if (pc.readable()) xbee.putc(pc.getc());
         if (xbee.readable()) pc.putc(xbee.getc());
-        wait_us(1);
        
         char cmd1 = xbee.getc();//cmd共有
-
-        //機体の放出後→データを取る
-        if(cmd1 == 'm'){//3
-            pc.printf("start\r\n");
-            t.start();
-            cmd1 = 0;
+        char va1 = xbee.readable();//これ1にならないと一向に進まないよ
+        
+        if(va1==1){//3 //これいいがいは永遠にまつ。
+            wait_us(1);
+            //機体の放出後→データを取る
+            if(cmd1 == 'm'){//4
+                pc.printf("start\r\n");
+                t.start();
+                cmd1 = 0;
            
-            press.attach(&pre, 1.0);
+                press.attach(&pre, 1.0);
            
-            while(1){//4
-                //if (pc.readable()) xbee.putc(pc.getc());
-                if (xbee.readable()) pc.putc(xbee.getc());
-                //printf("oo");
-                wait_us(1);
+                while(1){//4
+                    //if (pc.readable()) xbee.putc(pc.getc());
+                    if (xbee.readable()) pc.putc(xbee.getc());
+                    //printf("oo");
+               
+                    /***********************************************************/
+                    //float pressure = ps.readPressureMillibars();
+                    //float altitude = ps.pressureToAltitudeMeters(pressure);
+                    //float temperature = ps.readTemperatureC();
+                    //pc.printf("p:%.2f\t mbar\ta:%.2f m\tt:%.2f deg C\r\n",pressure,altitude,temperature);
+            
+                                //データ(気圧,GPS,地磁気)を取る。
+                                //データの保存を10回行い, 保存する。   
                
-                /***********************************************************/
-                //////////////////////////////////////
-                //float pressure = ps.readPressureMillibars();
-                //float altitude = ps.pressureToAltitudeMeters(pressure);
-                //float temperature = ps.readTemperatureC();
-                //pc.printf("p:%.2f\t mbar\ta:%.2f m\tt:%.2f deg C\r\n",pressure,altitude,temperature);
+                    /***********************************************************/
+                    char cmd2 = xbee.getc();
+                    char va2 = xbee.readable();//これ1にならないと一向に進まないよ
+                    
+                    //xbee.printf("%x\r\n",cmd);
+                    
+                    if(va2 == 1){//5
+                        wait_us(1);
+                        //機体の着陸後→プログラムを終わらす。
+                        if(cmd2 == 'n'){//5
+                            press.detach();
+                            pc.printf("end\r\n");
+                            pc.printf("time = %f",t.read());
+                            t.stop();
+                            cmd2 = 0;
                    
-                //////////////////////////////////////
-               
-                                //データ(気圧,GPS,地磁気)を取る。
-                                //データの保存を10回行い, 保存する。
-               
-               
-                /***********************************************************/
-                char cmd2 = xbee.getc();//共有化
-                //xbee.printf("%x\r\n",cmd);
-               
-               
-                //機体の着陸後→プログラムを終わらす。
-                if(cmd2 == 'n'){//5
-                    pc.printf("end\r\n");
-                    pc.printf("time = %f",t.read());
-                    t.stop();
-                    cmd2 = 0;
+                            return 0;
                    
-                    return 0;
-                   
-                    }//5
-               
+                            }//5
+                        va2 = 0;
+                        }//5
+                    }//4
                 }//4
            
-           
+           va1 =0;
             }//3
     }//2
 }//1
\ No newline at end of file