Skip to content

Commit

Permalink
Finding other places to squeeze space for the DESFire config (Log and…
Browse files Browse the repository at this point in the history
… terminal buffers stored on the stack -- adding buffer full messages for INFO)
  • Loading branch information
maxieds committed Feb 12, 2022
1 parent a4672ff commit 3974786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Firmware/Chameleon-Mini/Log.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ void LogGetModeList(char *List, uint16_t BufferSize) {
void LogSRAMToFRAM(void) {
if (LogMemLeft < LOG_SIZE) {
uint16_t FRAM_Free = FRAM_LOG_SIZE - (LogFRAMAddr - FRAM_LOG_START_ADDR);

if (FRAM_Free >= LOG_SIZE - LogMemLeft) {
MemoryWriteBlock(LogMem, LogFRAMAddr, LOG_SIZE - LogMemLeft);
LogFRAMAddr += LOG_SIZE - LogMemLeft;
Expand All @@ -223,13 +222,15 @@ void LogSRAMToFRAM(void) {
// not everything fits in FRAM, simply write as much as possible to FRAM
MemoryWriteBlock(LogMem, LogFRAMAddr, FRAM_Free);
memmove(LogMem, LogMem + FRAM_Free, LOG_SIZE - FRAM_Free); // FRAM_Free is < LOG_SIZE - LogMemLeft and thus also < LOG_SIZE

LogMemPtr -= FRAM_Free;
LogMemLeft += FRAM_Free;
LogFRAMAddr += FRAM_Free;
MemoryWriteBlock(&LogFRAMAddr, FRAM_LOG_ADDR_ADDR, 2);
} else {
// TODO: handle the case in which the FRAM is full
// TODO: handle the case in which the FRAM is full ???
// Notify the user by repeatedly blinking the LED:
LEDHook(LED_LOG_MEM_FULL, LED_BLINK_8X);
LEDHook(LED_LOG_MEM_FULL, LED_BLINK_8X);
}
}
}
7 changes: 7 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ static void DecodeCommand(void) {
/* Send optional answer */
TerminalSendString(pTerminalBuffer);
TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER));
if (StringLength(pTerminalBuffer, TERMINAL_BUFFER_SIZE) + 1 >= TERMINAL_BUFFER_SIZE) {
// Notify the user that the command line output is truncated. This can come up in the
// 'CONFIG=MF_DESFIRE' variants where the Makefile setting 'MEMORY_LIMITED_TESTING' is
// enabled by default to save space for other necessary components.
TerminalSendStringP(PSTR("-- OUTPUT TRUNCATED --"));
TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER));
}
}
}

Expand Down

0 comments on commit 3974786

Please sign in to comment.