当前位置: 首页>>代码示例>>C++>>正文


C++ Port::Flush方法代码示例

本文整理汇总了C++中Port::Flush方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::Flush方法的具体用法?C++ Port::Flush怎么用?C++ Port::Flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Port的用法示例。


在下文中一共展示了Port::Flush方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

bool
LX::ReceivePacketRetry(Port &port, Command command,
                       void *data, size_t length, OperationEnvironment &env,
                       unsigned first_timeout_ms,
                       unsigned subsequent_timeout_ms,
                       unsigned total_timeout_ms,
                       unsigned n_retries)
{
  assert(n_retries > 0);

  while (true) {
    if (ReceivePacket(port, command, data, length, env,
                      first_timeout_ms, subsequent_timeout_ms,
                      total_timeout_ms))
      return true;

    if (n_retries-- == 0)
      return false;

    if (!CommandMode(port, env))
      return false;

    port.Flush();
  }
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:25,代码来源:Protocol.cpp

示例2: ReadLargeReply

int
CAI302::UploadLarge(Port &port, const char *command,
                    void *response, unsigned max_size,
                    OperationEnvironment &env, unsigned timeout_ms)
{
  port.Flush();
  if (!WriteString(port, command, env))
    return -1;

  int nbytes = ReadLargeReply(port, response, max_size, env, timeout_ms);

  if (nbytes == -2) {
    /* transmission error - try again */

    if (!WriteString(port, command, env))
      return -1;

    nbytes = ReadLargeReply(port, response, max_size, env, timeout_ms);
  }

  if (nbytes < 0)
    return nbytes;

  if (!WaitUploadPrompt(port, env))
    return -1;

  return nbytes;
}
开发者ID:MietekAni,项目名称:XCSoar,代码行数:28,代码来源:Protocol.cpp

示例3: while

static bool
ReadFlightListInner(Port &port, RecordedFlightList &flight_list,
                    OperationEnvironment &env)
{
    if (!LX::CommandMode(port, env))
        return false;

    port.Flush();
    if (!LX::SendCommand(port, LX::READ_FLIGHT_LIST))
        return false;

    bool success = false;
    while (!flight_list.full()) {
        LX::FlightInfo flight;
        if (!LX::ReadCRC(port, &flight, sizeof(flight), env, 20000))
            break;

        success = true;
        if (!flight.IsValid())
            break;

        RecordedFlightInfo dest;
        if (Copy(dest, flight))
            flight_list.append(dest);
    }

    return success;
}
开发者ID:j-konopka,项目名称:XCSoar-TE,代码行数:28,代码来源:Logger.cpp

示例4: assert

bool
LX::ReceivePacketRetry(Port &port, Command command,
                       void *data, size_t length, OperationEnvironment &env,
                       std::chrono::steady_clock::duration first_timeout,
                       std::chrono::steady_clock::duration subsequent_timeout,
                       std::chrono::steady_clock::duration total_timeout,
                       unsigned n_retries)
{
  assert(n_retries > 0);

  while (true) {
    if (ReceivePacket(port, command, data, length, env,
                      first_timeout, subsequent_timeout,
                      total_timeout))
      return true;

    if (n_retries-- == 0)
      return false;

    if (!CommandMode(port, env))
      return false;

    port.Flush();
  }
}
开发者ID:XCSoar,项目名称:XCSoar,代码行数:25,代码来源:Protocol.cpp

示例5: Connect

bool
Volkslogger::ConnectAndFlush(Port &port, OperationEnvironment &env,
                             unsigned timeout_ms)
{
  port.Flush();

  return Connect(port, env, timeout_ms) && port.FullFlush(env, 50, 300);
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:8,代码来源:Protocol.cpp

示例6: SendCommand

bool
LX::ReceivePacket(Port &port, Command command,
                  void *data, size_t length, OperationEnvironment &env,
                  unsigned timeout_ms)
{
  port.Flush();
  return SendCommand(port, command) &&
    ReadCRC(port, data, length, env, timeout_ms);
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:9,代码来源:Protocol.cpp

示例7: WriteString

bool
CAI302::SendCommandQuick(Port &port, const char *cmd,
                         OperationEnvironment &env)
{
  if (!CommandMode(port, env))
    return false;

  port.Flush();
  return WriteString(port, cmd, env);
}
开发者ID:MietekAni,项目名称:XCSoar,代码行数:10,代码来源:Protocol.cpp

示例8: Connect

bool
Volkslogger::ConnectAndFlush(Port &port, OperationEnvironment &env,
                             std::chrono::steady_clock::duration timeout)
{
  port.Flush();

  return Connect(port, env, timeout) &&
    port.FullFlush(env, std::chrono::milliseconds(50),
                   std::chrono::milliseconds(300));
}
开发者ID:XCSoar,项目名称:XCSoar,代码行数:10,代码来源:Protocol.cpp

示例9: SendCommand

bool
LX::ReceivePacket(Port &port, Command command,
                  void *data, size_t length, OperationEnvironment &env,
                  std::chrono::steady_clock::duration first_timeout,
                  std::chrono::steady_clock::duration subsequent_timeout,
                  std::chrono::steady_clock::duration total_timeout)
{
  port.Flush();
  return SendCommand(port, command) &&
    ReadCRC(port, data, length, env,
            first_timeout, subsequent_timeout, total_timeout);
}
开发者ID:XCSoar,项目名称:XCSoar,代码行数:12,代码来源:Protocol.cpp

示例10: sizeof

static bool
DownloadFlightInner(Port &port, const RecordedFlightInfo &flight,
                    FILE *file, OperationEnvironment &env)
{
  if (!LX::CommandMode(port, env))
    return false;

  port.Flush();

  LX::SeekMemory seek;
  seek.start_address = flight.internal.lx.start_address;
  seek.end_address = flight.internal.lx.end_address;
  if (!LX::SendPacket(port, LX::SEEK_MEMORY, &seek, sizeof(seek), env) ||
      !LX::ExpectACK(port, env))
      return false;

  LX::MemorySection memory_section;
  if (!LX::ReceivePacketRetry(port, LX::READ_MEMORY_SECTION,
                              &memory_section, sizeof(memory_section), env,
                              5000, 2000, 60000, 2))
      return false;

  unsigned lengths[LX::MemorySection::N];
  unsigned total_length = 0;
  for (unsigned i = 0; i < LX::MemorySection::N; ++i) {
    lengths[i] = FromBE16(memory_section.lengths[i]);
    total_length += lengths[i];
  }

  env.SetProgressRange(total_length);

  uint8_t *data = new uint8_t[total_length], *p = data;
  for (unsigned i = 0; i < LX::MemorySection::N && lengths[i] > 0; ++i) {
    if (!LX::ReceivePacketRetry(port, (LX::Command)(LX::READ_LOGGER_DATA + i),
                                p, lengths[i], env,
                                20000, 2000, 300000, 2)) {
      delete [] data;
      return false;
    }

    p += lengths[i];
    env.SetProgressPosition(p - data);
  }

  bool success = LX::ConvertLXNToIGC(data, total_length, file);
  delete [] data;

  return success;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:49,代码来源:Logger.cpp

示例11: timeout

static bool
TryConnect(Port &port, char *user_data, size_t max_user_data,
           OperationEnvironment &env)
{
  port.Flush();
  port.Write('\x02');         // send IO Mode command

  unsigned user_size = 0;

  TimeoutClock timeout(8000);

  while (true) {
    int remaining = timeout.GetRemainingSigned();
    if (remaining < 0)
      return false;

    if (port.WaitRead(env, remaining) != Port::WaitResult::READY)
      return false;

    int nbytes = port.Read(user_data + user_size, max_user_data - user_size);
    if (nbytes < 0)
      return false;

    if (user_size == 0) {
      const char *minus = (const char *)memchr(user_data, '-', nbytes);
      if (minus == NULL)
        continue;

      user_size = user_data + nbytes - minus;
      memmove(user_data, minus, user_size);
    } else
      user_size += nbytes;

    char *end = (char *)memchr(user_data, '\x13', user_size);
    if (end != NULL) {
      *end = 0;
      port.Write('\x16');
      return true;
    }

    if (user_size >= max_user_data)
      /* response too large */
      return false;
  }

  return false;
}
开发者ID:XCame,项目名称:XCSoar,代码行数:47,代码来源:EWMicroRecorder.cpp

示例12: ReadShortReply

int
CAI302::UploadShort(Port &port, const char *command,
                    void *response, unsigned max_size,
                    OperationEnvironment &env, unsigned timeout_ms)
{
  port.Flush();
  if (!WriteString(port, command, env))
    return -1;

  int nbytes = ReadShortReply(port, response, max_size, env, timeout_ms);
  if (nbytes < 0)
    return nbytes;

  if (!WaitUploadPrompt(port, env))
    return -1;

  return nbytes;
}
开发者ID:MietekAni,项目名称:XCSoar,代码行数:18,代码来源:Protocol.cpp

示例13: CommandModeQuick

bool
CAI302::CommandMode(Port &port, OperationEnvironment &env)
{
  port.Flush();
  return CommandModeQuick(port) && WaitCommandPrompt(port, env);
}
开发者ID:MietekAni,项目名称:XCSoar,代码行数:6,代码来源:Protocol.cpp


注:本文中的Port::Flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。