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 u-blox

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-06
Revision:
4:0e065a08144b
Parent:
3:a985a125f9fa
Child:
5:598a573e3ad3

File content as of revision 4:0e065a08144b:

#include "mbed.h"
#include "C027.h"

int main()
{
    C027 c027;
    c027.gpsPower(true);

    // open the gps i2c port
    I2C gps(GPSSDA, GPSSCL);

    // open the PC serial port and (use the same baudrate)
    Serial pc(USBTX, USBRX);
    pc.baud(GPSBAUD);

    while (1) 
    {
        // transfer data from pc to gps
        int o; 
        char out[256] = { 0xFF, 0x00 /* ... */ };
        for (o = 1; (o < sizeof(out)) && pc.readable(); ) 
            out[o++] = pc.getc();
        if (o > 1)
        {
            if (0 == gps.write(GPSADR,out,o))
                /*ok*/;
        }
    
        const char r = 0xFD; 
        unsigned char sz[2];
        int s = 0, i;
        char in[1024];
        if ( (0 == gps.write(GPSADR,&r,1, true)) &&
             (0 == gps.read(GPSADR,(char*)sz,2,true)) )
        {
            s = 256 * (int)sz[0] + sz[1];
            if (s > sizeof(in)) 
                s = sizeof(in);
            if (s > 0) 
            {
                 if (0 != gps.read(GPSADR,in,s,true))
                    s = 0;
            }
        }
        gps.stop();
    
        for (i = 0; i < s; i ++)
        {
            while (!pc.writeable()) 
                /*wait*/;
            pc.putc(in[i]);
        }
    }
}