Skip to content

Commit

Permalink
fix(serial-reopening): bug that prevented the serial link to be reuse…
Browse files Browse the repository at this point in the history
…d after closing a session (#1624)

* fix(serial-reopening): resolved a bug that prevents sessions to be reopened over a serial link

Signed-off-by: Gabriele Baldoni <[email protected]>

* fix: serial reconnections

Signed-off-by: Gabriele Baldoni <[email protected]>

* feat: configurable timeout

Signed-off-by: Gabriele Baldoni <[email protected]>

* deps: bump z-serial dependency

Signed-off-by: Gabriele Baldoni <[email protected]>

* fix: release file on close

Signed-off-by: Gabriele Baldoni <[email protected]>

* fix: closing file on error

Signed-off-by: Gabriele Baldoni <[email protected]>

* fix: opening and reconnections

Signed-off-by: Gabriele Baldoni <[email protected]>

* chore: updated log levels

Signed-off-by: Gabriele Baldoni <[email protected]>

* fix: return on map_err

Signed-off-by: Gabriele Baldoni <[email protected]>

* chore: changed warn log to debug

Signed-off-by: Gabriele Baldoni <[email protected]>

* linter: make clippy happy again

Signed-off-by: Gabriele Baldoni <[email protected]>

* deps: bump z-serial

Signed-off-by: Gabriele Baldoni <[email protected]>

* chore: serial not as default feature

Signed-off-by: Gabriele Baldoni <[email protected]>

* deps: bump z-serial

Signed-off-by: Gabriele Baldoni <[email protected]>

---------

Signed-off-by: Gabriele Baldoni <[email protected]>
  • Loading branch information
gabrik authored Dec 11, 2024
1 parent cb3fa54 commit c50717f
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 81 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 @@ -188,7 +188,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

0 comments on commit c50717f

Please sign in to comment.