Skip to content

Commit

Permalink
Implement get_interface_names for serial link
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Feb 28, 2024
1 parent 42f9384 commit 7df2487
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
15 changes: 12 additions & 3 deletions io/zenoh-links/zenoh-link-serial/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,18 @@ impl LinkUnicastTrait for LinkUnicastSerial {

#[inline(always)]
fn get_interface_names(&self) -> Vec<String> {
// @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)]
Expand Down

0 comments on commit 7df2487

Please sign in to comment.