GPS FIX数据,从com端口读取

时间:2011-06-30 10:08:11

标签: java gps serial-port javax.comm

我正在创建一个非常简单的应用程序来读取java中的GPS信息。信息以NMEA0183格式在COM1上发送。

一切都很好,只是因为RMC和GGA句子是空的,我找不到我的位置。我收到了卫星信息和定位的其他句子,但我想要的只是我当前的位置(长/纬)。当我检查超级终端中的数据时,数据即将到来。

以下是我目前收到的一些例子:

$GPGGA,,,,,,0,00,,,M,,M,,*66
$GPVTG,0.0,T,,,000.0,N,000.0,K,A*40
$GPGSA,M,1,,,,,,,,,,,,,-1.0,-1.0,-1.0*10
$GPGGA,,,,,,0,00,,,M,,M,,*66
$GPVTG,0.0,T,,,000.0,N,000.0,K,A*40
$GPGSV,2,1,08,03,00,000,,06,00,000,,11,00,000,,14,00,000,*72
$GPGSV,2,2,08,19,00,000,,20,00,000,,22,00,000,,24,00,000,*7D
$GPGSA,M,1,,,,,,,,,,,,,-1.0,-1.0,-1.0*10
$GPGGA,,,,,,0,00,,,M,,M,,*66
$GPVTG,0.0,T,,,000.0,N,000.0,K,A*40
$GPGSV,3,1,12,03,21,351,,06,13,004,,11,55,235,,14,47,126,*78
$GPGSV,3,2,12,19,49,331,,20,19,272,,22,24,115,,24,41,227,*75
$GPGSV,3,3,12,31,16,048,,32,43,267,,09,00,160,,12,00,129,*71
$GPGSA,M,1,,,,,,,,,,,,,-1.0,-1.0,-1.0*10
$GPGGA,,,,,,0,00,,,M,,M,,*66
$GPVTG,0.0,T,,,000.0,N,000.0,K,A*40
$GPGSV,3,1,12,03,21,351,,06,13,004,,11,55,235,,14,47,126,*78
$GPGSV,3,2,12,19,49,331,,20,19,272,,22,24,115,,24,41,227,*75
$GPGSV,3,3,12,31,16,048,,32,43,267,,09,00,160,,12,00,129,*71
$GPGSA,M,1,,,,,,,,,,,,,-1.0,-1.0,-1.0*10
$GPGGA,,,,,,0,00,,,M,,M,,*66
$GPVTG,0.0,T,,,000.0,N,000.0,K,A*40
$GPGSV,3,1,12,03,21,351,,06,12,004,,11,55,235,,14,47,126,*79
$GPGSV,3,2,12,19,49,331,,20,19,272,,22,24,115,,24,41,227,*75
$GPGSV,3,3,12,31,16,048,,32,43,267,,09,00,160,,12,00,129,*71
$GPGSA,M,1,,,,,,,,,,,,,-1.0,-1.0,-1.0*10

我还有一个问题是检查GPS设备是否已连接到计算机。我正在使用rxtxcomm.jar进行com端口读取。

打开com端口的代码如下

CommPortIdentifier port_id = CommPortIdentifier.getPortIdentifier(serial_port_name_);
serial_port = (SerialPort)port_id.open("Gps",2000);
serial_port.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
serial_port_.setSerialPortParams(speed,
                             SerialPort.DATABITS_8,
                             SerialPort.STOPBITS_1,
                             SerialPort.PARITY_NONE);

1 个答案:

答案 0 :(得分:0)

根据GSV句子,您没有来自列表中任何卫星的信号(所有卫星的信噪比字段都是空的)。在获得信号强度之前,您不会获得位置信息。 GPS接收器需要在理想的范围之外,但如果你把它放在窗户旁边它可能会起作用。