设备发现与连接
枚举 Exo 串口候选,配置自动发现或固定端口,并按逻辑名称选择设备。
当前版本 · 1.0.0
设备发现与连接
发现候选
for (const auto& candidate : qnbot::discover_exos()) {
if (candidate.error) {
std::cerr << candidate.port << ": " << candidate.error->message << '\n';
} else if (candidate.device_info) {
std::cout << candidate.port << '\n';
}
}发现错误码为 port_open、protocol_error 或 incompatible。
固定端口和名称
qnbot::ExoConfig exo_config;
exo_config.name = "primary-exo";
exo_config.connection.port = "/dev/ttyUSB0";
qnbot::SdkConfig config;
config.devices = {exo_config};
qnbot::Sdk sdk(std::move(config));
auto device = sdk.exo().device("primary-exo");Windows 使用 COM3 等端口。Core 的 SerialConnection 是规范连接类型;ExoSerialConnection 仅为兼容别名。Exo 不支持通过 serial_number 定位设备。