k210-sdk-stuff/util/esp8266at/examples/parsetest.rs
Wladimir J. van der Laan c091f406eb Fix cargo build in /rust
Move esp8266 out of the workspace, it defaults to `nom` with different
features (`std` enabled) which means that `std` gets enabled for use of
nom (see https://github.com/rust-lang/cargo/issues/4463).

This caused the build to fail with missing std in riscv-….
2019-07-26 11:06:22 +00:00

36 lines
1.0 KiB
Rust

use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use esp8266at::response::{parse,ParseResult};
fn main() {
let f = File::open("data/parses.txt").unwrap();
let file = BufReader::new(&f);
for line in file.lines() {
let l = line.unwrap();
if l.len() >= 2 {
let mut lb = l[2..].as_bytes().to_vec();
lb.push(13);
lb.push(10);
let res = parse(&lb);
match res {
ParseResult::Err => {
println!("failed command was: {}", l);
}
ParseResult::Incomplete => {
println!("incomplete command was: {}", l);
}
ParseResult::Ok(res, x) => {
if res == lb.len() {
println!("{:?}", x);
} else {
println!("non-empty residue command was: {}", l);
println!("{:?} {:?}", res, x);
}
}
}
}
}
}