示例#1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Writes declaration into the logger.
///
/// @param d           device descriptor to be installed
/// @param lkDecl      LK task declaration data
/// @param errBufSize  error message buffer size
/// @param errBuf[]    [out] error message
///
/// @retval true  declaration has been written successfully
/// @retval false error during declaration (description in @p errBuf)
///
//static
BOOL DevLXNano::DeclareTask(PDeviceDescriptor_t d,
  Declaration_t* lkDecl, unsigned errBufSize, TCHAR errBuf[])
{
  Decl  decl;
  Class lxClass;

  if (!FillFlight(*lkDecl, decl, errBufSize, errBuf))
    return(false);

  if (!FillTask(*lkDecl, decl, errBufSize, errBuf))
    return(false);

  // we will use text-defined class
  decl.flight.cmp_cls = Decl::cls_textdef;
  lxClass.SetName(lkDecl->CompetitionClass);

  // stop RX thread
  if (!StopRxThread(d, errBufSize, errBuf))
    return(false);

  // set new Rx timeout
  int  orgRxTimeout;
  bool status = SetRxTimeout(d, 2000, orgRxTimeout, errBufSize, errBuf);

  if (status)
  {
    ShowProgress(decl_enable);
    status = StartCMDMode(d, errBufSize, errBuf);

    if (status)
    {
      ShowProgress(decl_send);
      status = status && WriteDecl(d, decl, errBufSize, errBuf);
      status = status && WriteClass(d, lxClass, errBufSize, errBuf);
    }

    ShowProgress(decl_disable);
    // always do the following step otherwise NMEA will not be sent
    // (don't overwrite error descr)
    status = StartNMEAMode(d, status ? errBufSize : 0, errBuf) && status;

    // restore Rx timeout (we must try that always; don't overwrite error descr)
    status = SetRxTimeout(d, orgRxTimeout,
      orgRxTimeout, status ? errBufSize : 0, errBuf) && status;
  }

  // restart RX thread (we must try that always; don't overwrite error descr)
  status = StartRxThread(d, status ? errBufSize : 0, errBuf) && status;

  return(status);
} // DeclareTask()
示例#2
0
////////////////////////////////   TASK    /////////////////////////////////////
BOOL DevLXMiniMap::DeclareTaskMinimap(PDeviceDescriptor_t d,
  Declaration_t* lkDecl, unsigned errBufSize, TCHAR errBuf[])
{
  Decl  decl;
  Class lxClass;



  if (!FillFlight(*lkDecl, decl, errBufSize, errBuf))
    return(false);

  if (!FillTask(*lkDecl, decl, errBufSize, errBuf))
    return(false);

  // we will use text-defined class
  decl.flight.cmp_cls = Decl::cls_textdef;
  lxClass.SetName(lkDecl->CompetitionClass);

  // stop RX thread
  if (!StopRxThread(d, errBufSize, errBuf))
    return(false);

  // set new Rx timeout
  int  orgRxTimeout;
  bool status = SetRxTimeout(d, 2000, orgRxTimeout, errBufSize, errBuf);

  if (status)
  {
	  devWriteNMEAString(d,TEXT("PFLX0,COLIBRI") );

	 Sleep(100);


	 d->Com->SetBaudrate(4800);
	 d->Com->SetRxTimeout(2000);

    ShowProgress(decl_enable);
    status = StartCMDMode(d, errBufSize, errBuf);

    if(status == false)
    {
   	  d->Com->SetBaudrate(9600);
   	  d->Com->SetRxTimeout(2000);
      status = StartCMDMode(d, errBufSize, errBuf);
    }
    if(status == false)
    {
   	  d->Com->SetBaudrate(19200);
   	  d->Com->SetRxTimeout(2000);
      status = StartCMDMode(d, errBufSize, errBuf);
    }
    if(status == false)
    {
   	  d->Com->SetBaudrate(38400);
   	  d->Com->SetRxTimeout(2000);
      status = StartCMDMode(d, errBufSize, errBuf);
    }



    if (status)
    {
      ShowProgress(decl_send);
      status = status && WriteDecl(d, decl, errBufSize, errBuf);
      status = status && WriteClass(d, lxClass, errBufSize, errBuf);
    }

    ShowProgress(decl_disable);
    // always do the following step otherwise NMEA will not be sent
    // (don't overwrite error descr)
    status = StartNMEAMode(d, status ? errBufSize : 0, errBuf) && status;


	 d->Com->SetBaudrate(4800);
	 devWriteNMEAString(d,TEXT("PFLX0,LX160") );

	 d->Com->SetBaudrate(38400);


    // restore Rx timeout (we must try that always; don't overwrite error descr)
    status = SetRxTimeout(d, orgRxTimeout,
      orgRxTimeout, status ? errBufSize : 0, errBuf) && status;
  }

  // restart RX thread (we must try that always; don't overwrite error descr)
  status = StartRxThread(d, status ? errBufSize : 0, errBuf) && status;

  return(status);
}