summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2018-04-10 13:32:33 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-04-10 13:32:33 +0100
commit8b0a5c31939d8328e63bf5639db7114effcb8a93 (patch)
tree5c14abcd350e4cf511b5c2210a2636bb9068dc92
parentf61501398da652e7aa13ccfffd1f3d37dfa5f2ca (diff)
downloadcanopied-8b0a5c31939d8328e63bf5639db7114effcb8a93.tar.bz2
Split a single stream so we don't see our own transmissions
-rw-r--r--src/isotp.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/isotp.rs b/src/isotp.rs
index 91394bc..c7d3d9c 100644
--- a/src/isotp.rs
+++ b/src/isotp.rs
@@ -12,6 +12,7 @@ use tokio;
use tokio::prelude::*;
use futures::sync::mpsc;
+use futures::stream::SplitStream;
const DEFAULT_BLOCKS: u8 = 16;
@@ -138,7 +139,7 @@ impl OutgoingPacket {
}
pub struct ISOTP {
- canstream: CANStream,
+ canstream: SplitStream<CANStream>,
cansink: mpsc::Sender<CANFrame>,
incoming: HashMap<u16, IncomingPacket>,
outgoing: HashMap<u16, OutgoingPacket>,
@@ -147,8 +148,7 @@ pub struct ISOTP {
impl ISOTP {
pub fn new(interface: &str) -> ISOTP {
- let stream = CANStream::from_name(interface).unwrap();
- let sink = CANStream::from_name(interface).unwrap();
+ let (sink, stream) = CANStream::from_name(interface).unwrap().split();
let (sender, receiver) = mpsc::channel(100);