Beispiel #1
0
bool
LXDevice::DownloadFlight(const RecordedFlightInfo &flight,
                         const TCHAR *path,
                         OperationEnvironment &env)
{
    if (flight.internal.lx.nano_filename[0] != 0) {
        assert(!busy);
        busy = true;

        bool success = Nano::DownloadFlight(port, flight, path, env);
        busy = false;
        return success;
    }

    if (!EnableCommandMode(env))
        return false;

    FILE *file = _tfopen(path, _T("wb"));
    if (file == NULL)
        return false;

    assert(!busy);
    busy = true;

    bool success = DownloadFlightInner(port, flight, file, env);
    fclose(file);

    LX::CommandModeQuick(port, env);

    busy = false;

    return success;
}
Beispiel #2
0
bool
LXDevice::ReadFlightList(RecordedFlightList &flight_list,
                         OperationEnvironment &env)
{
    if (IsNano()) {
        if (!EnableNanoNMEA(env))
            return false;

        assert(!busy);
        busy = true;

        bool success = Nano::ReadFlightList(port, flight_list, env);
        busy = false;
        return success;
    }

    if (!EnableCommandMode(env))
        return false;

    assert(!busy);
    busy = true;

    bool success = ReadFlightListInner(port, flight_list, env);

    LX::CommandModeQuick(port, env);

    busy = false;

    return success;
}
Beispiel #3
0
bool
LXDevice::Declare(const Declaration &declaration,
                  gcc_unused const Waypoint *home,
                  OperationEnvironment &env)
{
  if (declaration.Size() < 2 || declaration.Size() > 12)
    return false;

  if (!EnableCommandMode(env))
    return false;

  unsigned old_baud_rate = 0;
  if (bulk_baud_rate != 0) {
    old_baud_rate = port.GetBaudrate();
    if (old_baud_rate == bulk_baud_rate)
      old_baud_rate = 0;
    else if (!port.SetBaudrate(bulk_baud_rate))
      return false;
  }

  bool success = DeclareInner(port, declaration, env);

  LX::CommandModeQuick(port, env);

  return success;
}
Beispiel #4
0
bool
LXDevice::DownloadFlight(const RecordedFlightInfo &flight,
                         const TCHAR *path,
                         OperationEnvironment &env)
{
  if (!EnableCommandMode(env))
    return false;

  FILE *file = _tfopen(path, _T("wb"));
  if (file == NULL)
    return false;

  assert(!busy);
  mutex.Lock();
  busy = true;
  mutex.Unlock();

  bool success = DownloadFlightInner(port, flight, file, env);
  fclose(file);

  LX::CommandModeQuick(port, env);

  mutex.Lock();
  busy = false;
  mutex.Unlock();

  return success;
}
Beispiel #5
0
bool
LXDevice::Declare(const Declaration &declaration,
                  gcc_unused const Waypoint *home,
                  OperationEnvironment &env)
{
  if (declaration.Size() < 2 || declaration.Size() > 12)
    return false;

  if (!EnableCommandMode(env))
    return false;

  bool success = DeclareInner(port, declaration, env);

  LX::CommandModeQuick(port, env);

  return success;
}
Beispiel #6
0
bool
LXDevice::ReadFlightList(RecordedFlightList &flight_list,
                         OperationEnvironment &env)
{
  if (!EnableCommandMode(env))
    return false;

  assert(!busy);
  mutex.Lock();
  busy = true;
  mutex.Unlock();

  bool success = ReadFlightListInner(port, flight_list, env);

  LX::CommandModeQuick(port, env);

  mutex.Lock();
  busy = false;
  mutex.Unlock();

  return success;
}