Skip to content
This repository was archived by the owner on Dec 3, 2020. It is now read-only.

Commit c782cf3

Browse files
committed
refactor library interface to have open function
instead of ::new()
1 parent b0a6ac3 commit c782cf3

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1701,15 +1701,12 @@ fn open_msp(port: Option<&str>, flavor: &FcFlavor, buff: usize, verbose: bool) -
17011701
#[cfg(target_os = "linux")]
17021702
let serial_timeout = Duration::from_millis(0);
17031703

1704-
let msp = Msp::new(buff, Duration::from_millis(0), verbose);
1705-
17061704
match port {
17071705
Some(p) => {
17081706
match p.parse::<SocketAddr>() {
17091707
Ok(sa) => {
17101708
let stream = ClonableTcpStream(TcpStream::connect(sa).unwrap());
1711-
msp.start(stream);
1712-
return msp;
1709+
return Msp::open(stream, buff, Duration::from_millis(0), verbose);
17131710
},
17141711
_ => {
17151712
let mut sp = serialport::new(port.unwrap(), 0)
@@ -1719,8 +1716,7 @@ fn open_msp(port: Option<&str>, flavor: &FcFlavor, buff: usize, verbose: bool) -
17191716

17201717
let clone_port = ClonableSerialPort(sp);
17211718

1722-
msp.start(clone_port);
1723-
return msp;
1719+
return Msp::open(clone_port, buff, Duration::from_millis(0), verbose);
17241720
}
17251721
}
17261722
},
@@ -1750,8 +1746,7 @@ fn open_msp(port: Option<&str>, flavor: &FcFlavor, buff: usize, verbose: bool) -
17501746

17511747
let port = ClonableSerialPort(sp);
17521748

1753-
msp.start(port);
1754-
return msp;
1749+
return Msp::open(port, buff, Duration::from_millis(0), verbose);
17551750
}
17561751
}
17571752
}

0 commit comments

Comments
 (0)