gcode-rs
gcode-rs copied to clipboard
Panic unwrapping a float
I got a panic in gcode after sending M28 teg.gcode. Sadly, I haven't been able to reproduce the error so there may be more to it then just parsing an M28 teg.gcode. My question is could we replace this (and any other use) of unwrap with a result?
I'm using this lib in the send gcode to printer loop for https://tegapp.io so a panic here can abort a print whereas a result could be logged safely as a warning on my end (it's non-critical that every gcode gets parsed).
PS. Thanks for making this library - it's been super helpful!
Original Error:
thread 'main' panicked at ': ParseFloatError { kind: Invalid }', /home/d1plo1d/.cargo/registry/src/github.com-1ecc6299db9ec823/gcode-0.5.2/src/words.rs:100:33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Update: I can now recreate the issue reliably by sending M28 teg.gcode.
Also for reference here are the Marlin Firmware Docs for M28: https://marlinfw.org/docs/gcode/M028.html
Ok, initially I started working on a patch to fix this in gcode-rs. Then I decided I wanted to learn Nom.
Now for better or worse there is a nom-gcode parser.