![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Gps
Dependencies: mbed
Fork of GPS_System_with_Google_Maps by
Revision 8:c0a52f5de10d, committed 2017-01-18
- Comitter:
- jijou
- Date:
- Wed Jan 18 17:04:49 2017 +0000
- Parent:
- 7:73d911fc2bfa
- Commit message:
- gps trame ok
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 73d911fc2bfa -r c0a52f5de10d main.cpp --- a/main.cpp Fri Jan 06 13:33:19 2017 +0000 +++ b/main.cpp Wed Jan 18 17:04:49 2017 +0000 @@ -1,24 +1,90 @@ +// Provide a serial pass-through between the PC and an external UART + #include "mbed.h" -#include "GPS.h" -Serial pc(PA_0,PA_1); + +Serial pc(PA_0,PA_1); // tx, rx +//Serial gps(PA_9, PA_10); // tx, rx + +uint8_t buffer[64]; // buffer array for data receive over serial port +uint8_t count=0; -GPS ark(PA_2,PA_3); -DigitalOut myled(LED1); +typedef struct { +uint8_t heure; +uint8_t minute; +uint8_t seconde; +} temps; + +typedef struct { +uint8_t degre; +uint8_t minut; +double secon; +char azimut; +} latitude; + +typedef struct { +uint8_t degre; +uint8_t minut; +double secon; +char azimut; +} longiture; -int main() +void initSerial() +{ + pc.baud(9600); + pc.format(8,SerialBase::None,1); + //gps.baud(9600); + //gps.format(8,SerialBase::None,1); +} + +void clearBufferArray() // function to clear buffer array { - while(1) { - pc.printf("\r\n GPS Test program"); - pc.printf("\r\n******\r\n"); - if( ark.sample() == 1) { - myled=0; - float latitude = ark.latitude; - float longitude = ark.longitude; - float utc =50000; - pc.printf("latitude: %0.2f, longitude: %0.2f, utc: %f\r\n",latitude,longitude,utc); - wait(1); - } else { - myled=1; + for (int i=0; i<count;i++) + { + buffer[i]=NULL; + } // clear all index of array with command NULL +} + +void writeBufferArray() +{ + for (int i=0; i<count;i++) + { + pc.putc(buffer[i]); + } // write all index of array +} + +int main() +{ + initSerial(); + while(1) + { + temps tmp; + if (pc.readable()) // if date is coming from software serial port ==> data is coming from SoftSerial shield + { + while(pc.readable()) // reading data into char array + { + buffer[count++]=pc.getc(); // writing data into array + if(count == 64)break; + } + /* + if (sscanf(buffer, "$GPGGA, %2d%2D%lf", &tmp.heure, &tmp.minute, &tmp.seconde) == 3) + { + pc.printf("%dh, %dm, %fs\n", tmp.heure, tmp.minute, tmp.seconde); + } + else + { + pc.printf("error parsing message bro\n"); + } + */ + + writeBufferArray(); + //pc.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port + clearBufferArray(); // call clearBufferArray function to clear the stored data from the array + count = 0; // set counter of while loop to zero + + } + //if (Serial.available()) // if data is available on hardware serial port ==> data is coming from PC or notebook + //SoftSerial.write(Serial.read()); // write it to the SoftSerial shield } -} \ No newline at end of file + +}