pass in write length (#1447)

This commit is contained in:
Matthew Kennedy 2020-05-17 14:27:26 -07:00 committed by GitHub
parent a2ce3805a8
commit d6186c1cf3
3 changed files with 7 additions and 5 deletions

View File

@ -374,7 +374,7 @@ void writeLogLine(void) {
if (isSdCardAlive()) { if (isSdCardAlive()) {
appendPrintf(&fileLogger, "\r\n"); appendPrintf(&fileLogger, "\r\n");
appendToLog(fileLogger.buffer); appendToLog(fileLogger.buffer, strlen(fileLogger.buffer));
logFileLineIndex++; logFileLineIndex++;
} }
#endif /* EFI_FILE_LOGGING */ #endif /* EFI_FILE_LOGGING */

View File

@ -307,7 +307,7 @@ void readLogFileContent(char *buffer, short fileId, short offset, short length)
/** /**
* @brief Appends specified line to the current log file * @brief Appends specified line to the current log file
*/ */
void appendToLog(const char *line) { void appendToLog(const char *line, size_t lineLength) {
UINT bytesWritten; UINT bytesWritten;
if (!isSdCardAlive()) { if (!isSdCardAlive()) {
@ -316,7 +316,7 @@ void appendToLog(const char *line) {
errorReported = TRUE; errorReported = TRUE;
return; return;
} }
UINT lineLength = strlen(line);
totalLoggedBytes += lineLength; totalLoggedBytes += lineLength;
lockSpi(SPI_NONE); lockSpi(SPI_NONE);
FRESULT err = f_write(&FDLogFile, line, lineLength, &bytesWritten); FRESULT err = f_write(&FDLogFile, line, lineLength, &bytesWritten);
@ -494,7 +494,9 @@ void initMmcCard(void) {
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t)(void*) MMCmonThread, NULL); chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t)(void*) MMCmonThread, NULL);
addConsoleAction("mountsd", MMCmount); addConsoleAction("mountsd", MMCmount);
addConsoleActionS("appendtolog", appendToLog); addConsoleActionS("appendtolog", [](const char* str) {
appendToLog(str, strlen(str));
});
addConsoleAction("umountsd", mmcUnMount); addConsoleAction("umountsd", mmcUnMount);
addConsoleActionS("ls", listDirectory); addConsoleActionS("ls", listDirectory);
addConsoleActionS("del", removeFile); addConsoleActionS("del", removeFile);

View File

@ -16,7 +16,7 @@ extern "C"
void initMmcCard(void); void initMmcCard(void);
bool isSdCardAlive(void); bool isSdCardAlive(void);
void appendToLog(const char *line); void appendToLog(const char *line, size_t length);
void readLogFileContent(char *buffer, short fileId, short offset, short length); void readLogFileContent(char *buffer, short fileId, short offset, short length);