bool LXDevice::ParseNMEA(const char *String, NMEAInfo &info) { if (!VerifyNMEAChecksum(String)) return false; NMEAInputLine line(String); char type[16]; line.Read(type, 16); if (StringIsEqual(type, "$LXWP0")) return LXWP0(line, info); if (StringIsEqual(type, "$LXWP1")) { /* if in pass-through mode, assume that this line was sent by the secondary device */ DeviceInfo &device_info = mode == Mode::PASS_THROUGH ? info.secondary_device : info.device; LXWP1(line, device_info); const bool saw_v7 = device_info.product.equals("V7"); const bool saw_nano = device_info.product.equals("NANO"); const bool saw_lx16xx = device_info.product.equals("1606") || device_info.product.equals("1600"); if (mode == Mode::PASS_THROUGH) { /* in pass-through mode, we should never clear the V7 flag, because the V7 is still there, even though it's "hidden" currently */ is_v7 |= saw_v7; is_nano |= saw_nano; is_lx16xx |= saw_lx16xx; is_forwarded_nano = saw_nano; } else { is_v7 = saw_v7; is_nano = saw_nano; is_lx16xx = saw_lx16xx; } if (saw_v7 || saw_nano || saw_lx16xx) is_colibri = false; return true; } if (StringIsEqual(type, "$LXWP2")) return LXWP2(line, info); if (StringIsEqual(type, "$LXWP3")) return LXWP3(line, info); if (StringIsEqual(type, "$PLXV0")) { is_v7 = true; is_colibri = false; return PLXV0(line, v7_settings); } if (StringIsEqual(type, "$PLXVC")) { is_nano = true; is_colibri = false; PLXVC(line, info.device, info.secondary_device, nano_settings); is_forwarded_nano = info.secondary_device.product.equals("NANO"); return true; } if (StringIsEqual(type, "$PLXVF")) { is_v7 = true; is_colibri = false; return PLXVF(line, info); } if (StringIsEqual(type, "$PLXVS")) { is_v7 = true; is_colibri = false; return PLXVS(line, info); } return false; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Parses LXWPn sentences. /// /// @param d device descriptor /// @param sentence received NMEA sentence /// @param info GPS info to be updated /// /// @retval true if the sentence has been parsed /// //static BOOL DevLXV7::ParseNMEA(PDeviceDescriptor_t d, TCHAR* sentence, NMEA_INFO* info) { static int i=40; TCHAR szTmp[256]; if (_tcsncmp(_T("$LXWP2"), sentence, 6) == 0) { if(iLXV7_RxUpdateTime > 0) { iLXV7_RxUpdateTime--; } else { if(fabs(LXV7_oldMC - MACCREADY)> 0.005f) { LXV7PutMacCready( d, MACCREADY); LXV7_oldMC = MACCREADY; LXV7_MacCreadyUpdateTimeout = 2; } } } /* configure LX after 10 GPS positions */ if (_tcsncmp(_T("$GPGGA"), sentence, 6) == 0) { if(i++ > 4) { SetupLX_Sentence(d); i=0; } } static int oldQFEOff =0; static int iOldQNH =0; int iQNH = (int)(QNH*100.0); if(iQNH != iOldQNH) { iOldQNH = iQNH; _stprintf(szTmp, TEXT("$PLXV0,QNH,W,%i"),(int)iQNH); LXV7NMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); } int QFE = (int)QFEAltitudeOffset; if(QFE != oldQFEOff) { oldQFEOff = QFE; _stprintf(szTmp, TEXT("$PLXV0,ELEVATION,W,%i"),(int)(QFEAltitudeOffset)); LXV7NMEAddCheckSumStrg(szTmp); // d->Com->WriteString(szTmp); } if(LXV7_iGPSBaudrate ==0) { _stprintf(szTmp, TEXT("$PLXV0,BRGPS,R")); LXV7NMEAddCheckSumStrg(szTmp); d->Com->WriteString(szTmp); } if (_tcsncmp(_T("$PLXVF"), sentence, 6) == 0) return PLXVF(d, sentence + 7, info); else if (_tcsncmp(_T("$PLXVS"), sentence, 6) == 0) return PLXVS(d, sentence + 7, info); else if (_tcsncmp(_T("$PLXV0"), sentence, 6) == 0) return PLXV0(d, sentence + 7, info); else if (_tcsncmp(_T("$LXWP0"), sentence, 6) == 0) return LXWP0(d, sentence + 7, info); else if (_tcsncmp(_T("$LXWP1"), sentence, 6) == 0) return LXWP1(d, sentence + 7, info); else if (_tcsncmp(_T("$LXWP2"), sentence, 6) == 0) return LXWP2(d, sentence + 7, info); else if (_tcsncmp(_T("$LXWP3"), sentence, 6) == 0) return LXWP3(d, sentence + 7, info); else if (_tcsncmp(_T("$LXWP4"), sentence, 6) == 0) return LXWP4(d, sentence + 7, info); return(false); } // ParseNMEA()