This example establishes a transparent link between the mbed serial port and the gps I2C on the C027. You can use it to use the standard u-blox tools such as u-center. These tools can then connect to the serial port and talk directly to the GPS receiver. Baudrate should be set to 9600 baud and is fixed. m-center can be downloaded from u-blox website following this link: http://www.u-blox.com/en/evaluation-tools-a-software/u-center/u-center.html
Dependencies: mbed
Fork of C027_GPSTransparentSerial by
Install mbed Windows Drivers
Make sure you installed the drivers on your windows PC to get the virtual serial port. A installation guideline and the drivers can be found in the following wiki page. /handbook/Windows-serial-configuration
main.cpp
- Committer:
- mazgch
- Date:
- 2013-11-21
- Revision:
- 5:598a573e3ad3
- Parent:
- 4:0e065a08144b
- Child:
- 6:5a8fd99e6a09
File content as of revision 5:598a573e3ad3:
#include "mbed.h" #include "C027.h" int main() { Timer tmr; tmr.start(); C027 c027; c027.gpsPower(true); // open the gps i2c port I2C gps(GPSSDA, GPSSCL); gps.frequency(100000); // open the PC serial port and (use the same baudrate) Serial pc(USBTX, USBRX); pc.baud(GPSBAUD); int s = 0; int i = 0; int o = 1; char in[1024]; char out[1024] = { 0xFF/*STREAM_REG*/, 0x00 /* ... */ }; while (1) { // transfer data from pc to gps if (pc.readable() && (o < sizeof(out))) out[o++] = pc.getc(); if (pc.writeable() && i < s) pc.putc(in[i++]); if (tmr.read_ms() > 50) { const char r = 0xFD /*LENGTH_REG*/; unsigned char sz[2]; if (0 == gps.write(GPSADR,&r,sizeof(r), true)) { if (0 == gps.read(GPSADR,(char*)sz,sizeof(sz),true)) { int b = (int)sz[0]; b *= 256; b += sz[1]; if (i == s) i = s = 0; if (b > sizeof(in)-s) b = sizeof(in)-s; if (b > 0) { if (0 == gps.read(GPSADR,&in[s],b,true)) s += b; } } } gps.stop(); if (o > 1) { if (0 == gps.write(GPSADR,out,o)) o = 0; } tmr.reset(); } } }