3DR uBlox LEA-6H demo by Wayne Holder ported to mbed and tweaked by Michael Shimniok (https://sites.google.com/site/wayneholder/self-driving-car---part/evaluating-the-3dr-ublox-lea-6-gps)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
shimniok
Date:
Fri May 17 18:54:33 2013 +0000
Parent:
2:0ebd24621d18
Commit message:
Revised message enable code, works now. Revised SVINFO printout

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri May 17 16:25:57 2013 +0000
+++ b/main.cpp	Fri May 17 18:54:33 2013 +0000
@@ -46,10 +46,22 @@
 int in=0;
 int out=0;
 
-void enableMsg(unsigned char id, bool enable)
+void enableMsg(unsigned char id, bool enable, int rate=1)
 {
-    //               MSG   NAV   < length >  NAV
-    uint8_t cmdBuf[] = {0x06, 0x01, 0x03, 0x00, 0x01, id, enable ? 1 : 0};
+    if (!enable) rate = 0;
+    uint8_t cmdBuf[] = {
+        0x06,   // class CFG
+        0x01,   // id MSG -> CFG-MSG
+        8,      // length, for config message rates
+        0x01,   // class,
+        id,     // id,
+        0x0,    // target 0 rate (DDC/I2C)
+        rate,   // target 1 rate (UART1)
+        0x0,    // target 2 rate (UART2)
+        0x0,    // target 3 rate (USB)
+        0x0,    // target 4 rate (SPI)
+        0x0,    // target 5 rate (reserved)
+    };
     sendCmd(sizeof(cmdBuf), cmdBuf);
 }
 
@@ -90,7 +102,7 @@
     enableMsg(STATUS_MSG, true);    // Enable status messages
     enableMsg(SOL_MSG, true);       // Enable soluton messages
     enableMsg(DOP_MSG, false);       // Enable DOP messages
-    enableMsg(SVINFO_MSG, true);    // Enable SV info messages
+    enableMsg(SVINFO_MSG, true, 2);    // Enable SV info messages
     enableMsg(DGPS_MSG, false);     // Disable DGPS messages
 
     while (1) {
@@ -205,8 +217,8 @@
                                         unsigned int nc = data[4]; // number of channels
                                         pc.printf("SVINFO: channels = %u\n", nc);
                                         for (int ch = 0; ch < nc; ch++) {
-                                            pc.printf("  id = %u ", data[9+12*ch]);
-                                            for (int q=0; q < data[12+12*ch]/10; q++)
+                                            pc.printf("  id = %3u (%2u) ", data[9+12*ch], data[12+12*ch]);
+                                            for (int q=0; q < data[12+12*ch]/5; q++)
                                                 pc.printf("*");
                                             pc.printf("\n");
                                         }
@@ -311,13 +323,15 @@
 
 void sendCmd (unsigned char len, uint8_t data[])
 {
-    gps.printf("%c%c", SYNC1, SYNC2);
     unsigned char chk1 = 0, chk2 = 0;
+
+    gps.putc(SYNC1);
+    gps.putc(SYNC2);
     for (unsigned char ii = 0; ii < len; ii++) {
-        unsigned char cc = data[ii];
-        gps.printf("%c", cc);
-        chk1 += cc;
+        gps.putc(data[ii]);
+        chk1 += data[ii];
         chk2 += chk1;
     }
-    gps.printf("%c%c", chk1, chk2);
+    gps.putc(chk1);
+    gps.putc(chk2);
 }