Skip to content

Commit

Permalink
Define exclusiveness upon creation (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
cguimaraes authored Sep 15, 2022
1 parent b174a5e commit 623ec36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/serial-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn main() -> tokio_serial::Result<()> {

println!("Arguments: {:?}", args);

let mut port = ZSerial::new(args.port, args.baud_rate)?;
let mut port = ZSerial::new(args.port, args.baud_rate, true)?;

if args.server {
loop {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ pub struct ZSerial {
}

impl ZSerial {
pub fn new(port: String, baud_rate: u32) -> tokio_serial::Result<Self> {
pub fn new(port: String, baud_rate: u32, exclusive: bool) -> tokio_serial::Result<Self> {
let mut serial = tokio_serial::new(port.clone(), baud_rate).open_native_async()?;

#[cfg(unix)]
serial.set_exclusive(false)?;
serial.set_exclusive(exclusive)?;

Ok(Self {
port,
Expand Down

0 comments on commit 623ec36

Please sign in to comment.