1.GPS£¨Global Positioning System£©£ºÈ«ÇòÎÀÐǶ¨Î»ÏµÍ³
ÃÀ¹úµÄ24¿ÅÎÀÐDz»Í£µØ¸øµØÃæ·¢GPSÐźţ¬Ö»ÒªÓÐһ̨GPS½ÓÊÕÉ豸£¬¾ÍÄܶ¨Î»³öÄãËùÔÚµÄλÖø߶ȺÍËÙ¶ÈÁË£¬ËüÓëµç×ÓµØͼµÄ½áºÏ¾ÍÊÇͨ³£Ëù˵µÄGPS¹¦ÄÜ
¶þ¡¢Á¬½Ó·½Ê½
1.´®¿Ú£º¼ÆËã»úͨ³£Í¨¹ý´®¿Ú¶ÁÈ¡gpsÊý¾Ý£¨À¶ÑÀµÄgpsҲʹÓÃÐéÄâ´®¿Ú£©
2.²½Ö裺
1)ÆÕͨ´®¿ÚÉ豸
´ò¿ª´®¿Ú->ÉèÖô®¿Ú->¶ÁÈ¡Êý¾Ý->»Ö¸´´®¿Ú->¹Ø±Õ´®¿Ú
2)À¶ÑÀÉ豸
¿ªÆôÀ¶ÑÀ->ÓëgpsÉ豸Á¬½Ó->´ò¿ª´®¿Ú->¶ÁÈ¡Êý¾Ý->¹Ø±Õ´®¿Ú->ÓëgpsÉ豸¶Ï¿ª->¹Ø±ÕÀ¶ÑÀ
3)×¢Òâ
Á¬½ÓgpsÀ¶ÑÀÉ豸ÈçÐèÒªÁ¬½ÓÃÜÂ룬ÉèÖÃΪ0000£¨À¶ÑÀĬÈÏÃÜÂ룩
ÓÃÀ¶ÑÀgpsÉ豸һ°ã²»ÓöԴ®¿Ú½øÐÐÉèÖÃ
Èý¡¢gpsÊý¾Ý¸ñʽ
1.´Ó´®¿ÚÖжÁ³öµÄÊÇÎı¾Êý¾Ý£¬Ã¿´Î¶Á³öÒ»ÐУ¬Ò»°ãÇé¿öÏ£¬Ò»ÃëÖÖÄÜÊÕµ½¶àÐÐÊý¾Ý
2.ÓÐЧÊý¾ÝÒÔ$GP¿ªÍ·£¬·ÖΪ$GPGGA¡¢$GPGSA¡¢$GPGSV¡¢$GPRMC¡
3. $GPGGA ÊÇGPS¶¨Î»µÄÖ÷ÒªÊý¾Ý£¬Í¨¹ý½âÎöËüµÃµ½¾¶È¡¢Î³¶È¡¢º£°Î¸ß¶È¡¢Ê±¼ä¡¢ÎÀÐÇʹÓÃÇé¿öµÈ»ù±¾ÐÅÏ¢£¬ÆäÖÐÿÏîÓöººÅ·Ö¸ô£¬¹²Ê®Ëĸö¶ººÅ£¬¾ÙÀýÈçÏ£º
$GPGGA,064746.000,4925.4895,N,00103.9255,E,1,05,2.1,-68.0,M,47.1,M,,0000*4F
$GPGGA£¨Óï¾ä±êʶͷ£©,064746.000£¨UTCʱ¼ä£©,4925.4895£¨Î³¶È£©,N£¨Î³¶È°ëÇò£©,00103.9255£¨¾¶È£©,E£¨¾¶È°ëÇò£©,1£¨¶¨Î»ÖÊÁ¿Ö¸Ê¾£©,05£¨Ê¹ÓÃÎÀÐÇÊýÁ¿£©,2.1£¨Ë®Æ½¾«È·¶È£©,-68.0£¨º£°Î¸ß¶È£©,M£¨¸ß¶Èµ¥Î»£©,47.1£¨´óµØË®×¼Ãæ¸ß¶È£©,M£¨¸ß¶Èµ¥Î»£©,£¨²î·Ö GPSÊý¾ÝÆÚÏÞ£©,0000£¨²î·Ö²Î¿¼»ùÕ¾±êºÅ£©*4F£¨Ð£Ñ飩£¨½áÊø±ê¼Ç»Ø³µ»»ÐУ©
ËÄ¡¢Àý³Ì
1.¹¦ÄÜÃèÊö
¼ÙÉèÀ¶ÑÀÄ£¿éÓëgpsÒÑÁ¬½Ó³É¹¦£¬À¶ÑÀµÄÐéÄâ´®¿ÚÉ豸ÊÇttyB2
ʵÏÖ´ÓÀ¶ÑÀÉ豸Á¬½Ó¶ÁÈ¡100ÌõÊý¾Ý£¬½âÎöºó(¾¶È/γ¶È/º£°Î/ÎÀÐǸöÊý)ÏÔʾ³öÀ´
2.´úÂë
#include
#include
#include
#include
#include
#include
void parseData(char *buf)
{
int ret, nQ, nN, nB, nC;
char cX, cY, cM1, cM2;
float fTime, fX, fY, fP, fH, fB, fD;
if (buf == NULL)
return;
ret = sscanf(buf,
"$GPGGA,%f,%f,%c,%f,%c,%d,%02d,%f,%f,%c,%f,%c,%f,%04d%02x",
&fTime, &fX, &cX, &fY, &cY, &nQ, &nN, &fP, &fH, &cM1, &fB,
&cM2, &fD, &nB, &nC);
printf("x: %c %f, y: %c %f, h %f, satellite: %d\n",
cX, fX, cY, fY, fH, nN);
}
int main(int argc, char **argv)
{
int fd, i, ret;
char buf[1024] =
"$GPGGA,064746.000,4925.4895,N,00103.99255,E,1,05,2.1,-68.0,M,47.1,M,,0000*4F\r\n"; // ´Ë´¦¸³ÖµÓÃÓÚ²âÊÔ
if ((fd = open("/dev/ttyB2", O_RDWR)) == -1)
return -1;
// set fd: tcsetattr... Ö±½ÓÁ¬½Ó´®¿ÚµÄÉ豸ÐèÒªÔÚ´ËÉèÖò¨ÌØÂÊ
for (i = 0; i < 100; i++)
{
ret = read(fd, buf, 1024);
if (ret > 1)
{
if (strstr(buf, "GPGGA") != NULL)
parseData(buf);
}
}
// restore fd: tcsetattr... Ö±½ÓÁ¬½Ó´®¿ÚµÄÉ豸ÐèÒªÔڴ˻ָ´²¨ÌØÂÊ
close(fd);
}
Îå¡¢Ïà¹Ø×ÊÁÏ
1.GPGGAÏê½â
http://hi.baidu.com/xydjh/blog/item/b0caa1433902ab1073f05dc8.html
2.¿É²Î¿¼µÄ´úÂë
http://bbs.tongji.net/viewthread.php?tid=562733
js001sdx ÓÚ 2010-02-09 10:58:56·¢±í:
0000000 ºÃµÄºÜ£¡£¡
feiyinziiu ÓÚ 2009-11-07 09:02:29·¢±í:
²»´í²»´í¡£
clotfish ÓÚ 2009-11-06 15:17:35·¢±í:
¿ÉÒÔ°¡£¬²»´íµÄ¡£
yxsh01 ÓÚ 2009-11-06 11:14:50·¢±í:
²»¹ýÓõ½µÄ²âÊÔ´úÂëÊǸÉʲôÓõģ¿
yxsh01 ÓÚ 2009-11-06 11:13:48·¢±í:
ºÃ¶«Î÷ ÎÒÕýºÃÒªÓõ½
chambersqj ÓÚ 2009-11-02 20:51:43·¢±í:
ºÜÓÐʵÓüÛÖµ£¡£¡£¡Ö§³Ö
dongch123 ÓÚ 2009-11-02 20:28:29·¢±í:
ºÃÎÄ
wangdonghua ÓÚ 2009-10-28 21:21:04·¢±í:
ÓеãÄѶÈ
js001sdx ÓÚ 2009-10-23 10:31:01·¢±í:
ºÃÎÄ£¡£¡¶¥Æð
js001sdx ÓÚ 2009-10-20 08:37:53·¢±í:
bu cuo !!!