本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例10:
static bool
WriteLabel(Port &port, const char *name)
{
return port.FullWriteString(name, 1000) &&
port.FullWrite(": ", 2, 500);
}
示例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;
}
示例12:
static bool
WriteLabel(Port &port, const char *name, OperationEnvironment &env)
{
return port.FullWriteString(name, env, 1000) &&
port.FullWrite(": ", 2, env, 500);
}
示例13: strlen
bool
CAI302::WriteString(Port &port, const char *p, OperationEnvironment &env)
{
size_t length = strlen(p);
return port.FullWrite(p, length, env, 2000);
}
示例14:
bool
IMI::Send(Port &port, const TMsg &msg)
{
return port.FullWrite(&msg, IMICOMM_MSG_HEADER_SIZE + msg.payloadSize + 2, 2000);
}
示例15: Send
bool Send(Port &port, OperationEnvironment &env) {
data[fill++] = checksum;
return port.FullWrite(data, fill, env, 2000);
}