优化GGA的判断

This commit is contained in:
weidong 2024-10-18 18:30:00 +08:00
parent 3df63d6410
commit d0db10a822

View File

@ -9,7 +9,7 @@ import java.nio.charset.Charset;
public class Gga {
public static int FIX_RESULT = 4;
public static int FLOAT_RESULT = 5;
final static byte[] GGA_FLAG = {'$', 'G'};//$xxGGA
final static byte[] GGA_FLAG = {'$', 'X', 'X', 'G', 'G', 'A'};//$xxGGA
final static byte[] d331_flag = {(byte) 0xd3, (byte)0x31};
final static byte rtcm_flag = (byte)0xd3;
@ -50,9 +50,14 @@ public class Gga {
while(pos<data.readableBytes()){
byte d0 = data.getByte(pos);
byte d1 = data.getByte(pos+1);
if(GGA_FLAG[0] == d0 && GGA_FLAG[1] == d1){
found = true;
break;
if(GGA_FLAG[0] == d0){
if(data.readableBytes()>5 &&
data.getByte(pos+3) == GGA_FLAG[3] &&
data.getByte(pos+4) == GGA_FLAG[4] &&
data.getByte(pos+5) == GGA_FLAG[5]) {
found = true;
break;
}
}
else if(d0 == rtcm_flag){
if(d1 == 0x31) { // d331粘包