Merge pull request #3276 from mikeller/fix_cli_dump_resources

Fixed dump of resources in CLI.
This commit is contained in:
borisbstyle 2017-06-14 14:26:02 +02:00 committed by GitHub
commit 2e4184dc6d
1 changed files with 11 additions and 5 deletions

View File

@ -130,6 +130,8 @@ static uint8_t cliWriteBuffer[sizeof(*cliWriter) + 128];
static char cliBuffer[64]; static char cliBuffer[64];
static uint32_t bufferIndex = 0; static uint32_t bufferIndex = 0;
static bool configIsInCopy = false;
static const char* const emptyName = "-"; static const char* const emptyName = "-";
#ifndef USE_QUAD_MIXER_ONLY #ifndef USE_QUAD_MIXER_ONLY
@ -2761,15 +2763,15 @@ static void printResource(uint8_t dumpMask)
{ {
for (unsigned int i = 0; i < ARRAYLEN(resourceTable); i++) { for (unsigned int i = 0; i < ARRAYLEN(resourceTable); i++) {
const char* owner = ownerNames[resourceTable[i].owner]; const char* owner = ownerNames[resourceTable[i].owner];
const pgRegistry_t* pg = pgFind(resourceTable[i].pgn);
const void *currentConfig; const void *currentConfig;
const void *defaultConfig; const void *defaultConfig;
if (dumpMask & DO_DIFF || dumpMask & SHOW_DEFAULTS) { if (configIsInCopy) {
const pgRegistry_t* pg = pgFind(resourceTable[i].pgn);
currentConfig = pg->copy; currentConfig = pg->copy;
defaultConfig = pg->address; defaultConfig = pg->address;
} else { // Not guaranteed to have initialised default configs in this case } else {
currentConfig = pgFind(resourceTable[i].pgn)->address; currentConfig = pg->address;
defaultConfig = currentConfig; defaultConfig = NULL;
} }
for (int index = 0; index < MAX_RESOURCE_INDEX(resourceTable[i].maxIndex); index++) { for (int index = 0; index < MAX_RESOURCE_INDEX(resourceTable[i].maxIndex); index++) {
@ -2978,6 +2980,8 @@ static void backupConfigs(void)
memcpy(pg->copy, pg->address, pg->size); memcpy(pg->copy, pg->address, pg->size);
} }
} }
configIsInCopy = true;
} }
static void restoreConfigs(void) static void restoreConfigs(void)
@ -2989,6 +2993,8 @@ static void restoreConfigs(void)
memcpy(pg->address, pg->copy, pg->size); memcpy(pg->address, pg->copy, pg->size);
} }
} }
configIsInCopy = false;
} }
static void printConfig(char *cmdline, bool doDiff) static void printConfig(char *cmdline, bool doDiff)