summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2018-06-05 10:03:50 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2018-06-05 10:03:50 +0100
commit37c8e438104c39766f3fabbd90d698f2618d186a (patch)
tree5b128bfdb66abb5286e4d45d99ac7ba1b9b7cd05
parent502fd53ac06b3f509eddbe5a9629066156659cd7 (diff)
downloadcanopied-37c8e438104c39766f3fabbd90d698f2618d186a.tar.bz2
Support empty CAN interface name to stop after load/parse
-rw-r--r--src/main.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index f9e91a3..3103f5f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -67,13 +67,19 @@ fn main() {
info!("Read {} unit definitions", units.count());
info!("Read {} derived definitions", derived.count());
+ let args: Vec<String> = args().collect();
+ let iface = if args.len() > 1 {
+ args[1].clone()
+ } else {
+ "vcan0".into()
+ };
+
+ if iface.len() == 0 {
+ info!("Stopping now");
+ return;
+ }
+
let world = futures::future::lazy(move || {
- let args: Vec<String> = args().collect();
- let iface = if args.len() > 1 {
- args[1].clone()
- } else {
- "vcan0".into()
- };
info!("Connecting Canopied to {}", iface);
let (sink, stream) = isotp::ISOTP::new(&iface).split();
let (sender, receiver) = mpsc::channel(100);