|
20 | 20 |
|
21 | 21 | int main() { |
22 | 22 | try { |
| 23 | + ob::Context::setLoggerSeverity(OBLogSeverity::OB_LOG_SEVERITY_OFF); |
23 | 24 | auto context = std::make_unique<ob::Context>(); |
24 | | - context->setLoggerSeverity(OBLogSeverity::OB_LOG_SEVERITY_OFF); |
25 | 25 | auto list = context->queryDeviceList(); |
26 | 26 | for (size_t i = 0; i < list->deviceCount(); i++) { |
27 | | - auto device = list->getDevice(i); |
28 | | - auto device_info = device->getDeviceInfo(); |
29 | | - std::string serial = device_info->serialNumber(); |
30 | | - std::string uid = device_info->uid(); |
31 | | - auto usb_port = orbbec_camera::parseUsbPort(uid); |
32 | | - std::stringstream pid_hex; |
33 | | - pid_hex<< std::hex << std::setw(4) << std::setfill('0') << device_info->getPid(); |
34 | | - RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), |
35 | | - "- Name: " << device_info->getName() << ", PID: 0x" |
36 | | - << pid_hex.str() << ", SN/ID: " << serial |
37 | | - << ", Connection: " << device_info->getConnectionType()); |
38 | | - RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), "serial: " << serial); |
39 | | - RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), "usb port: " << usb_port); |
40 | | - RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), |
41 | | - "usb connect type: " << device_info->getConnectionType()); |
| 27 | + if (std::string(list->getConnectionType(i)) != "Ethernet") { |
| 28 | + std::string serial = list->serialNumber(i); |
| 29 | + std::string uid = list->uid(i); |
| 30 | + auto usb_port = orbbec_camera::parseUsbPort(uid); |
| 31 | + auto connection_type = list->getConnectionType(i); |
| 32 | + std::stringstream pid_hex; |
| 33 | + pid_hex << std::hex << std::setw(4) << std::setfill('0') << list->getPid(i); |
| 34 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), |
| 35 | + "- Name: " << list->getName(i) << ", PID: 0x" << pid_hex.str() |
| 36 | + << ", SN/ID: " << serial |
| 37 | + << ", Connection: " << connection_type); |
| 38 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), "serial: " << serial); |
| 39 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), "usb port: " << usb_port); |
| 40 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), |
| 41 | + "usb connect type: " << connection_type); |
| 42 | + std::cout << std::endl; |
| 43 | + } else { |
| 44 | + std::string serial = list->serialNumber(i); |
| 45 | + auto connection_type = list->getConnectionType(i); |
| 46 | + auto ip_address = list->getIpAddress(i); |
| 47 | + std::stringstream pid_hex; |
| 48 | + pid_hex << std::hex << std::setw(4) << std::setfill('0') << list->getPid(i); |
| 49 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), |
| 50 | + "- Name: " << list->getName(i) << ", PID: 0x" << pid_hex.str() |
| 51 | + << ", SN/ID: " << serial |
| 52 | + << ", Connection: " << connection_type); |
| 53 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), "serial: " << serial); |
| 54 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), "ip address: " << ip_address); |
| 55 | + RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"), |
| 56 | + "usb connect type: " << connection_type); |
| 57 | + std::cout << std::endl; |
| 58 | + } |
42 | 59 | } |
43 | 60 | } catch (ob::Error &e) { |
44 | 61 | RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), e.getMessage()); |
|
0 commit comments