From 444d552d5a9ecaba1739609cd8af41e0dbea7f24 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 20 Sep 2016 20:04:02 +0200 Subject: [PATCH] CLI improvements: * repeat last command on empty line input * added SD card read test [testsd] (multi block read of last sectors) --- radio/src/cli.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index ea7e422c4..cf568eddb 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -30,7 +30,7 @@ OS_TID cliTaskId; TaskStack _ALIGNED(8) cliStack; // stack must be aligned to 8 bytes otherwise printf for %f does not work! Fifo cliRxFifo; uint8_t cliTracesEnabled = true; -// char cliLastLine[CLI_COMMAND_MAX_LEN+1]; +char cliLastLine[CLI_COMMAND_MAX_LEN+1]; typedef int (* CliFunction) (const char ** args); int cliExecLine(char * line); @@ -228,6 +228,63 @@ int cliReadSD(const char ** argv) return 0; } +int cliTestSD(const char ** argv) +{ + // Do the read test on the SD card and report back the result + + // get sector count + uint32_t sectorCount; + if (disk_ioctl(0, GET_SECTOR_COUNT, §orCount) != RES_OK) { + serialPrint("Error: can't read sector count"); + return 0; + } + serialPrint("SD card has %u sectors", sectorCount); + + // read last 16 sectors one sector at the time + serialPrint("Starting single sector read test, reading 16 sectors one by one"); + uint8_t * buffer = (uint8_t*) malloc(512); + for(uint32_t s = sectorCount - 16; s" }, { "read", cliRead, "" }, { "readsd", cliReadSD, " " }, + { "testsd", cliTestSD, "" }, { "play", cliPlay, "" }, { "print", cliDisplay, "
[] | " }, { "p", cliDisplay, "
[] | " }, @@ -847,7 +905,14 @@ void cliTask(void * pdata) // enter serialCrlf(); line[pos] = '\0'; - // strcpy(cliLastLine, line); + if (pos == 0 && cliLastLine[0]) { + // execute (repeat) last command + strcpy(line, cliLastLine); + } + else { + // save new command + strcpy(cliLastLine, line); + } cliExecLine(line); pos = 0; cliPrompt();