binarygcode
A no_std
+ alloc
rust library and (coming soon) binary crate to deserialise and serialise binary gcode (.bgcode
) files. The binary gcode specification can be found here.
Support
Please consider supporting the crate by:
- Downloading and using the crate.
- Raising issues and improvements on the GitHub repo.
- Recommending the crate to others.
- ⭐ the crate on GitHub.
- Sponsoring the maintainer.
Functionality
The crate is still under construction. So far we have managed to complete...
Function |
Status |
Deserialise |
Done |
Serialise |
In Progress |
Binary (CLI) |
Planned |
Example
Examples can be found in the examples
folder. Below is an example of reading the headers
use std::{
env,
fs::File,
io::{BufReader, Read},
};
use binarygcode::deserialiser::Deserialiser;
fn main() {
let mut path = env::current_dir().unwrap();
path.push("test_files");
path.push("mini_cube_b.bgcode");
let file = File::open(path).unwrap();
let mut reader = BufReader::new(file);
let mut fh_buf = Deserialiser::fh_buf();
reader.read_exact(fh_buf.as_mut_slice()).unwrap();
let mut deserialiser = Deserialiser::new(&fh_buf).unwrap();
println!(
"File Version: {}, Checksum: {:?}",
deserialiser.version, deserialiser.checksum
);
let mut n = 0;
while reader.read_exact(deserialiser.block_header_buf()).is_ok() {
println!(
"{} {:?} {}",
n,
deserialiser.kind().unwrap(),
deserialiser.block_size().unwrap()
);
let block_size = deserialiser.block_size().unwrap();
reader.seek_relative(block_size as i64).unwrap();
n += 1;
}
}
References