diff --git a/apps/sample_app/fsw/src/sample_app.c b/apps/sample_app/fsw/src/sample_app.c index b3ff109..232a0a8 100644 --- a/apps/sample_app/fsw/src/sample_app.c +++ b/apps/sample_app/fsw/src/sample_app.c @@ -18,8 +18,6 @@ void SAMPLE_APP_Main(void) { int32 status; // return status of function calls CFE_SB_Buffer_t *SBBufPtr; // pointer to software bus - bool led_status = true; - // Register the app with Executive services CFE_ES_RegisterApp(); @@ -47,26 +45,12 @@ void SAMPLE_APP_Main(void) { */ status = CFE_SB_ReceiveBuffer(&SBBufPtr, SAMPLE_APP_Data.CommandPipe, 1000); if(status == CFE_SUCCESS) { - CFE_EVS_SendEvent(SAMPLE_APP_FILE_ERR_EID, CFE_EVS_EventType_CRITICAL, "SAMPLE: Recvd msg"); + SAMPLE_APP_ProcessCommandPacket(SBBufPtr); } // Performance Log Exit Stamp CFE_ES_PerfLogExit(SAMPLE_APP_PERF_ID); - // update led status - led_status = !led_status; - - // Use RPI library to access hardware - status = RPI_Set_LED(led_status); - if(status == CFE_SUCCESS) { - CFE_EVS_SendEvent(SAMPLE_APP_FILE_ERR_EID, CFE_EVS_EventType_DEBUG, "SAMPLE: Toggled LED"); - } - else { - // Error writing to RPI files - CFE_EVS_SendEvent(SAMPLE_APP_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "SAMPLE: Unable to write to file"); - } - - // Performance Log Entry Stamp CFE_ES_PerfLogEntry(SAMPLE_APP_PERF_ID); @@ -116,6 +100,8 @@ int32 SAMPLE_APP_Init(void) { SAMPLE_APP_Data.EventFilters[6].EventID = SAMPLE_APP_PIPE_ERR_EID; SAMPLE_APP_Data.EventFilters[6].Mask = 0x0000; + SAMPLE_APP_Data.led_status = 0; + // Register the events status = CFE_EVS_Register(SAMPLE_APP_Data.EventFilters, SAMPLE_APP_EVENT_COUNTS, CFE_EVS_EventFilter_BINARY); if (status != CFE_SUCCESS) { @@ -213,8 +199,7 @@ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) /* SAMPLE_APP_ProcessGroundCommand() -- SAMPLE ground commands */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) -{ +void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) { CFE_MSG_FcnCode_t CommandCode = 0; CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); @@ -222,32 +207,35 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) /* ** Process "known" SAMPLE app ground commands */ - switch (CommandCode) - { + switch (CommandCode) { case SAMPLE_APP_NOOP_CC: - if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_NoopCmd_t))) - { + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_NoopCmd_t))) { SAMPLE_APP_Noop((SAMPLE_APP_NoopCmd_t *)SBBufPtr); } break; case SAMPLE_APP_RESET_COUNTERS_CC: - if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ResetCountersCmd_t))) - { + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ResetCountersCmd_t))) { SAMPLE_APP_ResetCounters((SAMPLE_APP_ResetCountersCmd_t *)SBBufPtr); } break; case SAMPLE_APP_PROCESS_CC: - if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ProcessCmd_t))) - { + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ProcessCmd_t))) { SAMPLE_APP_Process((SAMPLE_APP_ProcessCmd_t *)SBBufPtr); } break; + case SAMPLE_APP_BLINK_CC: + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_BlinkCmd_t))) { + SAMPLE_APP_Blink((SAMPLE_APP_BlinkCmd_t *)SBBufPtr); + } + + break; + /* default case already found during FC vs length test */ default: CFE_EVS_SendEvent(SAMPLE_APP_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, @@ -372,6 +360,35 @@ int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) } /* End of SAMPLE_APP_ProcessCC */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* Name: SAMPLE_APP_Blink */ +/* */ +/* Purpose: */ +/* This function Process Blink Command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 SAMPLE_APP_Blink(const SAMPLE_APP_BlinkCmd_t *Msg) { + int32 status; + + // update led status + SAMPLE_APP_Data.led_status = !SAMPLE_APP_Data.led_status; + + // Use RPI library to access hardware + status = RPI_Set_LED(SAMPLE_APP_Data.led_status); + if(status == CFE_SUCCESS) { + CFE_EVS_SendEvent(SAMPLE_APP_BLINK_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: Blink command (%d) %s", + SAMPLE_APP_Data.led_status, SAMPLE_APP_VERSION); + } + else { + // Error writing to RPI files + CFE_EVS_SendEvent(SAMPLE_APP_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "SAMPLE: Unable to write to file"); + } + + + return status; + +} /* End of SAMPLE_APP_BlinkCC */ + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ /* SAMPLE_APP_VerifyCmdLength() -- Verify command packet length */ diff --git a/apps/sample_app/fsw/src/sample_app.h b/apps/sample_app/fsw/src/sample_app.h index a7fb92c..1d607c3 100644 --- a/apps/sample_app/fsw/src/sample_app.h +++ b/apps/sample_app/fsw/src/sample_app.h @@ -92,6 +92,8 @@ typedef struct CFE_EVS_BinFilter_t EventFilters[SAMPLE_APP_EVENT_COUNTS]; CFE_TBL_Handle_t TblHandles[SAMPLE_APP_NUMBER_OF_TABLES]; + bool led_status; + } SAMPLE_APP_Data_t; /****************************************************************************/ @@ -108,6 +110,7 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr); int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg); int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg); int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg); +int32 SAMPLE_APP_Blink(const SAMPLE_APP_BlinkCmd_t *Msg); int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg); void SAMPLE_APP_GetCrc(const char *TableName); diff --git a/apps/sample_app/fsw/src/sample_app_events.h b/apps/sample_app/fsw/src/sample_app_events.h index 42395fe..ca43862 100644 --- a/apps/sample_app/fsw/src/sample_app_events.h +++ b/apps/sample_app/fsw/src/sample_app_events.h @@ -15,7 +15,8 @@ #define SAMPLE_APP_LEN_ERR_EID 6 // Invalid Length #define SAMPLE_APP_PIPE_ERR_EID 7 // Pipe Error (Software Bus) #define SAMPLE_APP_FILE_ERR_EID 8 // File Write Error +#define SAMPLE_APP_BLINK_INF_EID 9 // Command Blink -#define SAMPLE_APP_EVENT_COUNTS 8 +#define SAMPLE_APP_EVENT_COUNTS 9 #endif diff --git a/apps/sample_app/fsw/src/sample_app_msg.h b/apps/sample_app/fsw/src/sample_app_msg.h index 294ed12..84635a4 100644 --- a/apps/sample_app/fsw/src/sample_app_msg.h +++ b/apps/sample_app/fsw/src/sample_app_msg.h @@ -15,6 +15,7 @@ #define SAMPLE_APP_NOOP_CC 0 #define SAMPLE_APP_RESET_COUNTERS_CC 1 #define SAMPLE_APP_PROCESS_CC 2 +#define SAMPLE_APP_BLINK_CC 3 /*************************************************************************/ @@ -35,6 +36,7 @@ typedef struct { typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_NoopCmd_t; typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_ResetCountersCmd_t; typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_ProcessCmd_t; +typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_BlinkCmd_t; /*************************************************************************/ /* diff --git a/ground-station/public/index.html b/ground-station/public/index.html index e3aa593..2bd63cc 100644 --- a/ground-station/public/index.html +++ b/ground-station/public/index.html @@ -20,5 +20,7 @@ +

+ \ No newline at end of file diff --git a/ground-station/public/js/arguments.js b/ground-station/public/js/arguments.js index 27fa834..03c73ad 100644 --- a/ground-station/public/js/arguments.js +++ b/ground-station/public/js/arguments.js @@ -3,5 +3,6 @@ const args = { cfe_sb_noop: { pktid: '0x1803' }, cfe_tbl_noop: { pktid: '0x1804' }, cfe_time_noop: { pktid: '0x1805' }, - cfe_es_noop: { pktid: '0x1806' } + cfe_es_noop: { pktid: '0x1806' }, + sample_toggle: { pktid: '0x1882', cmdcode: '3' } } \ No newline at end of file diff --git a/ground-station/server.js b/ground-station/server.js index eb738f9..25c585b 100644 --- a/ground-station/server.js +++ b/ground-station/server.js @@ -5,7 +5,7 @@ const express = require('express'); const morgan = require('morgan'); // app configuration -const DEBUG = true; +const DEBUG = false; const REQUEST_DEBUG = false; const node_port = 3000; const node_env = process.env.NODE_ENV || 'development';