本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例13: CommandModeQuick
bool
CAI302::CommandMode(Port &port, OperationEnvironment &env)
{
port.Flush();
return CommandModeQuick(port) && WaitCommandPrompt(port, env);
}