You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void(* Reset_AVR) (void) = 0; //Way of resetting the ATmega
98
98
99
-
#defineCFG_FILENAME"config.txt"//This is the name of the file that contains the unit settings
99
+
#defineCFG_FILENAME"config.txt\0"//This is the name of the file that contains the unit settings
100
100
101
101
#defineMAX_CFG"115200,255,255,1,1,1,1,255,255\0"// This is used to calculate the longest possible configuration string. These actual values are not used
102
102
#defineCFG_LENGTH (strlen(MAX_CFG) + 1) //Length of text found in config file. strlen ignores \0 so we have to add it back
103
-
#defineSEQ_FILENAME"SEQLOG00.TXT"//This is the name for the file when you're in sequential mode
103
+
#defineSEQ_FILENAME"SEQLOG00.TXT\0"//This is the name for the file when you're in sequential mode
104
104
105
105
//Internal EEPROM locations for the user settings
106
106
#defineLOCATION_SYSTEM_SETTING0x02
@@ -272,12 +272,12 @@ void loop(void)
272
272
{
273
273
//If in MODE_NEWLOG, then just append the file name that newLog() returns and ignore return value of appendFile()
274
274
//If in MODE_ROTATE, then as long as appendFile() keeps returning 0 (meaning the file is full and a new one
275
-
// needs to be started) keep creating new files and logging new data. If appendFile() returns a 1 then the escape
275
+
// needs to be started) keep creating new files and logging new data. If appendFile() returns a 1 then the escape
276
276
// sequence has been triggered so drop out of this while() loop and let commandShell() run.
277
277
while ((appendFile(newLog()) == 0) && (setting_systemMode == MODE_ROTATE))
278
278
{ } // While loop purposely empty
279
279
}
280
-
280
+
281
281
//If we are in sequential log mode, determine if seqLog.txt has been created or not, and then open it for logging
282
282
if (setting_systemMode == MODE_SEQLOG)
283
283
seqLog();
@@ -341,11 +341,11 @@ char* newLog(void)
341
341
//arbitrarily. This fixes that problem.
342
342
/// TODO: (BPS) I don't understand why this is here. Your file number is then always one less than what's in EEPROM, which doesn't make sense.
343
343
/// I'm commenting this out so that we always use the actual filenumber stored in EEPROM
344
-
// if (newFileNumber > 0) newFileNumber--;
344
+
// if (newFileNumber > 0) newFileNumber--;
345
345
346
346
staticchar newFileName[13]; //Bug fix from ystark's pull request: https://github.com/sparkfun/OpenLog/pull/189
347
347
348
-
// When in MODE_ROTATE, we don't care if the file exists, or if it is empty, or anything. We will always
348
+
// When in MODE_ROTATE, we don't care if the file exists, or if it is empty, or anything. We will always
349
349
// blindly create whatever the next filename is and use it.
350
350
if (setting_systemMode == MODE_ROTATE)
351
351
{
@@ -357,15 +357,15 @@ char* newLog(void)
357
357
while (1)
358
358
{
359
359
sprintf_P(newFileName, PSTR("LOG%05u.TXT"), newFileNumber); //Splice the new file number into this file name
360
-
360
+
361
361
// O_CREAT - create the file if it does not exist
362
362
// O_APPEND - seek to the end of the file prior to each write
363
363
// O_WRITE - open for write
364
364
// O_EXCL - if O_CREAT and O_EXCEL are set, open() shall fail if file exists
365
-
365
+
366
366
//Try to open file, if it opens (file doesn't exist), then break
367
367
if (newFile.open(newFileName, O_CREAT | O_EXCL | O_WRITE)) break;
368
-
368
+
369
369
//Try to open file and see if it is empty. If so, use it.
370
370
if (newFile.open(newFileName, O_READ))
371
371
{
@@ -376,7 +376,7 @@ char* newLog(void)
376
376
}
377
377
newFile.close(); // Close this existing file we just opened.
378
378
}
379
-
379
+
380
380
//Try the next number
381
381
newFileNumber++;
382
382
if (newFileNumber > 65533) //There is a max of 65534 logs
@@ -387,7 +387,7 @@ char* newLog(void)
387
387
}
388
388
newFile.close(); //Close this new file we just opened
389
389
}
390
-
390
+
391
391
newFileNumber++; //Increment so the next power up uses the next file #
392
392
393
393
//Record new_file number to EEPROM
@@ -420,7 +420,7 @@ void seqLog(void)
420
420
{
421
421
SdFile seqFile;
422
422
423
-
char sequentialFileName[strlen(SEQ_FILENAME)]; //Limited to 8.3
423
+
char sequentialFileName[strlen(SEQ_FILENAME) + 1]; //Limited to 8.3
424
424
strcpy_P(sequentialFileName, PSTR(SEQ_FILENAME)); //This is the name of the config file. 'config.sys' is probably a bad idea.
if (tempFile.write((byte*) buffer, dataLen) != dataLen) {
1579
+
if (tempFile.write((byte*) commandBuffer, dataLen) != dataLen) {
1587
1580
if ((feedbackMode & EXTENDED_INFO) > 0)
1588
1581
NewSerial.println(F("error writing to file"));
1589
1582
break;
1590
1583
}
1591
1584
1592
-
if (dataLen < (sizeof(buffer) - 1)) tempFile.write("\n\r", 2); //If we didn't fill up the buffer then user must have sent NL. Append new line and return
1585
+
if (dataLen < (sizeof(commandBuffer) - 1)) tempFile.write("\n\r", 2); //If we didn't fill up the buffer then user must have sent NL. Append new line and return
1593
1586
}
1594
1587
1595
1588
tempFile.close();
@@ -1831,9 +1824,9 @@ void commandShell(void)
1831
1824
}
1832
1825
1833
1826
//Reads a line until the \n enter character is found
0 commit comments