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


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

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


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

示例1: WriteLabel

/**
 * Write a name/value pair to the EW microRecorder.
 */
static bool
WritePair(Port &port, const char *name, const TCHAR *value)
{
    return WriteLabel(port, name) &&
           WriteCleanString(port, value, 1000) &&
           port.FullWrite("\r\n", 2, 500);
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:10,代码来源:EWMicroRecorder.cpp

示例2: WriteLabel

/**
 * Write a name/value pair to the EW microRecorder.
 */
static bool
WritePair(Port &port, const char *name, const TCHAR *value,
          OperationEnvironment &env)
{
  return WriteLabel(port, name, env) &&
    WriteCleanString(port, value, env, 1000) &&
    port.FullWrite("\r\n", 2, env, 500);
}
开发者ID:XCame,项目名称:XCSoar,代码行数:11,代码来源:EWMicroRecorder.cpp

示例3: assert

bool
PortWriteNMEA(Port &port, const char *line, OperationEnvironment &env)
{
  assert(line != nullptr);

  /* reasonable hard-coded timeout; do we need to make this a
     parameter? */
  const unsigned timeout_ms = 1000;

  if (!port.Write('$') ||
      !port.FullWrite(line, strlen(line), env, timeout_ms))
    return false;

  char checksum[16];
  sprintf(checksum, "*%02X\r\n", NMEAChecksum(line));
  return port.FullWrite(checksum, strlen(checksum), env, timeout_ms);
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:17,代码来源:NMEAWriter.cpp

示例4: SendCommand

bool
LX::SendPacket(Port &port, Command command,
               const void *data, size_t length,
               OperationEnvironment &env, unsigned timeout_ms)
{
  return SendCommand(port, command) &&
    port.FullWrite(data, length, env, timeout_ms) &&
    port.Write(calc_crc(data, length, 0xff));
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:9,代码来源:Protocol.cpp

示例5: strlen

static void
PortWriteNMEANoChecksum(Port &port, const char *line,
                        OperationEnvironment &env)
{
  // reasonable hard-coded timeout; Copied from ::PortWriteNMEA()
  const unsigned timeout_ms = 1000;

  port.FullWrite(line, strlen(line), env, timeout_ms);
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:9,代码来源:CaiLNav.cpp

示例6: strlen

static void
PortWriteNMEANoChecksum(Port &port, const char *line,
                        OperationEnvironment &env)
{
  // reasonable hard-coded timeout; Copied from ::PortWriteNMEA()
  constexpr auto timeout = std::chrono::seconds(1);

  port.FullWrite(line, strlen(line), env, timeout);
}
开发者ID:XCSoar,项目名称:XCSoar,代码行数:9,代码来源:CaiLNav.cpp

示例7: SendCommand

bool
LX::SendPacket(Port &port, Command command,
               const void *data, size_t length,
               OperationEnvironment &env,
               std::chrono::steady_clock::duration timeout)
{
  return SendCommand(port, command) &&
    port.FullWrite(data, length, env, timeout) &&
    port.Write(calc_crc(data, length, 0xff));
}
开发者ID:XCSoar,项目名称:XCSoar,代码行数:10,代码来源:Protocol.cpp

示例8:

static bool
SendWithCRC(Port &port, const void *data, size_t length,
            OperationEnvironment &env)
{
  if (!port.FullWrite(data, length, env, 2000))
    return false;

  uint16_t crc16 = UpdateCRC16CCITT(data, length, 0);
  return port.Write(crc16 >> 8) && port.Write(crc16 & 0xff);
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:10,代码来源:Protocol.cpp

示例9: timeout

bool
FLARM::SendEscaped(Port &port, const void *buffer, size_t length,
                   OperationEnvironment &env, unsigned timeout_ms)
{
  assert(buffer != nullptr);
  assert(length > 0);

  const TimeoutClock timeout(timeout_ms);

  // Send data byte-by-byte including escaping
  const uint8_t *p = (const uint8_t *)buffer, *end = p + length;
  while (true) {
    const uint8_t *special = FindSpecial(p, end);

    if (special > p) {
      /* bulk write of "harmless" characters */

      if (!port.FullWrite(p, special - p, env, timeout.GetRemainingOrZero()))
        return false;

      p = special;
    }

    if (p == end)
      break;

    // Check for bytes that need to be escaped and send
    // the appropriate replacements
    bool result;
    if (*p == START_FRAME)
      result = port.Write(ESCAPE) && port.Write(ESCAPE_START);
    else if (*p == ESCAPE)
      result = port.Write(ESCAPE) && port.Write(ESCAPE_ESCAPE);
    else
      // Otherwise just send the original byte
      result = port.Write(*p);

    if (!result)
      return false;

    p++;
  }

  return true;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:45,代码来源:BinaryProtocol.cpp

示例10:

static bool
WriteLabel(Port &port, const char *name)
{
    return port.FullWriteString(name, 1000) &&
           port.FullWrite(": ", 2, 500);
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:6,代码来源:EWMicroRecorder.cpp

示例11: args

int
main(int argc, char **argv)
{
  Args args(argc, argv, "PORT BAUD");
  const DeviceConfig config = ParsePortArgs(args);
  args.ExpectEnd();

  InitialiseIOThread();

  MyHandler handler;
  Port *port = OpenPort(config, handler);
  if (port == NULL) {
    fprintf(stderr, "Failed to open COM port\n");
    return EXIT_FAILURE;
  }

  ConsoleOperationEnvironment env;

  if (!port->WaitConnected(env)) {
    delete port;
    DeinitialiseIOThread();
    fprintf(stderr, "Failed to connect the port\n");
    return EXIT_FAILURE;
  }

  if (!port->StartRxThread()) {
    delete port;
    DeinitialiseIOThread();
    fprintf(stderr, "Failed to start the port thread\n");
    return EXIT_FAILURE;
  }

  unsigned long last_stamp = -1;
  char line[1024];
  while (fgets(line, sizeof(line), stdin) != NULL) {
    char *endptr;
    unsigned long current_stamp = strtoul(line, &endptr, 10);
    if (endptr == line || *endptr != ' ' || endptr[1] != '<')
      continue;

    char *start = endptr + 2;
    char *end = strchr(start, '>');
    if (end == NULL)
      continue;

    *end++ = '\n';
    *end = 0;

    if (current_stamp > last_stamp) {
      unsigned long delta_t = std::min(current_stamp - last_stamp, 1000ul);
      Sleep(delta_t);
    }

    last_stamp = current_stamp;

    if (!port->FullWrite(start, end - start, env, 1000)) {
      fprintf(stderr, "Failed to write to port\n");
      delete port;
      return EXIT_FAILURE;

    }
  }

  delete port;
  DeinitialiseIOThread();
  return EXIT_SUCCESS;
}
开发者ID:j-konopka,项目名称:XCSoar-TE,代码行数:67,代码来源:FeedVega.cpp

示例12:

static bool
WriteLabel(Port &port, const char *name, OperationEnvironment &env)
{
  return port.FullWriteString(name, env, 1000) &&
    port.FullWrite(": ", 2, env, 500);
}
开发者ID:XCame,项目名称:XCSoar,代码行数:6,代码来源:EWMicroRecorder.cpp

示例13: strlen

bool
CAI302::WriteString(Port &port, const char *p, OperationEnvironment &env)
{
  size_t length = strlen(p);
  return port.FullWrite(p, length, env, 2000);
}
开发者ID:MietekAni,项目名称:XCSoar,代码行数:6,代码来源:Protocol.cpp

示例14:

bool
IMI::Send(Port &port, const TMsg &msg)
{
  return port.FullWrite(&msg, IMICOMM_MSG_HEADER_SIZE + msg.payloadSize + 2, 2000);
}
开发者ID:joachimwieland,项目名称:xcsoar-jwieland,代码行数:5,代码来源:Communication.cpp

示例15: Send

 bool Send(Port &port, OperationEnvironment &env) {
   data[fill++] = checksum;
   return port.FullWrite(data, fill, env, 2000);
 }
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:4,代码来源:ATR833.cpp


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