binarygcode is both an executable binary that can be run, and a library that can be used in Rust programs.
Installing the command-line executable
Assuming you have Rust/Cargo installed , run this command in a terminal:
cargo install binarygcode
It will make the binarygcode command available in your PATH if you've allowed the PATH to be modified when installing Rust . cargo uninstall binarygcode uninstalls.
Adding binarygcode library as a dependency
Run this command in a terminal, in your project's directory:
cargo add binarygcode
To add it manually, edit your project's Cargo.toml file and add to the [dependencies] section:
binarygcode = "0.0.3"
The binarygcode library will be automatically available globally.
Read the binarygcode library documentation .
Back to the crate overview .
Readme
binarygcode
A no_std + alloc rust library and binary (CLI) 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 .
Example
Examples can be found in the examples folder. Below is an example of reading the headers
use std:: { env, fs} ;
use binarygcode:: binary_to_ascii;
fn main ( ) {
// Create the path to the gcode file
let mut path = env:: current_dir( ) . unwrap ( ) ;
path. push ( " test_files" ) ;
path. push ( " mini_cube_b.bgcode" ) ;
let binary = fs:: read( path) . unwrap ( ) ;
let gcode = binary_to_ascii ( & binary, true ) . unwrap ( ) ;
println! (
" Binary Length: {} , ASCII Lenght: {} " ,
binary. len ( ) ,
gcode. len ( )
) ;
fs:: write( " tmp/ascii.gcode" , gcode. as_ref ( ) ) . unwrap ( ) ;
}
References