GPS/GSM serial test for Crunchtrack https://hackaday.io/project/7134-crunchtrack

Dependencies:   GPS_CanSat mbed

This project is a simple test for the basic functionality of the Crunchtrack Board. It just forwards the serial port of either the GPS or the GSM to the PC's serial port. There's also a basic implementation of the GPS parser library that handles the GPS data and prints out coordinates and other data.

Revision:
0:99647d2b3203
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Aug 17 18:48:51 2015 +0000
@@ -0,0 +1,104 @@
+#include "mbed.h"
+#include "GPS.h"
+  
+ Serial pc(SERIAL_TX, SERIAL_RX);
+ //v0.2
+ Serial GSM(PC_10, PC_11);
+// Serial GPS(PB_6, PB_7);
+ GPS g1(PB_6, PB_7);
+
+ 
+ //v0.1
+ //Serial GPS(PC_10, PC_11);
+ //Serial GSM(PA_14, PA_15);
+ 
+//breadboard
+//Serial GSM(PB_6, PB_7);
+//Serial GPS(PC_4, PC_5);
+
+//GPS g1(PC_10, PC_11);
+
+DigitalIn mybutton(USER_BUTTON);
+DigitalOut myled(PB_2);
+DigitalOut GSMsw(PA_15);
+
+DigitalOut DET(PB_13);
+ /*
+int main() {
+  while(1) {
+    if (mybutton == 0) { // Button is pressed
+      myled = !myled; // Toggle the LED state
+      wait(0.2); // 200 ms
+    }
+  }
+}
+ */
+ 
+int main() {
+  
+  DET = 0;
+  
+  pc.baud(115200);
+  //GPS.baud(9600);
+  GSM.baud(115200);
+  int i = 1;
+  pc.printf("Hello World !\n");
+  
+  
+  ///INIT
+  myled = 1;
+  //GSMsw = 1;
+  wait(1);
+  myled = 0;
+  
+  pc.printf("ON\n");
+   
+      
+  /*    GSM.printf("AT\n");
+  wait(1);
+      GSM.printf("AT\n");
+  wait(1);*/
+      
+ while(1) { 
+ 
+        
+  //GSM.printf("AT\n");
+  
+      /*if(GSM.readable())
+        pc.putc(GSM.getc());
+      if(pc.readable())
+        GSM.putc(pc.getc());*/
+       
+      /*if(GPS.readable())
+        pc.putc(GPS.getc());
+      if(pc.readable())
+        GPS.putc(pc.getc());*/
+       
+
+      wait(1);
+      pc.printf("ns: %d\r\n", g1.ns());
+      pc.printf("ew: %d\r\n", g1.ew());
+      pc.printf("lock: %d\r\n", g1.lock());
+      pc.printf("t: %f\r\n", g1.time());
+      pc.printf("lat: %f\r\n", g1.latitude());
+      pc.printf("lon: %f\r\n", g1.longitude());
+      /*pc.printf("This program runs since %d seconds.\n", i++);
+      s3.putc('U');
+      while(GPS.readable())
+        pc.putc(GPS.getc());
+        */
+        /*
+        pc.putc('G');
+       while(GSM.readable())
+        pc.putc(GSM.getc());
+     GSM.printf("AT+CGMI\n\r");
+      //wait(0.001);
+      while(GSM.readable())
+        pc.putc(GSM.getc());
+        */
+       
+        
+      //myled = !myled;
+  }
+}
+ 
\ No newline at end of file