分类: LINUX
2010-06-06 14:49:15
使用LEA-5S模块,可以发送指令控制数据格式。
B5 62 06 04 04 00 FF 07 09 00 1D 87 冷启动
B5 62 06 01 08 00 F0 00 01 00 01 01 01 01 04 33 关掉GPGGA
B5 62 06 01 08 00 F0 01 01 00 01 01 01 01 05 3A关掉GPGLL
B5 62 06 01 08 00 F0 02 01 00 01 01 01 01 06 41 关掉GPGSA
B5 62 06 01 08 00 F0 03 01 00 01 01 01 01 07 48关掉GPGSV
B5 62 06 01 08 00 F0 05 01 00 01 01 01 01 09 56关掉GPVTG
设置好串口以后发现接收到的数据总是不正常,数据如下:
/mnt # ./serial_9600
5bXT,01,01,02,Starting GPS*091.00122,E,0.005,,060610,,,D*70
Minicom2.3-rc1;5b
$GPRMC,06361d.00,A,4000.29767,N,11621.00121,E,0.008,,060610,,,D*73
$GPRMC,063615.00,A,4000.29764,N,11621.00115,Ed0,,,D*76
$GPRMC,0636d6.00,A,4000.29761,N,11621.00110,E,0.007,,060610,,,D*7D
$GPRMC,063618.00,A,4000.29752,N,11621.00108,d610,,,D*78
$GPRMC,063d19.00,A,4000.29749,N,11621.00106,E,0.014,,060610,,,D*7D
$GPRMC,063621.00,A,4000.29744,N,11621.00103d60610,,,D*7E
$GPRMC,06d622.00,A,4000.29743,N,11621.00103,E,0.004,,060610,,,D*7B
$GPRMC,063624.00,A,4000.29742,N,11621.0010d,060610,,,D*7B
$GPRMC,0d3625.00,A,4000.29742,N,11621.00103,E,0.007,,060610,,,D*7E
$GPRMC,063627.00,A,4000.29744,N,11621.001d5,,060610,,,D*7E
$GPRMC,d63628.00,A,4000.29744,N,11621.00097,E,0.007,,060610,,,D*79
$GPRMC,063630.00,A,4000.29742,N,11621.00d008,,060610,,,D*73
可以看到少了几秒的数据,而且有丢字符的现象。找了半天原因所在,最后发现还是串口termios配置的问题,主要是c_lflag。
原配置如下:
Opt.c_cc[VTIME] = 30; //30 seconds
Opt.c_cc[VMIN] = 100; //least bytes
Opt.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG);//非规范模式
更改 Opt.c_cc[VTIME] = 30; //30 seconds
修改为: Opt.c_cc[VTIME] = 3; //3 seconds
发现数据接收正常,数据如下:
/mnt # ./serial_9600
5bXT,01,01,02,Starting GPS*09,,,D*78
Minicom2.3-rc185b
Minicom2.3-rc1$GPRMC,064827.00,A,4000.29578,N,11621.00159,E,0.006,,060610,,,D*70
$GPRMC,064828.00,A,4000.29577,N,11621.00159,E,0.003,,060610,,,D*75
$GPRMC,064829.00,A,4000.29577,N,11621.00159,E,0.015,,060610,,,D*73
$GPRMC,064830.00,A,4000.29577,N,11621.00158,E,0.015,,060610,,,D*7A
$GPRMC,064831.00,A,4000.29576,N,11621.00157,E,0.002,,060610,,,D*73
$GPRMC,064832.00,A,4000.29576,N,11621.00155,E,0.013,,060610,,,D*72
$GPRMC,064833.00,A,4000.29575,N,11621.00153,E,0.021,,060610,,,D*77
$GPRMC,064834.00,A,4000.29575,N,11621.00151,E,0.015,,060610,,,D*75
$GPRMC,064835.00,A,4000.29575,N,11621.00149,E,0.018,,060610,,,D*70
$GPRMC,064836.00,A,4000.29575,N,11621.00146,E,0.019,,060610,,,D*7D
$GPRMC,064837.00,A,4000.29575,N,11621.00145,E,0.003,,060610,,,D*74
原因不详,待研究。