checkpointing

This commit is contained in:
John Goerzen 2020-09-24 22:44:13 -05:00
parent 0bc7559915
commit 47ed503356
2 changed files with 12 additions and 2 deletions

View File

@ -98,9 +98,13 @@ fn main() {
ping::genpings(dest_u64, xbeesender).expect("Failure in genpings") ping::genpings(dest_u64, xbeesender).expect("Failure in genpings")
}); });
ping::displaypongs(&mut xbreframer, &mut xb.ser_reader); ping::displaypongs(&mut xbreframer, &mut xb.ser_reader);
// Make sure queued up data is sent
let _ = writerthread.join();
} }
Command::Pong => { Command::Pong => {
ping::pong(&mut xbreframer, &mut xb.ser_reader, xbeesender).expect("Failure in pong"); ping::pong(&mut xbreframer, &mut xb.ser_reader, xbeesender).expect("Failure in pong");
// Make sure queued up data is sent
let _ = writerthread.join();
} }
Command::Pipe { dest } => { Command::Pipe { dest } => {
let dest_u64: u64 = u64::from_str_radix(&dest, 16).expect("Invalid destination"); let dest_u64: u64 = u64::from_str_radix(&dest, 16).expect("Invalid destination");
@ -124,6 +128,8 @@ fn main() {
}); });
tap_reader.frames_from_tap_processor(maxpacketsize - 1, xbeesender) tap_reader.frames_from_tap_processor(maxpacketsize - 1, xbeesender)
.expect("Failure in frames_from_tap_processor"); .expect("Failure in frames_from_tap_processor");
// Make sure queued up data is sent
let _ = writerthread.join();
} }
} }
} }

View File

@ -20,6 +20,7 @@
use bytes::*; use bytes::*;
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
use std::fmt; use std::fmt;
use log::*;
/** XBee transmissions can give either a 64-bit or a 16-bit destination /** XBee transmissions can give either a 64-bit or a 16-bit destination
address. This permits the user to select one. */ address. This permits the user to select one. */
@ -191,12 +192,15 @@ impl PacketStream {
return Ok(retval); return Ok(retval);
} }
trace!("xbpacket: data len {}", data.len());
let chunks: Vec<&[u8]> = data.chunks(maxpacketsize - 1).collect(); let chunks: Vec<&[u8]> = data.chunks(maxpacketsize - 1).collect();
let mut chunks_remaining: u8 = u8::try_from(chunks.len() - 1) trace!("xbpacket: chunk count {}", chunks.len());
let mut chunks_remaining: u8 = u8::try_from(chunks.len())
.map_err(|e| String::from("More than 255 chunks to transmit"))?; .map_err(|e| String::from("More than 255 chunks to transmit"))?;
for chunk in chunks { for chunk in chunks {
trace!("xbpacket: chunks_remaining: {}", chunks_remaining);
let mut payload = BytesMut::new(); let mut payload = BytesMut::new();
payload.put_u8(chunks_remaining); payload.put_u8(chunks_remaining - 1);
payload.put_slice(chunk); payload.put_slice(chunk);
let frame_id = 0; // self.get_and_incr_framecounter(); // FIXME: make this configurable whether we get back TX reports. let frame_id = 0; // self.get_and_incr_framecounter(); // FIXME: make this configurable whether we get back TX reports.
let packet = XBTXRequest { let packet = XBTXRequest {