本文整理汇总了C++中Port::WaitForChar方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::WaitForChar方法的具体用法?C++ Port::WaitForChar怎么用?C++ Port::WaitForChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::WaitForChar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timeout
bool
Volkslogger::Handshake(Port &port, OperationEnvironment &env,
unsigned timeout_ms)
{
TimeoutClock timeout(timeout_ms);
while (true) { // Solange R's aussenden, bis ein L zurückkommt
if (!port.Write('R'))
return false;
int remaining = timeout.GetRemainingSigned();
if (remaining < 0)
return false;
if (remaining > 500)
remaining = 500;
Port::WaitResult result =
port.WaitForChar('L', env, remaining);
if (result == Port::WaitResult::READY)
break;
if (result != Port::WaitResult::TIMEOUT)
return false;
/* timeout, try again */
}
unsigned count = 1;
while (true) { // Auf 4 hintereinanderfolgende L's warten
int remaining = timeout.GetRemainingSigned();
if (remaining < 0)
return false;
if (port.WaitForChar('L', env, remaining) != Port::WaitResult::READY)
return false;
count++;
if (count >= 4)
return true;
}
}
示例2: timeout
bool
Volkslogger::Handshake(Port &port, OperationEnvironment &env,
std::chrono::steady_clock::duration _timeout)
{
TimeoutClock timeout(_timeout);
while (true) { // Solange R's aussenden, bis ein L zurückkommt
if (!port.Write('R'))
return false;
auto remaining = timeout.GetRemainingSigned();
if (remaining.count() < 0)
return false;
if (remaining > std::chrono::milliseconds(500))
remaining = std::chrono::milliseconds(500);
Port::WaitResult result =
port.WaitForChar('L', env, remaining);
if (result == Port::WaitResult::READY)
break;
if (result != Port::WaitResult::TIMEOUT)
return false;
/* timeout, try again */
}
unsigned count = 1;
while (true) { // Auf 4 hintereinanderfolgende L's warten
const auto remaining = timeout.GetRemainingSigned();
if (remaining.count() < 0)
return false;
if (port.WaitForChar('L', env, remaining) != Port::WaitResult::READY)
return false;
count++;
if (count >= 4)
return true;
}
}
示例3:
static bool
ExpectXOff(Port &port, OperationEnvironment &env, unsigned timeout_ms)
{
return port.WaitForChar(0x13, env, timeout_ms) == Port::WaitResult::READY;
}
示例4:
bool
Volkslogger::WaitForACK(Port &port, OperationEnvironment &env)
{
return port.WaitForChar(ACK, env, 30000) == Port::WaitResult::READY;
}
示例5: ExpectACK
static inline bool
ExpectACK(Port &port, OperationEnvironment &env, unsigned timeout_ms=2000)
{
return port.WaitForChar(ACK, env, timeout_ms) == Port::WaitResult::READY;
}
示例6:
bool
Volkslogger::WaitForACK(Port &port, OperationEnvironment &env)
{
return port.WaitForChar(ACK, env, std::chrono::seconds(30)) == Port::WaitResult::READY;
}