From acab315f817376a98f5241f56490ccb560199807 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 11 Jan 2024 09:02:41 -0500 Subject: [PATCH 1/2] Fix #89, correct format spec strings and data types Resolves mismatches between format strings and the data types --- fsw/src/mm_app.c | 6 +++--- fsw/src/mm_dump.c | 14 +++++++------- fsw/src/mm_mem16.c | 4 ++-- fsw/src/mm_mem32.c | 6 +++--- unit-test/mm_mem16_tests.c | 12 ++---------- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/fsw/src/mm_app.c b/fsw/src/mm_app.c index 7e506ef..146a483 100644 --- a/fsw/src/mm_app.c +++ b/fsw/src/mm_app.c @@ -170,7 +170,7 @@ CFE_Status_t MM_AppInit(void) Status = CFE_SB_CreatePipe(&MM_AppData.CmdPipe, MM_CMD_PIPE_DEPTH, "MM_CMD_PIPE"); if (Status != CFE_SUCCESS) { - CFE_EVS_SendEvent(MM_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating SB Pipe, RC = 0x%08X", Status); + CFE_EVS_SendEvent(MM_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating SB Pipe, RC = 0x%08X", (unsigned int)Status); return Status; } @@ -181,7 +181,7 @@ CFE_Status_t MM_AppInit(void) if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(MM_HK_SUB_ERR_EID, CFE_EVS_EventType_ERROR, "Error Subscribing to HK Request, RC = 0x%08X", - Status); + (unsigned int)Status); return Status; } @@ -192,7 +192,7 @@ CFE_Status_t MM_AppInit(void) if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(MM_CMD_SUB_ERR_EID, CFE_EVS_EventType_ERROR, "Error Subscribing to MM Command, RC = 0x%08X", - Status); + (unsigned int)Status); return Status; } diff --git a/fsw/src/mm_dump.c b/fsw/src/mm_dump.c index 27f2ce4..7676708 100644 --- a/fsw/src/mm_dump.c +++ b/fsw/src/mm_dump.c @@ -169,7 +169,7 @@ bool MM_PeekMem(const MM_PeekCmd_t *CmdPtr, cpuaddr SrcAddress) else { CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR, - "PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", PSP_Status, (void *)SrcAddress, + "PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", (int)PSP_Status, (void *)SrcAddress, (unsigned int)DataSize); } @@ -395,7 +395,7 @@ bool MM_DumpMemToFile(osal_id_t FileHandle, const char *FileName, const MM_LoadD { BytesRemaining = 0; CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_write error received: RC = %d, Expected = %u, File = '%s'", OS_Status, + "OS_write error received: RC = %d, Expected = %u, File = '%s'", (int)OS_Status, (unsigned int)SegmentSize, FileName); } } @@ -434,7 +434,7 @@ bool MM_WriteFileHeaders(const char *FileName, osal_id_t FileHandle, CFE_FS_Head /* We either got an error or didn't write as much data as expected */ Valid = false; CFE_EVS_SendEvent(MM_CFE_FS_WRITEHDR_ERR_EID, CFE_EVS_EventType_ERROR, - "CFE_FS_WriteHeader error received: RC = %d Expected = %d File = '%s'", OS_Status, + "CFE_FS_WriteHeader error received: RC = %d Expected = %d File = '%s'", (int)OS_Status, (int)sizeof(CFE_FS_Header_t), FileName); } /* end CFE_FS_WriteHeader if */ @@ -449,7 +449,7 @@ bool MM_WriteFileHeaders(const char *FileName, osal_id_t FileHandle, CFE_FS_Head /* We either got an error or didn't read as much data as expected */ Valid = false; CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_write error received: RC = %d Expected = %u File = '%s'", OS_Status, + "OS_write error received: RC = %d Expected = %u File = '%s'", (int)OS_Status, (unsigned int)sizeof(MM_LoadDumpFileHeader_t), FileName); } /* end OS_write if */ @@ -593,7 +593,7 @@ bool MM_FillDumpInEventBuffer(cpuaddr SrcAddress, const MM_DumpInEventCmd_t *Cmd /* CFE_PSP_MemRead32 error */ Valid = false; CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR, - "PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM32", PSP_Status, + "PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM32", (int)PSP_Status, (void *)SrcAddress, (void *)DumpBuffer); /* Stop load dump buffer loop */ break; @@ -617,7 +617,7 @@ bool MM_FillDumpInEventBuffer(cpuaddr SrcAddress, const MM_DumpInEventCmd_t *Cmd /* CFE_PSP_MemRead16 error */ Valid = false; CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR, - "PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM16", PSP_Status, + "PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM16", (int)PSP_Status, (void *)SrcAddress, (void *)DumpBuffer); /* Stop load dump buffer loop */ break; @@ -641,7 +641,7 @@ bool MM_FillDumpInEventBuffer(cpuaddr SrcAddress, const MM_DumpInEventCmd_t *Cmd /* CFE_PSP_MemRead8 error */ Valid = false; CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR, - "PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM8", PSP_Status, + "PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM8", (int)PSP_Status, (void *)SrcAddress, (void *)DumpBuffer); /* Stop load dump buffer loop */ break; diff --git a/fsw/src/mm_mem16.c b/fsw/src/mm_mem16.c index 9b777f8..1c5a261 100644 --- a/fsw/src/mm_mem16.c +++ b/fsw/src/mm_mem16.c @@ -235,8 +235,8 @@ bool MM_FillMem16(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr) { NewBytesRemaining = BytesRemaining - (BytesRemaining % 2); CFE_EVS_SendEvent(MM_FILL_MEM16_ALIGN_WARN_INF_EID, CFE_EVS_EventType_INFORMATION, - "MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %d to %d.", BytesRemaining, - NewBytesRemaining); + "MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %u to %u.", (unsigned int)BytesRemaining, + (unsigned int)NewBytesRemaining); BytesRemaining = NewBytesRemaining; } diff --git a/fsw/src/mm_mem32.c b/fsw/src/mm_mem32.c index a531b9e..4293843 100644 --- a/fsw/src/mm_mem32.c +++ b/fsw/src/mm_mem32.c @@ -91,7 +91,7 @@ bool MM_LoadMem32FromFile(osal_id_t FileHandle, const char *FileName, const MM_L /* CFE_PSP_MemWrite32 error */ BytesRemaining = 0; CFE_EVS_SendEvent(MM_PSP_WRITE_ERR_EID, CFE_EVS_EventType_ERROR, - "PSP write memory error: RC=%d, Address=%p, MemType=MEM32", PSP_Status, + "PSP write memory error: RC=%d, Address=%p, MemType=MEM32", (int)PSP_Status, (void *)DataPointer32); /* Stop load segment loop */ break; @@ -236,8 +236,8 @@ bool MM_FillMem32(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr) { NewBytesRemaining = BytesRemaining - (BytesRemaining % 4); CFE_EVS_SendEvent(MM_FILL_MEM32_ALIGN_WARN_INF_EID, CFE_EVS_EventType_INFORMATION, - "MM_FillMem32 NumOfBytes not multiple of 4. Reducing from %d to %d.", BytesRemaining, - NewBytesRemaining); + "MM_FillMem32 NumOfBytes not multiple of 4. Reducing from %d to %d.", (int)BytesRemaining, + (int)NewBytesRemaining); BytesRemaining = NewBytesRemaining; } diff --git a/unit-test/mm_mem16_tests.c b/unit-test/mm_mem16_tests.c index be88b25..5539092 100644 --- a/unit-test/mm_mem16_tests.c +++ b/unit-test/mm_mem16_tests.c @@ -470,14 +470,10 @@ void MM_FillMem16_Test_Align(void) { MM_FillMemCmd_t CmdPacket; uint32 DestAddress = 1; - CmdPacket.Payload.NumOfBytes = 3; - CmdPacket.Payload.FillPattern = 3; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; bool Result; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %%d to %%d."); + CmdPacket.Payload.NumOfBytes = 3; + CmdPacket.Payload.FillPattern = 3; /* Execute the function being tested */ Result = MM_FillMem16(DestAddress, &CmdPacket); @@ -488,10 +484,6 @@ void MM_FillMem16_Test_Align(void) UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, MM_FILL_MEM16_ALIGN_WARN_INF_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1", From e2399b9c570806bd21ef1e7c29ea9fd39632004c Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 11 Jan 2024 09:05:14 -0500 Subject: [PATCH 2/2] Fix #89, apply clang-format Resolves whitespace errors, committed separately as MM had accumulated a fair number of other mismatches. --- fsw/src/mm_app.c | 256 +++++++++++------------ fsw/src/mm_dump.c | 405 +++++++++++++++++++------------------ fsw/src/mm_mem16.c | 6 +- fsw/src/mm_mem32.c | 2 +- unit-test/mm_mem16_tests.c | 24 ++- 5 files changed, 352 insertions(+), 341 deletions(-) diff --git a/fsw/src/mm_app.c b/fsw/src/mm_app.c index 146a483..c4267de 100644 --- a/fsw/src/mm_app.c +++ b/fsw/src/mm_app.c @@ -170,7 +170,8 @@ CFE_Status_t MM_AppInit(void) Status = CFE_SB_CreatePipe(&MM_AppData.CmdPipe, MM_CMD_PIPE_DEPTH, "MM_CMD_PIPE"); if (Status != CFE_SUCCESS) { - CFE_EVS_SendEvent(MM_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating SB Pipe, RC = 0x%08X", (unsigned int)Status); + CFE_EVS_SendEvent(MM_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating SB Pipe, RC = 0x%08X", + (unsigned int)Status); return Status; } @@ -332,7 +333,7 @@ void MM_AppPipe(const CFE_SB_Buffer_t *BufPtr) } break; - case MM_ENABLE_EEPROM_WRITE_CC: + case MM_ENABLE_EEPROM_WRITE_CC: if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_EepromWriteEnaCmd_t))) { CmdResult = MM_EepromWriteEnaCmd(BufPtr); @@ -386,15 +387,15 @@ void MM_AppPipe(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void MM_HousekeepingCmd(const CFE_SB_Buffer_t *BufPtr) { - /* - ** Send housekeeping telemetry packet - */ - CFE_SB_TimeStampMsg(&MM_AppData.HkPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&MM_AppData.HkPacket.TlmHeader.Msg, true); + /* + ** Send housekeeping telemetry packet + */ + CFE_SB_TimeStampMsg(&MM_AppData.HkPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&MM_AppData.HkPacket.TlmHeader.Msg, true); - /* - ** This command does not affect the command execution counter - */ + /* + ** This command does not affect the command execution counter + */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -404,12 +405,12 @@ void MM_HousekeepingCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool MM_NoopCmd(const CFE_SB_Buffer_t *BufPtr) { - bool Result = false; - MM_AppData.HkPacket.Payload.LastAction = MM_NOOP; - Result = true; + bool Result = false; + MM_AppData.HkPacket.Payload.LastAction = MM_NOOP; + Result = true; - CFE_EVS_SendEvent(MM_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", - MM_MAJOR_VERSION, MM_MINOR_VERSION, MM_REVISION, MM_MISSION_REV); + CFE_EVS_SendEvent(MM_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", + MM_MAJOR_VERSION, MM_MINOR_VERSION, MM_REVISION, MM_MISSION_REV); return Result; } @@ -421,13 +422,13 @@ bool MM_NoopCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool MM_ResetCmd(const CFE_SB_Buffer_t *BufPtr) { - bool Result = false; - MM_AppData.HkPacket.Payload.LastAction = MM_RESET; - MM_AppData.HkPacket.Payload.CmdCounter = 0; - MM_AppData.HkPacket.Payload.ErrCounter = 0; + bool Result = false; + MM_AppData.HkPacket.Payload.LastAction = MM_RESET; + MM_AppData.HkPacket.Payload.CmdCounter = 0; + MM_AppData.HkPacket.Payload.ErrCounter = 0; - CFE_EVS_SendEvent(MM_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command received"); - Result = true; + CFE_EVS_SendEvent(MM_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command received"); + Result = true; return Result; } @@ -441,46 +442,46 @@ bool MM_LookupSymbolCmd(const CFE_SB_Buffer_t *BufPtr) { int32 OS_Status = OS_ERROR; /* Set to error instead of success since we explicitly test for success */ cpuaddr ResolvedAddr = 0; - const MM_LookupSymCmd_t *CmdPtr = NULL; - bool Result = false; + const MM_LookupSymCmd_t *CmdPtr = NULL; + bool Result = false; char SymName[OS_MAX_SYM_LEN]; - CmdPtr = ((MM_LookupSymCmd_t *)BufPtr); + CmdPtr = ((MM_LookupSymCmd_t *)BufPtr); - /* Make sure string is null terminated before attempting to process it */ - CFE_SB_MessageStringGet(SymName, CmdPtr->Payload.SymName, NULL, sizeof(SymName), sizeof(CmdPtr->Payload.SymName)); + /* Make sure string is null terminated before attempting to process it */ + CFE_SB_MessageStringGet(SymName, CmdPtr->Payload.SymName, NULL, sizeof(SymName), sizeof(CmdPtr->Payload.SymName)); + /* + ** Check if the symbol name string is a nul string + */ + if (strlen(SymName) == 0) + { + CFE_EVS_SendEvent(MM_SYMNAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, + "NUL (empty) string specified as symbol name"); + } + else + { /* - ** Check if the symbol name string is a nul string + ** If symbol name is not an empty string look it up using the OSAL API */ - if (strlen(SymName) == 0) + OS_Status = OS_SymbolLookup(&ResolvedAddr, SymName); + if (OS_Status == OS_SUCCESS) { - CFE_EVS_SendEvent(MM_SYMNAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, - "NUL (empty) string specified as symbol name"); + /* Update telemetry */ + MM_AppData.HkPacket.Payload.LastAction = MM_SYM_LOOKUP; + MM_AppData.HkPacket.Payload.Address = ResolvedAddr; + + CFE_EVS_SendEvent(MM_SYM_LOOKUP_INF_EID, CFE_EVS_EventType_INFORMATION, + "Symbol Lookup Command: Name = '%s' Addr = %p", SymName, (void *)ResolvedAddr); + Result = true; } else { - /* - ** If symbol name is not an empty string look it up using the OSAL API - */ - OS_Status = OS_SymbolLookup(&ResolvedAddr, SymName); - if (OS_Status == OS_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.Payload.LastAction = MM_SYM_LOOKUP; - MM_AppData.HkPacket.Payload.Address = ResolvedAddr; - - CFE_EVS_SendEvent(MM_SYM_LOOKUP_INF_EID, CFE_EVS_EventType_INFORMATION, - "Symbol Lookup Command: Name = '%s' Addr = %p", SymName, (void *)ResolvedAddr); - Result = true; - } - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", SymName); - } + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", SymName); + } - } /* end strlen(CmdPtr->Payload.SymName) == 0 else */ + } /* end strlen(CmdPtr->Payload.SymName) == 0 else */ return Result; } @@ -494,43 +495,44 @@ bool MM_SymTblToFileCmd(const CFE_SB_Buffer_t *BufPtr) { int32 OS_Status = OS_ERROR; /* Set to error instead of success since we explicitly test for success */ char FileName[OS_MAX_PATH_LEN]; - const MM_SymTblToFileCmd_t *CmdPtr = NULL; - bool Result = false; + const MM_SymTblToFileCmd_t *CmdPtr = NULL; + bool Result = false; - CmdPtr = ((MM_SymTblToFileCmd_t *)BufPtr); + CmdPtr = ((MM_SymTblToFileCmd_t *)BufPtr); - /* Make sure string is null terminated before attempting to process it */ - CFE_SB_MessageStringGet(FileName, CmdPtr->Payload.FileName, NULL, sizeof(FileName), sizeof(CmdPtr->Payload.FileName)); + /* Make sure string is null terminated before attempting to process it */ + CFE_SB_MessageStringGet(FileName, CmdPtr->Payload.FileName, NULL, sizeof(FileName), + sizeof(CmdPtr->Payload.FileName)); - /* - ** Check if the filename string is a nul string - */ - if (strlen(FileName) == 0) + /* + ** Check if the filename string is a nul string + */ + if (strlen(FileName) == 0) + { + CFE_EVS_SendEvent(MM_SYMFILENAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, + "NUL (empty) string specified as symbol dump file name"); + } + else + { + OS_Status = OS_SymbolTableDump(FileName, MM_MAX_DUMP_FILE_DATA_SYMTBL); + if (OS_Status == OS_SUCCESS) { - CFE_EVS_SendEvent(MM_SYMFILENAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, - "NUL (empty) string specified as symbol dump file name"); + /* Update telemetry */ + MM_AppData.HkPacket.Payload.LastAction = MM_SYMTBL_SAVE; + strncpy(MM_AppData.HkPacket.Payload.FileName, FileName, OS_MAX_PATH_LEN); + + CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, + "Symbol Table Dump to File Started: Name = '%s'", FileName); + Result = true; } else { - OS_Status = OS_SymbolTableDump(FileName, MM_MAX_DUMP_FILE_DATA_SYMTBL); - if (OS_Status == OS_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.Payload.LastAction = MM_SYMTBL_SAVE; - strncpy(MM_AppData.HkPacket.Payload.FileName, FileName, OS_MAX_PATH_LEN); - - CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Symbol Table Dump to File Started: Name = '%s'", FileName); - Result = true; - } - else - { - CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_FAIL_ERR_EID, CFE_EVS_EventType_ERROR, - "Error dumping symbol table, OS_Status= 0x%X, File='%s'", (unsigned int)OS_Status, - FileName); - } + CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_FAIL_ERR_EID, CFE_EVS_EventType_ERROR, + "Error dumping symbol table, OS_Status= 0x%X, File='%s'", (unsigned int)OS_Status, + FileName); + } - } /* end strlen(FileName) == 0 else */ + } /* end strlen(FileName) == 0 else */ return Result; } @@ -542,33 +544,33 @@ bool MM_SymTblToFileCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool MM_EepromWriteEnaCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_Status_t cFE_Status = CFE_PSP_ERROR; /* Set to error since we explicitly test for success */ - MM_EepromWriteEnaCmd_t *CmdPtr = NULL; - bool Result = false; + CFE_Status_t cFE_Status = CFE_PSP_ERROR; /* Set to error since we explicitly test for success */ + MM_EepromWriteEnaCmd_t *CmdPtr = NULL; + bool Result = false; - CmdPtr = ((MM_EepromWriteEnaCmd_t *)BufPtr); + CmdPtr = ((MM_EepromWriteEnaCmd_t *)BufPtr); - /* - ** Call the cFE to write-enable the requested bank - */ - cFE_Status = CFE_PSP_EepromWriteEnable(CmdPtr->Payload.Bank); - if (cFE_Status == CFE_PSP_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.Payload.LastAction = MM_EEPROMWRITE_ENA; - MM_AppData.HkPacket.Payload.MemType = MM_EEPROM; + /* + ** Call the cFE to write-enable the requested bank + */ + cFE_Status = CFE_PSP_EepromWriteEnable(CmdPtr->Payload.Bank); + if (cFE_Status == CFE_PSP_SUCCESS) + { + /* Update telemetry */ + MM_AppData.HkPacket.Payload.LastAction = MM_EEPROMWRITE_ENA; + MM_AppData.HkPacket.Payload.MemType = MM_EEPROM; - CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_INF_EID, CFE_EVS_EventType_INFORMATION, - "EEPROM bank %d write enabled, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, - (unsigned int)cFE_Status); - Result = true; - } - else - { - CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_ERR_EID, CFE_EVS_EventType_ERROR, - "Error requesting EEPROM bank %d write enable, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, - (unsigned int)cFE_Status); - } + CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_INF_EID, CFE_EVS_EventType_INFORMATION, + "EEPROM bank %d write enabled, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, + (unsigned int)cFE_Status); + Result = true; + } + else + { + CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_ERR_EID, CFE_EVS_EventType_ERROR, + "Error requesting EEPROM bank %d write enable, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, + (unsigned int)cFE_Status); + } return Result; } @@ -580,32 +582,32 @@ bool MM_EepromWriteEnaCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool MM_EepromWriteDisCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_Status_t cFE_Status = CFE_PSP_ERROR; /* Set to error since we explicitly test for success */ - MM_EepromWriteDisCmd_t *CmdPtr = NULL; - bool Result = false; + CFE_Status_t cFE_Status = CFE_PSP_ERROR; /* Set to error since we explicitly test for success */ + MM_EepromWriteDisCmd_t *CmdPtr = NULL; + bool Result = false; - CmdPtr = ((MM_EepromWriteDisCmd_t *)BufPtr); + CmdPtr = ((MM_EepromWriteDisCmd_t *)BufPtr); - /* - ** Call the cFE to write-enable the requested bank - */ - cFE_Status = CFE_PSP_EepromWriteDisable(CmdPtr->Payload.Bank); - if (cFE_Status == CFE_PSP_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.Payload.LastAction = MM_EEPROMWRITE_DIS; - MM_AppData.HkPacket.Payload.MemType = MM_EEPROM; - Result = true; - CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_INF_EID, CFE_EVS_EventType_INFORMATION, - "EEPROM bank %d write disabled, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, - (unsigned int)cFE_Status); - } - else - { - CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_ERR_EID, CFE_EVS_EventType_ERROR, - "Error requesting EEPROM bank %d write disable, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, - (unsigned int)cFE_Status); - } + /* + ** Call the cFE to write-enable the requested bank + */ + cFE_Status = CFE_PSP_EepromWriteDisable(CmdPtr->Payload.Bank); + if (cFE_Status == CFE_PSP_SUCCESS) + { + /* Update telemetry */ + MM_AppData.HkPacket.Payload.LastAction = MM_EEPROMWRITE_DIS; + MM_AppData.HkPacket.Payload.MemType = MM_EEPROM; + Result = true; + CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_INF_EID, CFE_EVS_EventType_INFORMATION, + "EEPROM bank %d write disabled, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, + (unsigned int)cFE_Status); + } + else + { + CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_ERR_EID, CFE_EVS_EventType_ERROR, + "Error requesting EEPROM bank %d write disable, cFE_Status= 0x%X", (int)CmdPtr->Payload.Bank, + (unsigned int)cFE_Status); + } return Result; } diff --git a/fsw/src/mm_dump.c b/fsw/src/mm_dump.c index 7676708..cc6bcb6 100644 --- a/fsw/src/mm_dump.c +++ b/fsw/src/mm_dump.c @@ -49,39 +49,39 @@ bool MM_PeekCmd(const CFE_SB_Buffer_t *BufPtr) { bool Valid; const MM_PeekCmd_t *CmdPtr; - cpuaddr SrcAddress = 0; - bool Result = false; + cpuaddr SrcAddress = 0; + bool Result = false; MM_SymAddr_t SrcSymAddress; - CmdPtr = ((MM_PeekCmd_t *)BufPtr); + CmdPtr = ((MM_PeekCmd_t *)BufPtr); - SrcSymAddress = CmdPtr->Payload.SrcSymAddress; + SrcSymAddress = CmdPtr->Payload.SrcSymAddress; - /* Resolve the symbolic address in command message */ - Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + /* Resolve the symbolic address in command message */ + Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); - if (Valid == true) - { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyPeekPokeParams(SrcAddress, CmdPtr->Payload.MemType, CmdPtr->Payload.DataSize); - - /* Check the specified memory type and call the appropriate routine */ - if (Valid == true) - { - /* - ** We use this single peek routine for all memory types - ** (including the optional ones) - */ - Result = MM_PeekMem(CmdPtr, SrcAddress); - } + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = MM_VerifyPeekPokeParams(SrcAddress, CmdPtr->Payload.MemType, CmdPtr->Payload.DataSize); - } /* end MM_ResolveSymAddr if */ - else + /* Check the specified memory type and call the appropriate routine */ + if (Valid == true) { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", CmdPtr->Payload.SrcSymAddress.SymName); + /* + ** We use this single peek routine for all memory types + ** (including the optional ones) + */ + Result = MM_PeekMem(CmdPtr, SrcAddress); } + } /* end MM_ResolveSymAddr if */ + else + { + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", CmdPtr->Payload.SrcSymAddress.SymName); + } + return Result; } @@ -169,8 +169,8 @@ bool MM_PeekMem(const MM_PeekCmd_t *CmdPtr, cpuaddr SrcAddress) else { CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR, - "PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", (int)PSP_Status, (void *)SrcAddress, - (unsigned int)DataSize); + "PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", (int)PSP_Status, + (void *)SrcAddress, (unsigned int)DataSize); } return ValidPeek; @@ -193,163 +193,165 @@ bool MM_DumpMemToFileCmd(const CFE_SB_Buffer_t *BufPtr) CFE_FS_Header_t CFEFileHeader; MM_LoadDumpFileHeader_t MMFileHeader; - CmdPtr = ((MM_DumpMemToFileCmd_t *)BufPtr); + CmdPtr = ((MM_DumpMemToFileCmd_t *)BufPtr); + + SrcSymAddress = CmdPtr->Payload.SrcSymAddress; - SrcSymAddress = CmdPtr->Payload.SrcSymAddress; + /* Make sure strings are null terminated before attempting to process them */ + CFE_SB_MessageStringGet(FileName, CmdPtr->Payload.FileName, NULL, sizeof(FileName), + sizeof(CmdPtr->Payload.FileName)); - /* Make sure strings are null terminated before attempting to process them */ - CFE_SB_MessageStringGet(FileName, CmdPtr->Payload.FileName, NULL, sizeof(FileName), sizeof(CmdPtr->Payload.FileName)); + /* Resolve the symbolic address in command message */ + Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); - /* Resolve the symbolic address in command message */ - Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = + MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->Payload.MemType, CmdPtr->Payload.NumOfBytes, MM_VERIFY_DUMP); if (Valid == true) { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->Payload.MemType, CmdPtr->Payload.NumOfBytes, MM_VERIFY_DUMP); - - if (Valid == true) + /* + ** Initialize the cFE primary file header structure + */ + CFE_FS_InitHeader(&CFEFileHeader, MM_CFE_HDR_DESCRIPTION, MM_CFE_HDR_SUBTYPE); + + /* + ** Initialize the MM secondary file header structure + */ + memset(&MMFileHeader, 0, sizeof(MMFileHeader)); + MMFileHeader.SymAddress.SymName[0] = MM_CLEAR_SYMNAME; + + /* + ** Copy command data to file secondary header + */ + MMFileHeader.SymAddress.Offset = SrcAddress; + MMFileHeader.MemType = CmdPtr->Payload.MemType; + MMFileHeader.NumOfBytes = CmdPtr->Payload.NumOfBytes; + + /* + ** Create and open dump file + */ + OS_Status = + OS_OpenCreate(&FileHandle, FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + if (OS_Status == OS_SUCCESS) { - /* - ** Initialize the cFE primary file header structure - */ - CFE_FS_InitHeader(&CFEFileHeader, MM_CFE_HDR_DESCRIPTION, MM_CFE_HDR_SUBTYPE); - - /* - ** Initialize the MM secondary file header structure - */ - memset(&MMFileHeader, 0, sizeof(MMFileHeader)); - MMFileHeader.SymAddress.SymName[0] = MM_CLEAR_SYMNAME; - - /* - ** Copy command data to file secondary header - */ - MMFileHeader.SymAddress.Offset = SrcAddress; - MMFileHeader.MemType = CmdPtr->Payload.MemType; - MMFileHeader.NumOfBytes = CmdPtr->Payload.NumOfBytes; - - /* - ** Create and open dump file - */ - OS_Status = - OS_OpenCreate(&FileHandle, FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - if (OS_Status == OS_SUCCESS) + /* Write the file headers */ + Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); + if (Valid == true) { - /* Write the file headers */ - Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); - if (Valid == true) + switch (MMFileHeader.MemType) { - switch (MMFileHeader.MemType) - { - case MM_RAM: - case MM_EEPROM: - Valid = MM_DumpMemToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_RAM: + case MM_EEPROM: + Valid = MM_DumpMemToFile(FileHandle, FileName, &MMFileHeader); + break; #ifdef MM_OPT_CODE_MEM32_MEMTYPE - case MM_MEM32: - Valid = MM_DumpMem32ToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_MEM32: + Valid = MM_DumpMem32ToFile(FileHandle, FileName, &MMFileHeader); + break; #endif /* MM_OPT_CODE_MEM32_MEMTYPE */ #ifdef MM_OPT_CODE_MEM16_MEMTYPE - case MM_MEM16: - Valid = MM_DumpMem16ToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_MEM16: + Valid = MM_DumpMem16ToFile(FileHandle, FileName, &MMFileHeader); + break; #endif /* MM_OPT_CODE_MEM16_MEMTYPE */ #ifdef MM_OPT_CODE_MEM8_MEMTYPE - case MM_MEM8: - Valid = MM_DumpMem8ToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_MEM8: + Valid = MM_DumpMem8ToFile(FileHandle, FileName, &MMFileHeader); + break; #endif /* MM_OPT_CODE_MEM8_MEMTYPE */ - default: - /* This branch will never be executed. MMFileHeader.MemType will always - * be valid value for this switch statement it is verified via - * MM_VerifyFileLoadDumpParams */ - Valid = false; - break; - } + default: + /* This branch will never be executed. MMFileHeader.MemType will always + * be valid value for this switch statement it is verified via + * MM_VerifyFileLoadDumpParams */ + Valid = false; + break; + } - if (Valid == true) + if (Valid == true) + { + /* + ** Compute CRC of dumped data + */ + OS_Status = OS_lseek(FileHandle, (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t)), + OS_SEEK_SET); + if (OS_Status != (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t))) { - /* - ** Compute CRC of dumped data - */ - OS_Status = OS_lseek( - FileHandle, (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t)), OS_SEEK_SET); - if (OS_Status != (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t))) + Valid = false; + } + else + { + OS_Status = MM_ComputeCRCFromFile(FileHandle, &MMFileHeader.Crc, MM_DUMP_FILE_CRC_TYPE); + if (OS_Status == OS_SUCCESS) { - Valid = false; - } + /* + ** Rewrite the file headers. The subfunctions will take care of moving + ** the file pointer to the beginning of the file so we don't need to do it + ** here. + */ + Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); + + } /* end MM_ComputeCRCFromFile if */ else { - OS_Status = MM_ComputeCRCFromFile(FileHandle, &MMFileHeader.Crc, MM_DUMP_FILE_CRC_TYPE); - if (OS_Status == OS_SUCCESS) - { - /* - ** Rewrite the file headers. The subfunctions will take care of moving - ** the file pointer to the beginning of the file so we don't need to do it - ** here. - */ - Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); - - } /* end MM_ComputeCRCFromFile if */ - else - { - Valid = false; - CFE_EVS_SendEvent(MM_COMPUTECRCFROMFILE_ERR_EID, CFE_EVS_EventType_ERROR, - "MM_ComputeCRCFromFile error received: RC = 0x%08X File = '%s'", - (unsigned int)OS_Status, FileName); - } + Valid = false; + CFE_EVS_SendEvent(MM_COMPUTECRCFROMFILE_ERR_EID, CFE_EVS_EventType_ERROR, + "MM_ComputeCRCFromFile error received: RC = 0x%08X File = '%s'", + (unsigned int)OS_Status, FileName); } - - } /* end Valid == true if */ - - if (Valid == true) - { - CFE_EVS_SendEvent( - MM_DMP_MEM_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Dump Memory To File Command: Dumped %d bytes from address %p to file '%s'", - (int)MM_AppData.HkPacket.Payload.BytesProcessed, (void *)SrcAddress, FileName); - /* - ** Update last action statistics - */ - MM_AppData.HkPacket.Payload.LastAction = MM_DUMP_TO_FILE; - strncpy(MM_AppData.HkPacket.Payload.FileName, FileName, OS_MAX_PATH_LEN); - MM_AppData.HkPacket.Payload.MemType = CmdPtr->Payload.MemType; - MM_AppData.HkPacket.Payload.Address = SrcAddress; - MM_AppData.HkPacket.Payload.BytesProcessed = CmdPtr->Payload.NumOfBytes; } - } /* end MM_WriteFileHeaders if */ + } /* end Valid == true if */ - /* Close dump file */ - if ((OS_Status = OS_close(FileHandle)) != OS_SUCCESS) + if (Valid == true) { - Valid = false; - CFE_EVS_SendEvent(MM_OS_CLOSE_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_close error received: RC = 0x%08X File = '%s'", (unsigned int)OS_Status, + CFE_EVS_SendEvent(MM_DMP_MEM_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, + "Dump Memory To File Command: Dumped %d bytes from address %p to file '%s'", + (int)MM_AppData.HkPacket.Payload.BytesProcessed, (void *)SrcAddress, FileName); + /* + ** Update last action statistics + */ + MM_AppData.HkPacket.Payload.LastAction = MM_DUMP_TO_FILE; + strncpy(MM_AppData.HkPacket.Payload.FileName, FileName, OS_MAX_PATH_LEN); + MM_AppData.HkPacket.Payload.MemType = CmdPtr->Payload.MemType; + MM_AppData.HkPacket.Payload.Address = SrcAddress; + MM_AppData.HkPacket.Payload.BytesProcessed = CmdPtr->Payload.NumOfBytes; } - } /* end OS_OpenCreate if */ - else + } /* end MM_WriteFileHeaders if */ + + /* Close dump file */ + if ((OS_Status = OS_close(FileHandle)) != OS_SUCCESS) { Valid = false; - CFE_EVS_SendEvent(MM_OS_CREAT_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, FileName); + CFE_EVS_SendEvent(MM_OS_CLOSE_ERR_EID, CFE_EVS_EventType_ERROR, + "OS_close error received: RC = 0x%08X File = '%s'", (unsigned int)OS_Status, + FileName); } - } /* end MM_VerifyFileLoadDumpParams if */ + } /* end OS_OpenCreate if */ + else + { + Valid = false; + CFE_EVS_SendEvent(MM_OS_CREAT_ERR_EID, CFE_EVS_EventType_ERROR, + "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, FileName); + } - } /* end MM_ResolveSymAddr if */ - else - { - Valid = false; - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); - } + } /* end MM_VerifyFileLoadDumpParams if */ + + } /* end MM_ResolveSymAddr if */ + else + { + Valid = false; + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); + } return Valid; } @@ -403,7 +405,7 @@ bool MM_DumpMemToFile(osal_id_t FileHandle, const char *FileName, const MM_LoadD /* Update last action statistics */ if (BytesProcessed == FileHeader->NumOfBytes) { - ValidDump = true; + ValidDump = true; MM_AppData.HkPacket.Payload.LastAction = MM_DUMP_TO_FILE; MM_AppData.HkPacket.Payload.MemType = FileHeader->MemType; MM_AppData.HkPacket.Payload.Address = FileHeader->SymAddress.Offset; @@ -484,72 +486,73 @@ bool MM_DumpInEventCmd(const CFE_SB_Buffer_t *BufPtr) */ uint32 DumpBuffer[(MM_MAX_DUMP_INEVENT_BYTES + 3) / 4]; - CmdPtr = ((MM_DumpInEventCmd_t *)BufPtr); + CmdPtr = ((MM_DumpInEventCmd_t *)BufPtr); - SrcSymAddress = CmdPtr->Payload.SrcSymAddress; + SrcSymAddress = CmdPtr->Payload.SrcSymAddress; - /* Resolve the symbolic source address in the command message */ - Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + /* Resolve the symbolic source address in the command message */ + Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = + MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->Payload.MemType, CmdPtr->Payload.NumOfBytes, MM_VERIFY_EVENT); if (Valid == true) { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->Payload.MemType, CmdPtr->Payload.NumOfBytes, MM_VERIFY_EVENT); + /* Fill a local data buffer with the dump words */ + Valid = MM_FillDumpInEventBuffer(SrcAddress, CmdPtr, (uint8 *)DumpBuffer); if (Valid == true) { - /* Fill a local data buffer with the dump words */ - Valid = MM_FillDumpInEventBuffer(SrcAddress, CmdPtr, (uint8 *)DumpBuffer); + /* + ** Prepare event message string header + ** 13 characters, not counting NUL terminator + */ + CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], HeaderString, NULL, + sizeof(EventString) - EventStringTotalLength, sizeof(HeaderString)); + EventStringTotalLength = strlen(EventString); - if (Valid == true) + /* + ** Build dump data string + ** Each byte of data requires 5 characters of string space + ** Note this really only allows up to ~15 bytes using default config + */ + BytePtr = (uint8 *)DumpBuffer; + for (i = 0; i < CmdPtr->Payload.NumOfBytes; i++) { - /* - ** Prepare event message string header - ** 13 characters, not counting NUL terminator - */ - CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], HeaderString, NULL, - sizeof(EventString) - EventStringTotalLength, sizeof(HeaderString)); - EventStringTotalLength = strlen(EventString); - - /* - ** Build dump data string - ** Each byte of data requires 5 characters of string space - ** Note this really only allows up to ~15 bytes using default config - */ - BytePtr = (uint8 *)DumpBuffer; - for (i = 0; i < CmdPtr->Payload.NumOfBytes; i++) - { - snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "0x%02X ", *BytePtr); - CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], TempString, NULL, - sizeof(EventString) - EventStringTotalLength, sizeof(TempString)); - EventStringTotalLength = strlen(EventString); - BytePtr++; - } - - /* - ** Append tail - ** This adds up to 33 characters depending on pointer representation including the NUL terminator - */ - snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "from address: %p", (void *)SrcAddress); + snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "0x%02X ", *BytePtr); CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], TempString, NULL, sizeof(EventString) - EventStringTotalLength, sizeof(TempString)); + EventStringTotalLength = strlen(EventString); + BytePtr++; + } - /* Send it out */ - CFE_EVS_SendEvent(MM_DUMP_INEVENT_INF_EID, CFE_EVS_EventType_INFORMATION, "%s", EventString); - - /* Update telemetry */ - MM_AppData.HkPacket.Payload.LastAction = MM_DUMP_INEVENT; - MM_AppData.HkPacket.Payload.MemType = CmdPtr->Payload.MemType; - MM_AppData.HkPacket.Payload.Address = SrcAddress; - MM_AppData.HkPacket.Payload.BytesProcessed = CmdPtr->Payload.NumOfBytes; - } /* end MM_FillDumpInEventBuffer if */ - } /* end MM_VerifyFileLoadDumpParams if */ - } /* end MM_ResolveSymAddr if */ - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); - } + /* + ** Append tail + ** This adds up to 33 characters depending on pointer representation including the NUL terminator + */ + snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "from address: %p", (void *)SrcAddress); + CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], TempString, NULL, + sizeof(EventString) - EventStringTotalLength, sizeof(TempString)); + + /* Send it out */ + CFE_EVS_SendEvent(MM_DUMP_INEVENT_INF_EID, CFE_EVS_EventType_INFORMATION, "%s", EventString); + + /* Update telemetry */ + MM_AppData.HkPacket.Payload.LastAction = MM_DUMP_INEVENT; + MM_AppData.HkPacket.Payload.MemType = CmdPtr->Payload.MemType; + MM_AppData.HkPacket.Payload.Address = SrcAddress; + MM_AppData.HkPacket.Payload.BytesProcessed = CmdPtr->Payload.NumOfBytes; + } /* end MM_FillDumpInEventBuffer if */ + } /* end MM_VerifyFileLoadDumpParams if */ + } /* end MM_ResolveSymAddr if */ + else + { + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); + } return Valid; } diff --git a/fsw/src/mm_mem16.c b/fsw/src/mm_mem16.c index 1c5a261..7685017 100644 --- a/fsw/src/mm_mem16.c +++ b/fsw/src/mm_mem16.c @@ -115,7 +115,7 @@ bool MM_LoadMem16FromFile(osal_id_t FileHandle, const char *FileName, const MM_L /* Update last action statistics */ if (BytesProcessed == FileHeader->NumOfBytes) { - Valid = true; + Valid = true; MM_AppData.HkPacket.Payload.LastAction = MM_LOAD_FROM_FILE; MM_AppData.HkPacket.Payload.MemType = MM_MEM16; MM_AppData.HkPacket.Payload.Address = DestAddress; @@ -235,8 +235,8 @@ bool MM_FillMem16(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr) { NewBytesRemaining = BytesRemaining - (BytesRemaining % 2); CFE_EVS_SendEvent(MM_FILL_MEM16_ALIGN_WARN_INF_EID, CFE_EVS_EventType_INFORMATION, - "MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %u to %u.", (unsigned int)BytesRemaining, - (unsigned int)NewBytesRemaining); + "MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %u to %u.", + (unsigned int)BytesRemaining, (unsigned int)NewBytesRemaining); BytesRemaining = NewBytesRemaining; } diff --git a/fsw/src/mm_mem32.c b/fsw/src/mm_mem32.c index 4293843..f67b6ef 100644 --- a/fsw/src/mm_mem32.c +++ b/fsw/src/mm_mem32.c @@ -115,7 +115,7 @@ bool MM_LoadMem32FromFile(osal_id_t FileHandle, const char *FileName, const MM_L /* Update last action statistics */ if (BytesProcessed == FileHeader->NumOfBytes) { - Valid = true; + Valid = true; MM_AppData.HkPacket.Payload.LastAction = MM_LOAD_FROM_FILE; MM_AppData.HkPacket.Payload.MemType = MM_MEM32; MM_AppData.HkPacket.Payload.Address = DestAddress; diff --git a/unit-test/mm_mem16_tests.c b/unit-test/mm_mem16_tests.c index 5539092..706d60e 100644 --- a/unit-test/mm_mem16_tests.c +++ b/unit-test/mm_mem16_tests.c @@ -73,7 +73,8 @@ void MM_LoadMem16FromFile_Test_Nominal(void) UtAssert_True(MM_AppData.HkPacket.Payload.LastAction == MM_LOAD_FROM_FILE, "MM_AppData.HkPacket.Payload.LastAction == MM_LOAD_FROM_FILE"); UtAssert_True(MM_AppData.HkPacket.Payload.MemType == MM_MEM16, "MM_AppData.HkPacket.Payload.MemType == MM_MEM16"); - UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, "MM_AppData.HkPacket.Payload.Address == DestAddress"); + UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, + "MM_AppData.HkPacket.Payload.Address == DestAddress"); UtAssert_True(MM_AppData.HkPacket.Payload.BytesProcessed == FileHeader.NumOfBytes, "MM_AppData.HkPacket.Payload.BytesProcessed == FileHeader.NumOfBytes"); UtAssert_True(strncmp(MM_AppData.HkPacket.Payload.FileName, "filename", OS_MAX_PATH_LEN) == 0, @@ -109,7 +110,8 @@ void MM_LoadMem16FromFile_Test_CPUHogging(void) UtAssert_True(MM_AppData.HkPacket.Payload.LastAction == MM_LOAD_FROM_FILE, "MM_AppData.HkPacket.Payload.LastAction == MM_LOAD_FROM_FILE"); UtAssert_True(MM_AppData.HkPacket.Payload.MemType == MM_MEM16, "MM_AppData.HkPacket.Payload.MemType == MM_MEM16"); - UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, "MM_AppData.HkPacket.Payload.Address == DestAddress"); + UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, + "MM_AppData.HkPacket.Payload.Address == DestAddress"); UtAssert_True(MM_AppData.HkPacket.Payload.BytesProcessed == FileHeader.NumOfBytes, "MM_AppData.HkPacket.Payload.BytesProcessed == FileHeader.NumOfBytes"); UtAssert_True(strncmp(MM_AppData.HkPacket.Payload.FileName, "filename", OS_MAX_PATH_LEN) == 0, @@ -376,9 +378,11 @@ void MM_FillMem16_Test_Nominal(void) /* Verify results */ UtAssert_True(Result == true, "Result == true"); - UtAssert_True(MM_AppData.HkPacket.Payload.LastAction == MM_FILL, "MM_AppData.HkPacket.Payload.LastAction == MM_FILL"); + UtAssert_True(MM_AppData.HkPacket.Payload.LastAction == MM_FILL, + "MM_AppData.HkPacket.Payload.LastAction == MM_FILL"); UtAssert_True(MM_AppData.HkPacket.Payload.MemType == MM_MEM16, "MM_AppData.HkPacket.Payload.MemType == MM_MEM16"); - UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, "MM_AppData.HkPacket.Payload.Address == DestAddress"); + UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, + "MM_AppData.HkPacket.Payload.Address == DestAddress"); UtAssert_True(MM_AppData.HkPacket.Payload.DataValue == CmdPacket.Payload.FillPattern, "MM_AppData.HkPacket.Payload.DataValue == CmdPacket.Payload.FillPattern"); UtAssert_True(MM_AppData.HkPacket.Payload.BytesProcessed == CmdPacket.Payload.NumOfBytes, @@ -408,9 +412,11 @@ void MM_FillMem16_Test_CPUHogging(void) /* Verify results */ UtAssert_True(Result == true, "Result == true"); - UtAssert_True(MM_AppData.HkPacket.Payload.LastAction == MM_FILL, "MM_AppData.HkPacket.Payload.LastAction == MM_FILL"); + UtAssert_True(MM_AppData.HkPacket.Payload.LastAction == MM_FILL, + "MM_AppData.HkPacket.Payload.LastAction == MM_FILL"); UtAssert_True(MM_AppData.HkPacket.Payload.MemType == MM_MEM16, "MM_AppData.HkPacket.Payload.MemType == MM_MEM16"); - UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, "MM_AppData.HkPacket.Payload.Address == DestAddress"); + UtAssert_True(MM_AppData.HkPacket.Payload.Address == DestAddress, + "MM_AppData.HkPacket.Payload.Address == DestAddress"); UtAssert_True(MM_AppData.HkPacket.Payload.DataValue == CmdPacket.Payload.FillPattern, "MM_AppData.HkPacket.Payload.DataValue == CmdPacket.Payload.FillPattern"); UtAssert_True(MM_AppData.HkPacket.Payload.BytesProcessed == CmdPacket.Payload.NumOfBytes, @@ -470,10 +476,10 @@ void MM_FillMem16_Test_Align(void) { MM_FillMemCmd_t CmdPacket; uint32 DestAddress = 1; - bool Result; + bool Result; - CmdPacket.Payload.NumOfBytes = 3; - CmdPacket.Payload.FillPattern = 3; + CmdPacket.Payload.NumOfBytes = 3; + CmdPacket.Payload.FillPattern = 3; /* Execute the function being tested */ Result = MM_FillMem16(DestAddress, &CmdPacket);