1、gga处理优化,支持d300和b562混合的情况

This commit is contained in:
weidong 2024-05-17 09:32:06 +08:00
parent cf1fe75183
commit 63a3499444

View File

@ -38,19 +38,11 @@ public class Gga {
public Gga() { public Gga() {
} }
static public Gga getFrom(ByteBuf data){ public static Gga getFrom(ByteBuf data){
int msgFlag = data.getUnsignedShort(0); int msgFlag = data.getUnsignedShort(0);
if(msgFlag == 0xD341){ if(msgFlag != 0xD341 && msgFlag != 0xD331){
return getFromD341(data); return null;
} }
else if(msgFlag == 0xD331){
return getFromD331(data);
}
else return null;
}
static Gga getFromD331(ByteBuf data){
int pos = 26; // 从惯导之后开始 int pos = 26; // 从惯导之后开始
boolean found = false; boolean found = false;
while(pos<data.readableBytes()){ while(pos<data.readableBytes()){
@ -65,29 +57,14 @@ public class Gga {
pos += 26; pos += 26;
} }
else { else {
pos++; // +----------+----------+----------+
pos += data.getUnsignedShort(pos) + 5;//length+payload+crc // | d3 | 6bit | 10bits |
} // +----------+----------+----------+
} // d3 xx payload len(10bits)
else{
break;
}
}
if(found){
return getFromGGAString(data, pos);
}
else return null;
}
static Gga getFromD341(ByteBuf data){ pos++;
int pos = 26; // 从惯导之后开始 pos += ((data.getUnsignedShort(pos)&0x03FF) + 5);//length(2byte)+payload+crc(3byte)
boolean found = false; }
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;
} }
else if(b562_flag[0] == d0 && b562_flag[1] == d1){ else if(b562_flag[0] == d0 && b562_flag[1] == d1){
pos += 4; // type, class id pos += 4; // type, class id