GPS-Tracking-Velo

Dependencies:   MODSERIAL SDBlockDevice GPS

Forschungsstand und Theoretische Grundlage

Die Bestandteile der Hardware, die das Projekt gebraucht wird, bestehen aus drei Komponente ein Mikrocontroller Board, eine GPS Antenne und ein SIM Modul. GPS basiert auf Satelliten, die mit codierten Radiosignalen ständig ihre aktuelle Position und genaue Uhrzeit ausstrahlen. Aus den Signallaufzeiten können eine GPS Antenne ihre eigene Position und Geschwindigkeit berechnen. Diese GPS Antenne sollte die Daten der Objektposition aus Satelliten auf dem Board gespeichert werden. Diese Daten wurden noch weiter durch eine SIM Module nach GMS Turm und dann per SMS Nachrichten an Handy gesendet. Möglicherweise können diese Daten auch an Webanwendung nach der Sendung an GMS Turm geschickt werden.

https://os.mbed.com/media/uploads/QuangAnhLe/picture1.png

Revision:
1:2f617b92078b
Parent:
0:ee1ae011cba6
Child:
2:3d3d272d2df2
diff -r ee1ae011cba6 -r 2f617b92078b mbed-os-example-fat-filesystem-master/main.cpp
--- a/mbed-os-example-fat-filesystem-master/main.cpp	Fri Apr 12 13:45:29 2019 +0000
+++ b/mbed-os-example-fat-filesystem-master/main.cpp	Fri Apr 12 17:48:39 2019 +0000
@@ -1,4 +1,9 @@
 #include "mbed.h"
+#include "GPS.h"
+#include <iostream>
+#include <sstream>
+#include <bitset>
+#include <string>
 #include "FATFileSystem.h"
 //#include "HeapBlockDevice.h"
 #include "SDBlockDevice.h"
@@ -8,6 +13,8 @@
 //HeapBlockDevice bd(128 * 512, 512);
 //SDBlockDevice bd(PinName mosi, PinName miso, PinName sclk, PinName cs);
 SDBlockDevice bd(D11, D12, D13, D10);
+Serial pc(PA_2,PA_3);
+GPS gps (PA_11,PA_12);
 
 FATFileSystem fs("fs");
 
@@ -17,44 +24,44 @@
   else
     printf("done.\r\n");
 }
-
+ 
 void errno_error(void* ret_val){
   if (ret_val == NULL)
     printf(" Failure. %d \r\n", errno);
   else
     printf(" done.\r\n");
 }
-
+ 
 int main() {
   int error = 0;
   printf("Welcome to the filesystem example.\r\n"
          "Formatting a FAT, RAM-backed filesystem. ");
   error = FATFileSystem::format(&bd);
   return_error(error);
-
+ 
   printf("Mounting the filesystem on \"/fs\". ");
   error = fs.mount(&bd);
   return_error(error);
-
+ 
   printf("Opening a new file, numbers.txt.");
   FILE* fd = fopen("/fs/numbers.txt", "w");
   errno_error(fd);
-
-  for (int i = 0; i < 15; i++){
+ 
+  /*for (int i = 0; i < 20; i++){
     printf("Writing decimal numbers to a file (%d/20)\r", i);
     fprintf(fd, "%d\r\n", i);
-    //fprintf(fd, "%d\r\n", i);
-  }
-  printf("Writing decimal numbers to a file (20/20) done.\r\n");
-
+  }*/
+  fprintf(fd,"Latitude, Longitude,Altitude,Speed in knots, Date, Time,Number of satellites being tracked, IDs of satellites ins use, Fix, Fix mode,\r\n");
+  //printf("Writing decimal numbers to a file (20/20) done.\r\n");
+ 
   printf("Closing file.");
   fclose(fd);
   printf(" done.\r\n");
-
+ 
   printf("Re-opening file read-only.");
   fd = fopen("/fs/numbers.txt", "r");
   errno_error(fd);
-
+ 
   printf("Dumping file to screen.\r\n");
   char buff[16] = {0};
   while (!feof(fd)){
@@ -62,26 +69,88 @@
     fwrite(&buff[0], 1, size, stdout);
   }
   printf("EOF.\r\n");
-
+ 
   printf("Closing file.");
   fclose(fd);
   printf(" done.\r\n");
-
+ 
   printf("Opening root directory.");
   DIR* dir = opendir("/fs/");
   errno_error(fd);
-
+ 
   struct dirent* de;
   printf("Printing all filenames:\r\n");
   while((de = readdir(dir)) != NULL){
     printf("  %s\r\n", &(de->d_name)[0]);
   }
-
+ 
   printf("Closing root directory. ");
   error = closedir(dir);
   return_error(error);
   printf("Filesystem Demo complete.\r\n");
-
-  while (true) {}
+ 
+  while (true) {
+    pc.printf("\n");
+     wait(1); 
+          if(gps.sample()){
+          float latitude    = gps.latitude;
+          float longitude   = gps.longitude;
+          float altitude    = gps.altitude;
+          float direction   =0.0;
+          float utc = gps.utc+20000;
+          //int sek=gps.sek;
+          //int min=gps.min;
+          //int hour=gps.hour;
+          int sat_tracked=gps. sat_tracked;
+          int fix=gps.fix;
+          int fix_3d=gps.fix_3d;
+          int id1=gps.id1;
+          int id2=gps.id2;
+          int id3=gps.id3;
+          int id4=gps.id4;
+          int id5=gps.id5;
+          int id6=gps.id6;
+          int id7=gps.id7;
+          int id8=gps.id8;
+          int id9=gps.id9;
+          int id10=gps.id10;
+          int id11=gps.id11;
+          int id12=gps.id12;
+          double hdop=gps.hdop;
+          double pdop=gps.pdop;
+          float speed=gps.speed;
+          int   date=gps.date;
+          //char aut=gps.aut;
+          //float vdop=gps.vdop;
+          //int chek_data=gps.check_data;
+          /*pc.printf("Latitude, Longitude,Altitude, Direction, Speed in knots, Date, Time, Satellites in use, Satellites in view, IDs of satellites ins use, Fix, Fix mode, PDOP, HDOP\r\n");
+          pc.printf("%0.6f,%0.6f,%0.3f,%0.2f,%0.2f,%d,%0.0f,%d,",latitude,longitude,altitude,direction,speed,date,utc, sat_tracked);
+          pc.printf("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d,",id1,id2,id3,id4,id5,id6,id7,id8,id9,id10,id11,id12);
+          pc.printf("%d,%d,%.2f,%.2f\r\n",fix,fix_3d,pdop,hdop);*/
+          //pc.printf("%d",date);
+          pc.printf("Latitude: %0.6f\r\n",latitude);
+          pc.printf("Longitude:%0.6f\r\n",longitude);
+          pc.printf("Altitude: %0.3f\r\n",altitude);
+          pc.printf("Speed in knots: %0.2f\r\n",speed);
+          pc.printf("Date: %d\r\n",date);
+          pc.printf("Time UTC: %0.0f\r\n",utc);
+          pc.printf("Number of satellites being tracked: %d\r\n", sat_tracked);
+          pc.printf("PRNs of satellites used for fix:\r\n");
+          pc.printf("ID1:%d,ID2:%d,ID3:%d,ID4:%d,ID5:%d,ID6:%d\r\n",id1,id2,id3,id4,id5,id6);
+          pc.printf("ID7:%d,ID8:%d,ID9:%d,ID10:%d,ID11:%d,ID12:%d\r\n",id7,id8,id9,id10,id11,id12);
+          pc.printf("Fix quality: %d - value include 0=invalid; 1=GPS fix\r\n",fix);
+          pc.printf("3D fix: %d - value include: 1 = no fix, 2 = 2D fix, 3 = 3D fix\r\n\n", fix_3d); 
+          pc.printf("****************************************************************\r\n");   
+          
+          FILE* fd = fopen("/fs/numbers.txt", "a+");
+          errno_error(fd);
+ 
+  /*for (int i = 0; i < 20; i++){
+    printf("Writing decimal numbers to a file (%d/20)\r", i);
+    fprintf(fd, "%d\r\n", i);
+  }*/
+   //fprintf(fd,"Latitude, Longitude,Altitude,Speed in knots, Date, Time,Number of satellites being tracked, IDs of satellites ins use, Fix, Fix mode,\r\n");
+   fprintf(fd,"%0.6f,%0.6f,%0.3f,%0.2f,%d,%0.0f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",latitude, longitude, altitude, speed, date, utc, sat_tracked, id1,id2,id3,id4,id5,id6,id7,id8,id9,id10,id11,id12, fix,fix_3d);
+      }
 }
-
+}
\ No newline at end of file