BrewPi / firmware

Brewing temperature control firmware for the BrewPi Spark (Particle Photon inside)
http://www.brewpi.com
GNU Affero General Public License v3.0
97 stars 55 forks source link

Error checking on strings received over Serial #21

Closed elcojacobs closed 9 years ago

elcojacobs commented 9 years ago

The strings that are received over serial for setpoints and other settings are not error checked.

atol just returns 0 on error, which is indistinguishable from atol("0").

By using strtol instead, we can check the end pointer after the function and handle parse errors.

elcojacobs commented 9 years ago

This is fixed in: https://github.com/BrewPi/firmware/compare/cb4ae685101d17adde08fda7942d373f170f55a9...8807f2efe1d39e467bc8123e7919e948e709d297

String conversion functions now return bool and take a pointer to temperature as argument. The temperature is not written if the string is invalid, avoiding the need to write to an intermediate value:

if(stringToTempDiff(target, value)){
    eepromManager.storeTempConstantsAndSettings(); // value parsed correctly
}

Also introduced DISABLED_TEMP in addition to invalid temp to indicate a disabled setpoint independent of mode.

elcojacobs commented 9 years ago

Merged in 0.2.9