![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
gps
Dependencies: mbed
main.cpp@0:d0c5d19ca007, 2017-01-18 (annotated)
- Committer:
- wallsow
- Date:
- Wed Jan 18 14:35:08 2017 +0000
- Revision:
- 0:d0c5d19ca007
gps;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wallsow | 0:d0c5d19ca007 | 1 | #include "mbed.h" |
wallsow | 0:d0c5d19ca007 | 2 | |
wallsow | 0:d0c5d19ca007 | 3 | //serial config |
wallsow | 0:d0c5d19ca007 | 4 | Serial pc(PA_0,PA_1); //Serial class for transmission of serial data |
wallsow | 0:d0c5d19ca007 | 5 | //***Broche Connexion GPS ***********// |
wallsow | 0:d0c5d19ca007 | 6 | Serial GPSTXRX(PA_2,PA_3); // input PB_1 for X axis |
wallsow | 0:d0c5d19ca007 | 7 | |
wallsow | 0:d0c5d19ca007 | 8 | int main() |
wallsow | 0:d0c5d19ca007 | 9 | { |
wallsow | 0:d0c5d19ca007 | 10 | pc.baud(9600); |
wallsow | 0:d0c5d19ca007 | 11 | pc.format(8,SerialBase::None,1); |
wallsow | 0:d0c5d19ca007 | 12 | //----------prinf test sur pc--------- |
wallsow | 0:d0c5d19ca007 | 13 | pc.printf("\r\n GPS Test program"); |
wallsow | 0:d0c5d19ca007 | 14 | pc.printf("\r\n******\r\n"); |
wallsow | 0:d0c5d19ca007 | 15 | //------------------------ |
wallsow | 0:d0c5d19ca007 | 16 | |
wallsow | 0:d0c5d19ca007 | 17 | |
wallsow | 0:d0c5d19ca007 | 18 | while(1) { |
wallsow | 0:d0c5d19ca007 | 19 | pc.printf("\r\n GPS Test en cours"); |
wallsow | 0:d0c5d19ca007 | 20 | pc.printf("\r\n******\r\n"); |
wallsow | 0:d0c5d19ca007 | 21 | |
wallsow | 0:d0c5d19ca007 | 22 | int i; |
wallsow | 0:d0c5d19ca007 | 23 | int tag[256]; |
wallsow | 0:d0c5d19ca007 | 24 | char buff[55]; |
wallsow | 0:d0c5d19ca007 | 25 | |
wallsow | 0:d0c5d19ca007 | 26 | |
wallsow | 0:d0c5d19ca007 | 27 | for(i=0;i<255;i++) |
wallsow | 0:d0c5d19ca007 | 28 | { |
wallsow | 0:d0c5d19ca007 | 29 | tag[i]=GPSTXRX.getc(); |
wallsow | 0:d0c5d19ca007 | 30 | pc.printf("gps:%d",tag[i]); |
wallsow | 0:d0c5d19ca007 | 31 | sprintf(buff,"%d%d%d%d%d",tag[0],tag[1],tag[2],tag[3],tag[4]); |
wallsow | 0:d0c5d19ca007 | 32 | pc.printf("%s \r\n",buff); |
wallsow | 0:d0c5d19ca007 | 33 | int code = atoi(buff); |
wallsow | 0:d0c5d19ca007 | 34 | pc.printf("%d \r\n",code); |
wallsow | 0:d0c5d19ca007 | 35 | } |
wallsow | 0:d0c5d19ca007 | 36 | |
wallsow | 0:d0c5d19ca007 | 37 | wait(10); |
wallsow | 0:d0c5d19ca007 | 38 | /* if(GPSTXRX.readable()) |
wallsow | 0:d0c5d19ca007 | 39 | { |
wallsow | 0:d0c5d19ca007 | 40 | serial.putc(GPSTXRX.getc()); |
wallsow | 0:d0c5d19ca007 | 41 | } |
wallsow | 0:d0c5d19ca007 | 42 | char c; |
wallsow | 0:d0c5d19ca007 | 43 | char buffer[128]; |
wallsow | 0:d0c5d19ca007 | 44 | |
wallsow | 0:d0c5d19ca007 | 45 | GPSTXRX.gets(buffer,8); |
wallsow | 0:d0c5d19ca007 | 46 | |
wallsow | 0:d0c5d19ca007 | 47 | serial.printf("I got '%s'\n", buffer); |
wallsow | 0:d0c5d19ca007 | 48 | wait(1);*/ |
wallsow | 0:d0c5d19ca007 | 49 | } |
wallsow | 0:d0c5d19ca007 | 50 | } |