Why is the conversion from string to float done using the method in NultsAndBolts.cpp versus doing a little string manipulation and using a toFloat()?
I guess I could have read the comments:
/*
Takes a string and a starting character index and returns a float if it can
be parsed from the string, it will skip leading spaces. Does not support
scientific notation as this is officially not supported by GCode.
Code was adopted from arduino Stream::parseFloat and some from Grbl’s
read_float. It is a custom function because all arduino and c++ functions
appear to handle scientific notation or hexadecimal notation, or some other
type of numerical representation that we don’t want supported.
*/
Is the rationale that if gcode is sent with scientific notation you want it to kick back as an error?
NutsAndBolts.cpp does a proper job with values. The issue with the stray characters from the Arduino Serial.print() is from the floating point implementation of the Arduino. One solution would be to avoid printing so many digits (why 8 digits? Three would be plenty.).
I was more curious as to why toFloat wasn’t used… not related to the issue with too many significant digits.
It might be part of grbl compatibility?
I believe that @blurfl is correct, that function is adopted directly from GRBL
ok, so if I wanted to send data to the controller that’s not related to gcode, I could make my own routine that uses toFloat() I assume. I was wondering if there were issues with error handling, garbled data, that was trying to be caught since arduinos don’t do try/catch
Yes, I think we have used toFloat() successfully in the past