Skip to content

Commit

Permalink
Loop over input file
Browse files Browse the repository at this point in the history
  • Loading branch information
larsnaesbye committed Jan 3, 2024
1 parent c92113a commit fada239
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 113 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "sbf2rnx"
version = "0.1.0"
authors = ["Lars Næsbye Christensen <[email protected]"]
authors = ["Lars Næsbye Christensen <[email protected]>"]
edition = "2021"

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

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

The format, though proprietary, is openly described in the Septentrio reference guide, e.g. page 244
on https://www.septentrio.com/system/files/support/asterx_sb_firmware_v4.8.4_reference_guide.pdf
Expand Down
19 changes: 13 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod sbf;
use rinex::Rinex;
use std::path::Path;
use thiserror::Error;
use clap::{arg, Command};

#[derive(Debug, Error)]
pub enum Error {
Expand All @@ -14,22 +15,28 @@ pub enum Error {
}

pub fn main() -> Result<(), Error> {
let filepath: &str = "../../tests/testdata/KMS3240s.22_";
let matches = Command::new("sbf2rnx")
.version("0.1")
.author("Lars Næsbye Christensen <[email protected]>")
.about("Does awesome things")
.arg(arg!(--i <VALUE>).required(true))
.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);
return Ok(());
}

fn sbf2rnxrec(filepath: &str) -> Rinex {
fn sbf2rnxrec(filepath: String) -> Rinex {
//! Build RINEX records and output them as files
// For now we read the entire file as bytes before conversion - this uses more memory!

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);
// }
for byte in bytes {
eprintln!("Read byte {}", byte);
}
}
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
Expand Down
Loading

0 comments on commit fada239

Please sign in to comment.