本文整理汇总了C++中Port::GetState方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::GetState方法的具体用法?C++ Port::GetState怎么用?C++ Port::GetState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::GetState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenInternalSensors
bool
DeviceDescriptor::DoOpen(OperationEnvironment &env)
{
assert(config.IsAvailable());
if (config.port_type == DeviceConfig::PortType::INTERNAL)
return OpenInternalSensors();
if (config.port_type == DeviceConfig::PortType::DROIDSOAR_V2)
return OpenDroidSoarV2();
if (config.port_type == DeviceConfig::PortType::I2CPRESSURESENSOR)
return OpenI2Cbaro();
if (config.port_type == DeviceConfig::PortType::NUNCHUCK)
return OpenNunchuck();
if (config.port_type == DeviceConfig::PortType::IOIOVOLTAGE)
return OpenVoltage();
if (config.port_type == DeviceConfig::PortType::ADCAIRSPEED)
return OpenAdcAirspeed();
reopen_clock.Update();
Port *port = OpenPort(config, *this);
if (port == NULL) {
TCHAR name_buffer[64];
const TCHAR *name = config.GetPortName(name_buffer, 64);
StaticString<256> msg;
msg.Format(_T("%s: %s."), _("Unable to open port"), name);
env.SetErrorMessage(msg);
return false;
}
while (port->GetState() == PortState::LIMBO) {
env.Sleep(200);
if (env.IsCancelled() || port->GetState() == PortState::FAILED) {
delete port;
return false;
}
}
if (!Open(*port, env)) {
delete port;
return false;
}
return true;
}
示例2: args
int
main(int argc, char **argv)
{
Args args(argc, argv, "DRIVER PORT BAUD");
Emulator *emulator = LoadEmulator(args);
const DeviceConfig config = ParsePortArgs(args);
args.ExpectEnd();
InitialiseIOThread();
Port *port = OpenPort(config, *emulator->handler);
if (port == NULL) {
delete emulator;
fprintf(stderr, "Failed to open COM port\n");
return EXIT_FAILURE;
}
emulator->port = port;
ConsoleOperationEnvironment env;
emulator->env = &env;
if (!port->WaitConnected(env)) {
delete port;
delete emulator;
DeinitialiseIOThread();
fprintf(stderr, "Failed to connect the port\n");
return EXIT_FAILURE;
}
if (!port->StartRxThread()) {
delete port;
delete emulator;
DeinitialiseIOThread();
fprintf(stderr, "Failed to start the port thread\n");
return EXIT_FAILURE;
}
while (port->GetState() != PortState::FAILED)
Sleep(1000);
delete port;
delete emulator;
DeinitialiseIOThread();
return EXIT_SUCCESS;
}