本文整理汇总了C++中Port::FullFlush方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::FullFlush方法的具体用法?C++ Port::FullFlush怎么用?C++ Port::FullFlush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::FullFlush方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
Volkslogger::SendCommand(Port &port, OperationEnvironment &env,
Command cmd, uint8_t param1, uint8_t param2)
{
static constexpr unsigned delay = 2;
/* flush buffers */
if (!port.FullFlush(env, 20, 100))
return false;
/* reset command interpreter */
if (!Reset(port, env, 6))
return false;
/* send command packet */
const uint8_t cmdarray[8] = {
(uint8_t)cmd, param1, param2,
0, 0, 0, 0, 0,
};
if (!port.Write(ENQ))
return false;
env.Sleep(delay);
if (!SendWithCRC(port, cmdarray, sizeof(cmdarray), env))
return false;
/* wait for confirmation */
return port.WaitRead(env, 4000) == Port::WaitResult::READY &&
port.GetChar() == 0;
}
示例2:
bool
LX::CommandMode(Port &port, OperationEnvironment &env)
{
/* switch to command mode, first attempt */
if (!SendSYN(port) || !port.FullFlush(env, 50, 200))
return false;
/* the port is clean now; try the SYN/ACK procedure up to three
times */
for (unsigned i = 0; i < 100 && !env.IsCancelled(); ++i)
if (Connect(port, env))
/* make sure all remaining ACKs are flushed */
return port.FullFlush(env, 200, 500);
return false;
}
示例3: Connect
bool
Volkslogger::ConnectAndFlush(Port &port, OperationEnvironment &env,
unsigned timeout_ms)
{
port.Flush();
return Connect(port, env, timeout_ms) && port.FullFlush(env, 50, 300);
}
示例4: 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));
}
示例5: Connect
bool
LX::CommandMode(Port &port, OperationEnvironment &env)
{
/* switch to command mode, first attempt */
port.Write(SYN);
/* now flush all of the remaining input */
port.SetRxTimeout(10);
port.FullFlush(20);
/* the port is clean now; try the SYN/ACK procedure up to three
times */
return port.SetRxTimeout(500) &&
(Connect(port, env) || Connect(port, env) || Connect(port, env)) &&
/* ... and configure the timeout */
port.SetRxTimeout(5000);
}
示例6: reader
static bool
DownloadFlightInner(Port &port, const char *filename, FILE *file,
OperationEnvironment &env)
{
PortNMEAReader reader(port, env);
unsigned row_count = 0, i = 1;
while (true) {
/* read up to 32 lines at a time */
unsigned nrequest = row_count == 0 ? 1 : 32;
if (row_count > 0) {
assert(i <= row_count);
const unsigned remaining = row_count - i + 1;
if (nrequest > remaining)
nrequest = remaining;
}
const unsigned start = i;
const unsigned end = start + nrequest;
unsigned request_retry_count = 0;
/* read the requested lines and save to file */
while (i != end) {
if (i == start) {
/* send request range to Nano */
reader.Flush();
if (!RequestFlight(port, filename, start, end, env))
return false;
request_retry_count++;
}
TimeoutClock timeout(2000);
const char *line = reader.ExpectLine("PLXVC,FLIGHT,A,", timeout);
if (line == nullptr || !HandleFlightLine(line, file, i, row_count)) {
if (request_retry_count > 5)
return false;
/* Discard data which might still be in-transit, e.g. buffered
inside a bluetooth dongle */
port.FullFlush(env, 200, 2000);
/* If we already received parts of the request range correctly break
out of the loop to calculate new request range */
if (i != start)
break;
/* No valid reply received (i==start) - request same range again */
}
}
if (i > row_count)
/* finished successfully */
return true;
if (start == 1)
/* configure the range in the first iteration, now that we know
the length of the file */
env.SetProgressRange(row_count);
env.SetProgressPosition(i - 1);
}
}