Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
larsnaesbye committed Aug 24, 2023
1 parent ea8eac4 commit 5d305c5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 50 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ authors = ["Lars Næsbye Christensen <[email protected]"]
edition = "2021"

[dependencies]
clap = "4"
rinex = "0"
thiserror = "1"
rinex = "0.11.0"
thiserror = "1.0"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ The format, though proprietary, is openly described in the Septentrio reference

Others have made parsers for it, e.g. here: https://github.com/asvol/gnss.net/blob/main/src/Asv.Gnss/Parsers/SBF/SbfBinaryParser.cs or https://raw.githubusercontent.com/tomojitakasu/RTKLIB/master/src/rcv/septentrio.c

If it works, it might be turned into a plugin for the georust/rinex crate.
23 changes: 0 additions & 23 deletions src/cli.rs

This file was deleted.

46 changes: 22 additions & 24 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
//! into receiver independent (RINEX) files.
//! Specification is found on page 244 on https://www.septentrio.com/system/files/support/asterx_sb_firmware_v4.8.4_reference_guide.pdf
mod sbf;
mod cli;

use cli::matches;
use rinex::Rinex;
use std::path::Path;
use thiserror::Error;
Expand All @@ -16,36 +14,36 @@ pub enum Error {
}

pub fn main() -> Result<(), Error> {
let matches = matches();
//let filepath: Option<Vec<&str>> = match matches.is_present("filepath") {
// true => Some(matches.value_of("filepath").unwrap().split(",").collect()),
// false => None,
//};
// get the file data
//let rinexrec = sbf2rnxrec(filepath.unwrap());
//write_rnx_file(rinexrec);
let filepath: &str = "../../tests/testdata/KMS3240s.22_";
let rinexrec = sbf2rnxrec(filepath);
write_rnx_file(rinexrec);
return Ok(());
}

fn sbf2rnxrec(filepath: Vec<&str>) -> Rinex {
fn sbf2rnxrec(filepath: &str) -> Rinex {
//! Build RINEX records and output them as files
// For now we read the entire file as bytes before conversion - this uses more memory!
//match std::fs::read(Path::new(&filepath.as_ptr())) {
// Ok(bytes) => {
// eprintln!("{}", bytes.len().to_string()) // For testing, just print the length of the file
// }
// Err(e) => {
// if e.kind() == std::io::ErrorKind::PermissionDenied {
// eprintln!("Please run again with appropriate permissions.");
// panic!("{}", e)
// }
// panic!("{}", e);
// }
//}

match std::fs::read(Path::new(&filepath).as_os_str()) {
Ok(bytes) => {
eprintln!("Length {}", bytes.len().to_string()) // For testing, just print the length of the file
}
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
eprintln!("Please check path {}", &filepath);
panic!("{}", e)
}
if e.kind() == std::io::ErrorKind::PermissionDenied {
eprintln!("Please run again with appropriate permissions.");
panic!("{}", e)
}
panic!("{}", e);
}
}

return Rinex::default();
}

fn write_rnx_file(rinexrec: Rinex) {
rinexrec.to_file("").expect("TODO: panic message");
//rinexrec.to_file("").expect("TODO: panic message");
}

0 comments on commit 5d305c5

Please sign in to comment.