From 7df248779daac8634b5885d0a135b4c4863e526e Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Wed, 28 Feb 2024 20:47:52 +0100 Subject: [PATCH] Implement get_interface_names for serial link --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- io/zenoh-links/zenoh-link-serial/src/unicast.rs | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa9de7e800..9d95ae075d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4549,9 +4549,9 @@ dependencies = [ [[package]] name = "z-serial" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ab200b318928231fa62809ca06397f2790d29ffb58d9cbbc7d517e93a6b17" +checksum = "f113597c6b880587004169f14bc010e4b440981ab2ad669779d3654f9b1c4af1" dependencies = [ "cobs", "futures", diff --git a/Cargo.toml b/Cargo.toml index 9af42deeae..2165a44649 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -160,7 +160,7 @@ validated_struct = "2.1.0" vec_map = "0.8.2" webpki-roots = "0.26.0" winapi = { version = "0.3.9", features = ["iphlpapi"] } -z-serial = "0.2.1" +z-serial = "0.2.3" zenoh-ext = { version = "0.11.0-dev", path = "zenoh-ext" } zenoh-shm = { version = "0.11.0-dev", path = "commons/zenoh-shm" } zenoh-result = { version = "0.11.0-dev", path = "commons/zenoh-result", default-features = false } diff --git a/io/zenoh-links/zenoh-link-serial/src/unicast.rs b/io/zenoh-links/zenoh-link-serial/src/unicast.rs index 51d734f91b..fafac4c393 100644 --- a/io/zenoh-links/zenoh-link-serial/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-serial/src/unicast.rs @@ -183,9 +183,18 @@ impl LinkUnicastTrait for LinkUnicastSerial { #[inline(always)] fn get_interface_names(&self) -> Vec { - // @TODO: Not supported for now - log::debug!("The get_interface_names for LinkUnicastSerial is not supported"); - vec![] + // For POSIX systems, the interface name refers to the file name without the path + // e.g. for serial port "/dev/ttyUSB0" interface name will be "ttyUSB0" + match z_serial::get_available_port_names() { + Ok(interfaces) => { + log::trace!("get_interface_names for serial: {:?}", interfaces); + interfaces + } + Err(e) => { + log::debug!("get_interface_names for serial failed: {:?}", e); + vec![] + } + } } #[inline(always)]