Skip to content

Commit

Permalink
nom instead
Browse files Browse the repository at this point in the history
  • Loading branch information
larsnaesbye committed Jan 6, 2024
1 parent 6495fce commit a725765
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ version = "0.1.0"
authors = ["Lars Næsbye Christensen <[email protected]>"]
edition = "2021"
description = "Converts SBF to RINEX"
rust-version = "1.71.0"
categories = ["science::geo", "parsing"]

[dependencies]
binread = "2.2.0"

bstr = "1.9"
clap = { version = "4.4", features = [] }
nom = "7.1"
rinex = "0.15"
thiserror = "1.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sbf2rnx-dev
# sbf2rnx

A fun little project to see if I can convert SBF (Septentrio) binary files to RINEX using Rust.

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn main() -> Result<(), Error> {
.get_matches();
let filepath: String = matches.get_one::<String>("i").unwrap().to_string();
let rinexrec = sbf2rnxrec(filepath);
//write_rnx_file(rinexrec);
write_rnx_file(rinexrec);
Ok(())
}

Expand Down
8 changes: 5 additions & 3 deletions src/sbf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,18 @@ fn decode_galalm(galalmdata: u8) -> u8 {
}

pub(crate) fn process_sbfdata(bytes: Vec<u8>) -> Rinex {
let mut rinexstruct = Rinex::default();
rinexstruct.header.program = env!("CARGO_PKG_NAME").parse().unwrap();
// let's find SBF blocks by using their sync bytes

let pattern: [u8; 2] = [SBF_SYNC1, SBF_SYNC2];
let result: Vec<Vec<u8>> = bytes.split_str(&pattern).map(|x| x.to_vec()).collect();
// now we have a collection of SBF blocks

// now we have a collection of SBF blocks to iterate through
for block in result {
eprintln!("Read block {:?}", block);
// let crc = ((block[1] as u16) << 8) | block[2] as u16;
// eprintln!("CRC: {}", crc);
}

Rinex::default() // Placeholder to output right type for now
rinexstruct // Placeholder to output right type for now
}

0 comments on commit a725765

Please sign in to comment.