Add command to delete log file from SD
This commit is contained in:
parent
93aa6f5fd5
commit
18f173f11b
|
@ -65,6 +65,7 @@ void beginSDLogging();
|
|||
void endSDLogging();
|
||||
void setTS_SD_status();
|
||||
void formatExFat();
|
||||
void deleteLogFile(char, char, char, char);
|
||||
bool createLogFile();
|
||||
void dateTime(uint16_t*, uint16_t*, uint8_t*); //Used for timestamping with RTC
|
||||
uint16_t getNextSDLogFileNumber();
|
||||
|
|
|
@ -260,14 +260,6 @@ void writeSDLogHeader()
|
|||
//Sets the status variable for TunerStudio
|
||||
void setTS_SD_status()
|
||||
{
|
||||
/*
|
||||
indicator = { sd_status & 1}, "No SD", "SD in", white, black, green, black
|
||||
indicator = { sd_status & 4}, "SD ready", "SD ready", white, black, green, black
|
||||
indicator = { sd_status & 8}, "SD Log", "SD Log", white, black, green, black
|
||||
indicator = { sd_status & 16}, "SD Err", "SD Err", white, black, red, black
|
||||
*/
|
||||
//currentStatus.TS_SD_Status = SD_status;
|
||||
|
||||
if( SD_status == SD_STATUS_ERROR_NO_CARD ) { BIT_CLEAR(currentStatus.TS_SD_Status, SD_STATUS_CARD_PRESENT); } // CARD is not present
|
||||
else { BIT_SET(currentStatus.TS_SD_Status, SD_STATUS_CARD_PRESENT); } // CARD present
|
||||
|
||||
|
@ -380,15 +372,17 @@ void checkForSDStop()
|
|||
}
|
||||
|
||||
/**
|
||||
* Similar to the @getTSLogEntry function, however this returns a full, unadjusted (ie human readable) log entry value.
|
||||
* See logger.h for the field names and order
|
||||
* @param logIndex - The log index required. Note that this is NOT the byte number, but the index in the log
|
||||
* @return Raw, unadjusted value of the log entry. No offset or multiply is applied like it is with the TS log
|
||||
* Will perform a complete format of the SD card to ExFAT.
|
||||
* This will delete all files and create a new empty file system.
|
||||
* The SD status will be set to busy when this happens to prevent any other operations
|
||||
*/
|
||||
void formatExFat()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
//Set the SD status to busy
|
||||
BIT_CLEAR(currentStatus.TS_SD_Status, SD_STATUS_CARD_READY);
|
||||
|
||||
if (sd.cardBegin(SD_CONFIG))
|
||||
{
|
||||
if(sd.format())
|
||||
|
@ -400,9 +394,35 @@ void formatExFat()
|
|||
}
|
||||
}
|
||||
|
||||
if(result == false)
|
||||
if(result == false) { SD_status = SD_STATUS_ERROR_FORMAT_FAIL; }
|
||||
else { BIT_SET(currentStatus.TS_SD_Status, SD_STATUS_CARD_READY); }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes a log file from the SD card
|
||||
*
|
||||
* Log files all have hte same name with a 4 digit number at the end (Eg SPD_0001.csv). TS sends the 4 digits as ASCII characters and they are combined here with the logfile prefix
|
||||
*
|
||||
* @param log1
|
||||
* @param log2
|
||||
* @param log3
|
||||
* @param log4
|
||||
*/
|
||||
void deleteLogFile(char log1, char log2, char log3, char log4)
|
||||
{
|
||||
char logFileName[13];
|
||||
strcpy(logFileName, LOG_FILE_PREFIX);
|
||||
logFileName[4] = log1;
|
||||
logFileName[5] = log2;
|
||||
logFileName[6] = log3;
|
||||
logFileName[7] = log4;
|
||||
logFileName[8] = '.';
|
||||
strcpy(logFileName + 9, LOG_FILE_EXTENSION);
|
||||
//logFileName[8] = '\0';
|
||||
|
||||
if(sd.exists(logFileName))
|
||||
{
|
||||
SD_status = SD_STATUS_ERROR_FORMAT_FAIL;
|
||||
sd.remove(logFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,9 +234,7 @@ void processSerialCommand()
|
|||
|
||||
case 'E': // receive command button commands
|
||||
{
|
||||
byte cmdGroup = serialPayload[1];
|
||||
byte cmdValue = serialPayload[2];
|
||||
uint16_t cmdCombined = word(cmdGroup, cmdValue);
|
||||
uint16_t cmdCombined = word(serialPayload[1], serialPayload[2]);
|
||||
|
||||
if ( ((cmdCombined >= TS_CMD_INJ1_ON) && (cmdCombined <= TS_CMD_IGN8_50PC)) || (cmdCombined == TS_CMD_TEST_ENBL) || (cmdCombined == TS_CMD_TEST_DSBL) )
|
||||
{
|
||||
|
@ -533,27 +531,8 @@ void processSerialCommand()
|
|||
|
||||
|
||||
case 'T': //Send 256 tooth log entries to Tuner Studios tooth logger
|
||||
//6 bytes required:
|
||||
//2 - Page identifier
|
||||
//2 - offset
|
||||
//2 - Length
|
||||
cmdPending = true;
|
||||
if(Serial.available() >= 6)
|
||||
{
|
||||
Serial.read(); // First byte of the page identifier can be ignored. It's always 0
|
||||
Serial.read(); // First byte of the page identifier can be ignored. It's always 0
|
||||
Serial.read(); // First byte of the page identifier can be ignored. It's always 0
|
||||
Serial.read(); // First byte of the page identifier can be ignored. It's always 0
|
||||
Serial.read(); // First byte of the page identifier can be ignored. It's always 0
|
||||
Serial.read(); // First byte of the page identifier can be ignored. It's always 0
|
||||
|
||||
if(currentStatus.toothLogEnabled == true) { generateToothLog(0); } //Sends tooth log values as ints
|
||||
else if (currentStatus.compositeLogEnabled == true) { generateCompositeLog(0); }
|
||||
|
||||
cmdPending = false;
|
||||
}
|
||||
|
||||
|
||||
if(currentStatus.toothLogEnabled == true) { generateToothLog(0); } //Sends tooth log values as ints
|
||||
else if (currentStatus.compositeLogEnabled == true) { generateCompositeLog(0); }
|
||||
|
||||
break;
|
||||
|
||||
|
@ -665,10 +644,6 @@ void processSerialCommand()
|
|||
}
|
||||
break;
|
||||
|
||||
case 'V': // send VE table and constants in binary
|
||||
sendPage();
|
||||
break;
|
||||
|
||||
|
||||
case 'M':
|
||||
{
|
||||
|
@ -738,17 +713,14 @@ void processSerialCommand()
|
|||
else if((SD_arg1 == SD_ERASEFILE_ARG1) && (SD_arg2 == SD_ERASEFILE_ARG2))
|
||||
{
|
||||
//Erase file command
|
||||
//First 4 bytes are the log number in ASCII
|
||||
/*
|
||||
char log1 = Serial.read();
|
||||
char log2 = Serial.read();
|
||||
char log3 = Serial.read();
|
||||
char log4 = Serial.read();
|
||||
*/
|
||||
//We just need the 4 ASCII characters of the file name
|
||||
char log1 = serialPayload[7];
|
||||
char log2 = serialPayload[8];
|
||||
char log3 = serialPayload[9];
|
||||
char log4 = serialPayload[10];
|
||||
|
||||
//Next 2 bytes are the directory block no
|
||||
Serial.read();
|
||||
Serial.read();
|
||||
deleteLogFile(log1, log2, log3, log4);
|
||||
sendSerialReturnCode(SERIAL_RC_OK);
|
||||
}
|
||||
else if((SD_arg1 == SD_SPD_TEST_ARG1) && (SD_arg2 == SD_SPD_TEST_ARG2))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue