Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(serial-reopening): bug that prevented the serial link to be reused after closing a session #1624

Merged
merged 14 commits into from
Dec 11, 2024
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 @@ -187,7 +187,7 @@ vec_map = "0.8.2"
webpki-roots = "0.26.5"
winapi = { version = "0.3.9", features = ["iphlpapi", "winerror"] }
x509-parser = "0.16.0"
z-serial = "0.2.3"
z-serial = "0.3.1"
either = "1.13.0"
prost = "0.13.2"
tls-listener = { version = "0.10.2", features = ["rustls-ring"] }
Expand Down
22 changes: 22 additions & 0 deletions io/zenoh-links/zenoh-link-serial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const DEFAULT_BAUDRATE: u32 = 9_600;

const DEFAULT_EXCLUSIVE: bool = true;

const DEFAULT_TIMEOUT: u64 = 50_000;

const DEFAULT_RELEASE_ON_CLOSE: bool = true;

pub const SERIAL_LOCATOR_PREFIX: &str = "serial";

const SERIAL_MTU_LIMIT: BatchSize = SERIAL_MAX_MTU;
Expand Down Expand Up @@ -94,11 +98,29 @@ pub fn get_exclusive(endpoint: &EndPoint) -> bool {
}
}

pub fn get_timeout(endpoint: &EndPoint) -> u64 {
if let Some(tout) = endpoint.config().get(config::TIMEOUT_RAW) {
u64::from_str(tout).unwrap_or(DEFAULT_TIMEOUT)
} else {
DEFAULT_TIMEOUT
}
}

pub fn get_release_on_close(endpoint: &EndPoint) -> bool {
if let Some(release_on_close) = endpoint.config().get(config::RELEASE_ON_CLOSE) {
bool::from_str(release_on_close).unwrap_or(DEFAULT_RELEASE_ON_CLOSE)
} else {
DEFAULT_RELEASE_ON_CLOSE
}
}

pub fn get_unix_path_as_string(address: Address<'_>) -> String {
address.as_str().to_owned()
}

pub mod config {
pub const PORT_BAUD_RATE_RAW: &str = "baudrate";
pub const PORT_EXCLUSIVE_RAW: &str = "exclusive";
pub const TIMEOUT_RAW: &str = "tout";
pub const RELEASE_ON_CLOSE: &str = "release_on_close";
}
Loading
Loading