SSLM1 / Mbed 2 deprecated 1_Transiver_GPS

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sasakisho
Date:
Wed Jul 01 12:59:29 2020 +0000
Commit message:
version0

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 01 12:59:29 2020 +0000
@@ -0,0 +1,69 @@
+/* GMS6-CR6の流すデータからフォーマットGPGGAのみを取得して,PCに出力 (ネットにあったコード)*/
+
+#include "mbed.h"
+#include "math.h"
+
+#define TIME_GAP 6.0
+
+Serial gps (p9, p10);       //GPSのピンを設定
+Serial pc (USBTX, USBRX);
+Serial twe (p13, p14);
+
+/* 時間測定 */
+Timer  timer_open;
+Timer  timer_log;
+Ticker tic_open;
+Ticker tic_log;
+
+/* プロタイプ宣言 */
+float _DMS2DEG(float raw_data);
+int   _input(char cha);
+
+/* グローバル変数の設定 */
+float Time;
+char  gps_data[256];
+int   cnt_gps;
+int   Cnt_GPS = 0;
+
+int main()
+{
+    float world_time, lon_east, lat_north;
+    int rlock, sat_num;
+    char lat, lon;
+    
+    pc.baud(115200);
+    twe.baud(115200);
+    
+    while(1)
+    {
+        if(gps.readable())
+        {
+            gps_data[cnt_gps] = gps.getc();
+            
+            if(gps_data[cnt_gps] == '$' || cnt_gps == 256)
+            {
+                cnt_gps = 0;
+                memset(gps_data, '\0', 256); //この関数なんや
+            }
+            else if(gps_data[cnt_gps] == '\r')
+            {   
+                if(sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d,%d", &world_time, &lat_north, &lat, &lon_east, &lon, &rlock, &sat_num) >= 1)
+                {
+                    twe.printf("%s \r\n", gps_data);
+                }
+            }
+             else
+             {
+                 cnt_gps++;
+             }
+        }
+        if(timer_log.read() >= 30.0*60.0) timer_log.reset();
+    }
+}
+
+float _DMS2DEG(float raw_data)
+{
+    int d = (int)(raw_data/100);
+    float m = (raw_data - (float)d * 100);
+    return (float) d + m /60;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jul 01 12:59:29 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file