@@ -47,7 +47,7 @@ void loadSettings()
4747 recordSystemSettings ();
4848}
4949
50- // Load settings without recording
50+ // Load settings without recording
5151// Used at very first boot to test for resetCounter
5252void loadSettingsPartial ()
5353{
@@ -64,7 +64,7 @@ void loadSettingsPartial()
6464 log_d (" EEPROM is blank" );
6565 return ; // EEPROM is blank, assume default settings
6666 }
67-
67+
6868 EEPROM.get (0 , settings); // Read current settings
6969}
7070
@@ -308,26 +308,36 @@ bool parseLine(char* str) {
308308 char settingName[40 ];
309309 sprintf (settingName, " %s" , str);
310310
311+ double d = 0.0 ;
312+ char settingValue[50 ] = " " ;
313+
311314 // Move pointer to end of line
312315 str = strtok (nullptr , " \n " );
313- if (!str) return false ;
314-
315- // Attempt to convert string to double
316- double d = strtod (str, &ptr);
317-
318- char settingValue[50 ];
319- if (d == 0.0 ) // strtod failed, may be string or may be 0 but let it pass
316+ if (!str)
320317 {
321- sprintf (settingValue, " %s" , str);
318+ // This line does not contain a \n or the settingValue is zero length
319+ // so there is nothing to parse
320+ // https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/77
322321 }
323322 else
324323 {
325- if (str == ptr || *skipSpace (ptr)) return false ; // Check str pointer
324+ // Attempt to convert string to double
325+ d = strtod (str, &ptr);
326+
327+ if (d == 0.0 ) // strtod failed, may be string or may be 0 but let it pass
328+ {
329+ sprintf (settingValue, " %s" , str);
330+ }
331+ else
332+ {
333+ if (str == ptr || *skipSpace (ptr)) return false ; // Check str pointer
326334
327- // See issue https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/47
328- sprintf (settingValue, " %1.0lf" , d); // Catch when the input is pure numbers (strtod was successful), store as settingValue
335+ // See issue https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/47
336+ sprintf (settingValue, " %1.0lf" , d); // Catch when the input is pure numbers (strtod was successful), store as settingValue
337+ }
329338 }
330339
340+
331341 // Get setting name
332342 if (strcmp (settingName, " sizeOfSettings" ) == 0 )
333343 {
@@ -504,7 +514,7 @@ bool parseLine(char* str) {
504514// ESP32 doesn't have erase command so we do it here
505515void eepromErase ()
506516{
507- if (online.eeprom == false )
517+ if (online.eeprom == false )
508518 {
509519 log_d (" Error: EEPROM not online" );
510520 return ;
0 commit comments