コード例 #1
0
ファイル: devLX16xx.cpp プロジェクト: Acrobot/LK8000
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// 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 DevLX16xx::ParseNMEA(PDeviceDescriptor_t d, TCHAR* sentence, NMEA_INFO* info)
{
  static int i=40;

  if (_tcsncmp(_T("$LXWP2"), sentence, 6) == 0)
  {
	if(iLX16xx_RxUpdateTime > 0)
	{
	  iLX16xx_RxUpdateTime--;
	}
	else
	{
	  if(fabs(oldMC - MACCREADY)> 0.005f)
	  {
		LX16xxPutMacCready( d,  MACCREADY);
		oldMC = MACCREADY;
		MacCreadyUpdateTimeout = 2;
      }
	}
  }

  /* configure LX after 30 GPS positions */
  if (_tcsncmp(_T("$GPGGA"), sentence, 6) == 0)
  {
    if(i++ > 10)
    {
      SetupLX_Sentence(d);
	  i=0;
    }
  }

  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()
コード例 #2
0
ファイル: devLXV7easy.cpp プロジェクト: IvanSantanna/LK8000
BOOL LXV7easyParseNMEA(PDeviceDescriptor_t d, TCHAR* sentence, NMEA_INFO* info)
{

    if (!NMEAParser::NMEAChecksum(sentence) || (info == NULL)) {
        return FALSE;
    }

    //
    // We ignore the followings
    //
    if (_tcsncmp(_T("$PLXV0"), sentence, 6) == 0) {
	return TRUE;
    }
    if (_tcsncmp(_T("$LXWP0"), sentence, 6) == 0) {
	return TRUE;
    }
    if (_tcsncmp(_T("$LXWP2"), sentence, 6) == 0) {
	return TRUE;
    }
    if (_tcsncmp(_T("$LXWP3"), sentence, 6) == 0) {
	return TRUE;
    }
    if (_tcsncmp(_T("$LXWP4"), sentence, 6) == 0) {
	return TRUE;
    }
    if (_tcsncmp(_T("$LXWP5"), sentence, 6) == 0) {
	return TRUE;
    }

    //
    // We manage the followings
    //
    if (_tcsncmp(_T("$PLXVF"), sentence, 6) == 0)
        return PLXVF(d, sentence + 7, info);

    if (_tcsncmp(_T("$PLXVS"), sentence, 6) == 0)
        return PLXVS(d, sentence + 7, info);

    if (_tcsncmp(_T("$LXWP1"), sentence, 6) == 0)
        return LXWP1(d, sentence + 7, info);


    return(FALSE);
}
コード例 #3
0
ファイル: devLXMiniMap.cpp プロジェクト: IvanSantanna/LK8000
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// 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 DevLXMiniMap::ParseNMEA(PDeviceDescriptor_t d, TCHAR* sentence, NMEA_INFO* info)
{

  if (!NMEAParser::NMEAChecksum(sentence) || (info == NULL)){
    return FALSE;
  }

  if (_tcsncmp(_T("$GPGGA"), sentence, 6) == 0)
	   LXMiniMapOnSysTicker(d);
  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);

  return(false);
} // ParseNMEA()
コード例 #4
0
ファイル: Parser.cpp プロジェクト: kwtskran/XCSoar
/**
 * Parse the $PLXVC sentence (LXNAV Nano).
 *
 * $PLXVC,<key>,<type>,<values>*<checksum><cr><lf>
 */
static void
PLXVC(NMEAInputLine &line, DeviceInfo &device,
      DeviceInfo &secondary_device,
      DeviceSettingsMap<std::string> &settings)
{
  char key[64];
  line.Read(key, ARRAY_SIZE(key));

  char type[2];
  line.Read(type, ARRAY_SIZE(type));
  if (StringIsEqual(key, "SET") && type[0] == 'A') {
    char name[64];
    line.Read(name, ARRAY_SIZE(name));

    const auto value = line.Rest();
    if (!StringIsEmpty(name)) {
      settings.Lock();
      settings.Set(name, std::string(value.begin(), value.end()));
      settings.Unlock();
    }
  } else if (StringIsEqual(key, "INFO") && type[0] == 'A') {
    ParseNanoInfo(line, device);
  } else if (StringIsEqual(key, "GPSINFO") && type[0] == 'A') {
    /* the LXNAV V7 (firmware >= 2.01) forwards the Nano's INFO
       sentence with the "GPS" prefix */

    char name[64];
    line.Read(name, ARRAY_SIZE(name));

    if (StringIsEqual(name, "LXWP1")) {
      LXWP1(line, secondary_device);
    } else if (StringIsEqual(name, "INFO")) {
      line.Read(type, ARRAY_SIZE(type));
      if (type[0] == 'A')
        ParseNanoInfo(line, secondary_device);
    }
  }
}
コード例 #5
0
ファイル: Parser.cpp プロジェクト: kwtskran/XCSoar
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;
}
コード例 #6
0
ファイル: devLXV7.cpp プロジェクト: Mazuk/LK8000
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// 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()