mirror of
https://github.com/jgoerzen/xbnet.git
synced 2025-02-12 05:23:50 -04:00
Checkpointing packet work
This commit is contained in:
parent
b65219dff5
commit
38bd1573e7
@ -38,6 +38,8 @@ pub fn stdintolorakiss(ls: &mut LoraStik, maxframesize: usize) -> io::Result<()>
|
||||
let mut buf = Vec::new();
|
||||
let res = br.read_until(FEND, &mut buf)?;
|
||||
|
||||
// buf now ends with FEND but doesn't begin with it (in the case of a frame)
|
||||
|
||||
if res == 0 {
|
||||
// EOF
|
||||
return Ok(());
|
||||
|
@ -108,7 +108,7 @@ impl LoraStik {
|
||||
/// as well as a separate receiver to be used in a separate thread to handle
|
||||
/// incoming frames. The bool specifies whether or not to read the quality
|
||||
/// parameters after a read.
|
||||
pub fn new(ser: LoraSer, readqual: bool, txwait: u64, eotwait: u64, maxpacketsize: usize) -> (LoraStik, crossbeam_channel::Receiver<ReceivedFrames>) {
|
||||
pub fn new(ser: LoraSer, readqual: bool, txwait: u64, eotwait: u64, maxpacketsize: usize, pack: bool) -> (LoraStik, crossbeam_channel::Receiver<ReceivedFrames>) {
|
||||
let (readerlinestx, readerlinesrx) = crossbeam_channel::unbounded();
|
||||
let (txblockstx, txblocksrx) = crossbeam_channel::bounded(3);
|
||||
let (readeroutput, readeroutputreader) = crossbeam_channel::unbounded();
|
||||
@ -117,7 +117,7 @@ impl LoraStik {
|
||||
|
||||
thread::spawn(move || readerlinesthread(ser2, readerlinestx));
|
||||
|
||||
(LoraStik { readqual, ser, readeroutput, readerlinesrx, txblockstx, txblocksrx, maxpacketsize,
|
||||
(LoraStik { readqual, ser, readeroutput, readerlinesrx, txblockstx, txblocksrx, maxpacketsize, pack,
|
||||
txdelay: None,
|
||||
txwait: Duration::from_millis(txwait),
|
||||
eotwait: Duration::from_millis(eotwait),
|
||||
|
@ -41,6 +41,10 @@ struct Opt {
|
||||
/// Read and log quality data after receiving packets
|
||||
#[structopt(long)]
|
||||
readqual: bool,
|
||||
|
||||
/// Pack as many bytes as possible into each TX frame, regardless of original framing
|
||||
#[structopt(long)]
|
||||
pack: bool,
|
||||
|
||||
/// Radio initialization command file
|
||||
#[structopt(long, parse(from_os_str))]
|
||||
@ -100,7 +104,7 @@ fn main() {
|
||||
let maxpacketsize = opt.maxpacketsize;
|
||||
|
||||
let loraser = ser::LoraSer::new(opt.port).expect("Failed to initialize serial port");
|
||||
let (mut ls, radioreceiver) = lorastik::LoraStik::new(loraser, opt.readqual, opt.txwait, opt.eotwait, maxpacketsize);
|
||||
let (mut ls, radioreceiver) = lorastik::LoraStik::new(loraser, opt.readqual, opt.txwait, opt.eotwait, maxpacketsize, pack);
|
||||
ls.radiocfg(opt.initfile).expect("Failed to configure radio");
|
||||
|
||||
let mut ls2 = ls.clone();
|
||||
|
@ -34,9 +34,7 @@ pub fn stdintolora(ls: &mut LoraStik, maxframesize: usize) -> io::Result<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for chunk in buf[0..res].chunks(maxframesize) {
|
||||
ls.transmit(&chunk);
|
||||
}
|
||||
ls.transmit(&buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user