Skip to content

Commit

Permalink
start work on byte matching
Browse files Browse the repository at this point in the history
  • Loading branch information
larsnaesbye committed Jan 4, 2024
1 parent 6a5bada commit abaab08
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn main() -> Result<(), Error> {
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
.about(env!("CARGO_PKG_DESCRIPTION"))
.arg(arg!(--i <VALUE>).required(true))
.arg(arg!(--i <SBFfile>).required(true))
.get_matches();
let filepath: String = matches.get_one::<String>("i").unwrap().to_string();
let rinexrec = sbf2rnxrec(filepath);
Expand All @@ -33,11 +33,7 @@ fn sbf2rnxrec(filepath: String) -> Rinex {

let rrecord: Rinex = Rinex::default();
match std::fs::read(Path::new(&filepath).as_os_str()) {
Ok(bytes) => {
for byte in bytes {
eprintln!("Read byte {}", byte);
}
}
Ok(bytes) => { process_sbfdata(bytes) }
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
eprintln!("Please check path {}", &filepath);
Expand All @@ -54,6 +50,15 @@ fn sbf2rnxrec(filepath: String) -> Rinex {
rrecord
}

fn process_sbfdata(bytes: Vec<u8>) {
const SBF_SYNC1: u8 = 0x24; /* SBF message header sync field 1 (correspond to $) */
const SBF_SYNC2: u8 = 0x40; /* SBF message header sync field 2 (correspond to @)*/
// let's find SBF blocks by their sync bytes
for byte in bytes {
eprintln!("Read byte {}", byte);
}
}

fn write_rnx_file(rinexrec: Rinex) {
rinexrec.to_file("test.rnx").expect("Error: RINEX writeout failed.");
}

0 comments on commit abaab08

Please sign in to comment.