版主: wanchong , wangyu , eepwwp , firedom

分享到:
共9条 1/1 1   

Intel Galileo 连接GPS模块失败

    [您是本帖的第1360位阅读者]
2007zoz
我是MM
普通会员

最后登陆时间:2015-09-29 16:36:14

直达楼层
1# 发表于 2015-04-25 22:30:58
小弟我最近在做用Intel Galileo 开发板接收GPS模块数据,但是就是无法接收到数据,Serial.available()一直为0。GPS发送的数据为ASCII码。求各位大神救救我啊,万分感激。程序如下:
[C++] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <string.h>
#include <ctype.h>
intledPin = 13;                 // LED test pin
intrxPin = 0;                   // RX PIN
inttxPin = 1;                   // TX TX
intbyteGPS=-1;
charlinea[300] ="";
charcomandoGPR[7] ="$GPRMC";
intcont=0;
intbien=0;
intconta=0;
intindices[13];
voidsetup() {
   pinMode(ledPin, OUTPUT);      // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   Serial.begin(38400);
   for(inti=0;i<300;i++){      // Initialize a buffer for received data
     linea=' ';
   }  
}
voidloop()
{
   if(Serial.available()){
 
   digitalWrite(ledPin, HIGH);
   delay(100);
   digitalWrite(ledPin, LOW);
   delay(100);
   byteGPS=Serial.read();
   }  // Read a byte of the serial port
   if(byteGPS == -1) {          // See if the port is empty yet
     delay(100);
   }else{
     // note: there is a potential buffer overflow here!
     linea[conta]=byteGPS;       // If there is serial port data, it is put in the buffer
     conta++;                     
     Serial.write(byteGPS);
     if(byteGPS==13){           // If the received byte is = to 13, end of transmission
       // note: the actual end of transmission is <CR><LF> (i.e. 0x13 0x10)
       digitalWrite(ledPin, LOW);
       cont=0;
       bien=0;
       // The following for loop starts at 1, because this code is clowny and the first byte is the <LF> (0x10) from the previous transmission.
       for(inti=1;i<7;i++){    // Verifies if the received command starts with $GPR
         if(linea==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){              // If yes, continue and process the data
         for(inti=0;i<300;i++){
           if(linea==','){   // check for the position of the  "," separator
             // note: again, there is a potential buffer overflow here!
             indices[cont]=i;
             cont++;
           }
           if(linea=='*'){   // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         Serial.println("");     // ... and write to the serial port
         Serial.println("");
         Serial.println("---------------");
         for(inti=0;i<12;i++){
           switch(i){
             case0 :Serial.print("Time in UTC (HhMmSs): ");break;
             case1 :Serial.print("Status (A=OK,V=KO): ");break;
             case2 :Serial.print("Latitude: ");break;
             case3 :Serial.print("Direction (N/S): ");break;
             case4 :Serial.print("Longitude: ");break;
             case5 :Serial.print("Direction (E/W): ");break;
             case6 :Serial.print("Velocity in knots: ");break;
             case7 :Serial.print("Heading in degrees: ");break;
             case8 :Serial.print("Date UTC (DdMmAa): ");break;
             case9 :Serial.print("Magnetic degrees: ");break;
             case10 :Serial.print("(E/W): ");break;
             case11 :Serial.print("Mode: ");break;
             case12 :Serial.print("Checksum: ");break;
           }
           for(intj=indices;j<(indices[i+1]-1);j++){
             Serial.print(linea[j+1]);
           }
           Serial.println("");
         }
         Serial.println("---------------");
       }
       conta=0;                   // Reset the buffer
       for(inti=0;i<300;i++){   // 
         linea=' ';            
       }                
     }
   }
}


file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1983404885\QQ\WinTemp\RichOle\WCAE0FW5E`%1%K$F%~Q80UY.jpg






上一篇:伽利略物联网开发套件
下一篇:以putty登录Linux

QQ图片20140617104115.jpg (38.7 KB, 下载次数: 0)


QQ图片20140617104115.jpg

QQ图片20140617104220.jpg (63.34 KB, 下载次数: 0)


QQ图片20140617104220.jpg

QQ图片20140617104245.jpg (67.77 KB, 下载次数: 0)


QQ图片20140617104245.jpg

QQ图片20140617104314.jpg (65.99 KB, 下载次数: 0)


QQ图片20140617104314.jpg

RE:by zpeng

tianbing2009
我是MM
普通会员

最后登陆时间:2015-01-14 10:48:51

2# 发表于 2015-04-26 07:23:38
新手上路,求带!

RE:by zpeng

adamaa
我是MM
普通会员

最后登陆时间:2015-01-14 10:40:44

3# 发表于 2015-04-26 10:03:17

RE:by zpeng

cyliew
我是MM
普通会员

最后登陆时间:2015-01-14 10:40:18

4# 发表于 2015-04-26 11:10:25
大神啊!

RE:by zpeng

LUOWEN
我是MM
普通会员

最后登陆时间:2015-01-14 11:09:00

5# 发表于 2015-04-27 09:26:13
谢谢楼主的经验分享

RE:by zpeng

miaoqun
我是MM
普通会员

最后登陆时间:2015-01-14 11:06:31

6# 发表于 2015-04-28 16:58:56
必须得顶啊

RE:by zpeng

threeggs
我是MM
普通会员

最后登陆时间:2015-01-14 11:03:16

7# 发表于 2015-04-28 21:39:03
问一下,作为初学者做这个上手合适吗?

RE:by zpeng

jinyaoshi
我是MM
普通会员

最后登陆时间:2015-01-14 10:47:20

8# 发表于 2015-04-29 19:21:58
学习了

RE:by zpeng

duxl2010
我是MM
普通会员

最后登陆时间:2015-01-14 11:02:49

9# 发表于 2015-04-30 23:10:41
外围模块到不错
共9条 1/1 1   
快速回复主题
  • 匿名不能发帖!请先 [ 登陆 注册 ]