From 4793da6e0d6d0051a1f73c26dd25c49302950112 Mon Sep 17 00:00:00 2001 From: Lewis Jaggi Date: Thu, 14 Jan 2021 11:22:26 +0100 Subject: [PATCH 01/29] pusopen integration --- Svc/GroundInterface/CMakeLists.txt | 12 +- Svc/GroundInterface/GroundInterface.cpp | 52 ++++++ Svc/GroundInterface/mdb_ground.xml | 120 +++++++++++++ Svc/GroundInterface/mdb_onboard.xml | 128 ++++++++++++++ Svc/GroundInterface/pusopen_mdb.c | 219 ++++++++++++++++++++++++ 5 files changed, 530 insertions(+), 1 deletion(-) create mode 100644 Svc/GroundInterface/mdb_ground.xml create mode 100644 Svc/GroundInterface/mdb_onboard.xml create mode 100644 Svc/GroundInterface/pusopen_mdb.c diff --git a/Svc/GroundInterface/CMakeLists.txt b/Svc/GroundInterface/CMakeLists.txt index 458f0771541..af68d4843df 100644 --- a/Svc/GroundInterface/CMakeLists.txt +++ b/Svc/GroundInterface/CMakeLists.txt @@ -6,13 +6,21 @@ # # Note: using PROJECT_NAME as EXECUTABLE_NAME #### + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/GroundInterfaceComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/GroundInterface.cpp" + "${CMAKE_CURRENT_LIST_DIR}/pusopen_mdb.c" # PUSOpen mission database ) set(MOD_DEPS "Utils/Types") register_fprime_module() +add_definitions(-D_LINUB1804_GCC750) +include_directories(../../Lib/Includes) +find_library(PUSOPEN pusopen ../../Lib/lib) +# PUSOPEN /home/jonathan/tm/CHESS/05_FS/fprime/Lib/lib/libpusopen.a found +target_link_libraries(Svc_GroundInterface ${PUSOPEN}) + # Rules based unit testing set(UT_MOD_DEPS STest @@ -23,6 +31,8 @@ set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestMain.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/GroundInterfaceRules.cpp" + "${CMAKE_CURRENT_LIST_DIR}/pusopen_mdb.c" # PUSOpen mission database ) -# STest Includes for this UT +# Test Includes for this UT register_fprime_ut() + diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index c78c636954a..d9eab8cc253 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -9,6 +9,8 @@ #include "Fw/Types/BasicTypes.hpp" #include +#include "pusopen.h" + namespace Svc { const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; @@ -203,4 +205,54 @@ namespace Svc { processRing(); } } + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * User-defined function triggered by PUS 8 provider. + * This function is defined in the Mission Database + * mdb_server.xml under . + */ +po_result_t UserPus8Fn (uint8_t fid, uint8_t *data, uint16_t len) +{ + printf("PUS8 User Function triggered.\n"); + printf("Function ID = %u.\n", fid); + printf("Received data (len = %u): %u %u %u %u\n", len, data[0], data[1], data[2], data[3]); + + return PO_SUCCESS; +} + +/* -- Global functions -- */ +po_result_t subnet_request( + uint8_t * const data, + const uint16_t len, + const po_apid_t apid, + const uint16_t vcid) { + po_result_t res = PO_SUCCESS; /* Result of this function */ + + (void)apid; + (void)vcid; + + /* Forward requested data directly down to FESS */ + res = fessChannelAccess_request(PO_DEF_FESS, data, len); + + return res; +} + +po_result_t subnet_indication(uint8_t * const data, uint16_t *len) { + po_result_t res = PO_SUCCESS; /* Result of this function */ + uint8_t quality = 0U; + uint8_t sequence = 0U; + + /* Call FESS indication API to retrieve received data */ + res = fessChannelAccess_indication(PO_DEF_FESS, data, len, &quality, &sequence); + + return res; +} + +#ifdef __cplusplus +} +#endif } // end namespace Svc diff --git a/Svc/GroundInterface/mdb_ground.xml b/Svc/GroundInterface/mdb_ground.xml new file mode 100644 index 00000000000..5f282005925 --- /dev/null +++ b/Svc/GroundInterface/mdb_ground.xml @@ -0,0 +1,120 @@ + + + + + 1.1 + + + 3 + + + 4 + + + + + + + true + + + 512 + + + + false + + + + false + + + + false + + + + false + + + + false + + + + true + + + + + true + + + 512 + 512 + + + + + + + + + + false + + + + + true + + + 2048 + 2048 + + + 2048 + + + FESS_DEF_ASM + 3 + + + + SLIP + NOENCRYPTION + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Svc/GroundInterface/mdb_onboard.xml b/Svc/GroundInterface/mdb_onboard.xml new file mode 100644 index 00000000000..45845e55866 --- /dev/null +++ b/Svc/GroundInterface/mdb_onboard.xml @@ -0,0 +1,128 @@ + + + + + 1.1 + + + 1 + + + 2 + + + + + + + true + + + 512 + + + + false + + + + true + + + + true + + + + false + + + + true + + + + false + + + + + true + + + 512 + 512 + + + + + + + + + + false + + + + + true + + + 2048 + 2048 + + + 2048 + + + FESS_DEF_ASM + 3 + + + + SLIP + NOENCRYPTION + + + + + + + + extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + + + + + 1 + Test function + Example test function + UserPus8Fn + + + + + + + + + + \ No newline at end of file diff --git a/Svc/GroundInterface/pusopen_mdb.c b/Svc/GroundInterface/pusopen_mdb.c new file mode 100644 index 00000000000..3cbb2c7db35 --- /dev/null +++ b/Svc/GroundInterface/pusopen_mdb.c @@ -0,0 +1,219 @@ +/** + * PUSopen(R) Mission Database + * + * THIS FILE HAS BEEN AUTOGENERATED. + * ANY MANUAL MODIFICATIONS MAY BE OVERWRITTEN. + */ + +/* Include files */ +#include "pusopen.h" + +/* Included PUSopen(R) modules */ + +#define PUS1_PROVIDER +/* #define PUS3_PROVIDER */ +#define PUS5_PROVIDER +#define PUS8_PROVIDER +/* #define PUS13_PROVIDER */ +#define PUS17_PROVIDER +/* #define PUS_USR */ + +/* PUSopen(R) configuration */ + +/* PUS 1 - Size of reception buffer (in bytes) */ +#define PUS1_RECV_BUF_SIZE 512 + +/* PUS 1 - Virtual Channel for TM[1,x] */ +#define PUS1_VCID 1 + +/* PUS 17 - Virtual Channel for TM[17,x] */ +#define PUS17_VCID 0 + +#define PS_LAYER + +/* PS - Max size of sent packet (in bytes) */ +#define PS_MAX_SEND_PACKET_SIZE 512 + +/* PS - Max size of received packet (in bytes) */ +#define PS_MAX_RECV_PACKET_SIZE 512 + +/* PS - Checksum type */ +#define PS_PKT_CHECKSUM_TYPE PKT_ISO16 + +/* PS - Checksum length (in bytes) */ +#define PS_PKT_CHECKSUM_LEN 2 + +#define FESS_LAYER + +/* FESS - Size of send buffer (in bytes) */ +#define FESS_SEND_BUF_SIZE 2048 + +/* FESS - Size of reception buffer (in bytes) */ +#define FESS_RECV_BUF_SIZE 2048 + +/* FESS - Size of FESS temporary buffers (in bytes) */ +#define FESS_TEMP_BUF_SIZE 2048 + +/* FESS - Attached Synchronization Mark (ASM) */ +#define FESS_ASM FESS_DEF_ASM + +/* FESS - Length of ASM */ +#define FESS_ASM_LEN 3 + +/* FESS - Frame encoding algorithm */ +#define FESS_ENCODING SLIP + +/* FESS - Frame encryption algorithm */ +#define FESS_ENCRYPTION NOENCRYPTION + +/* FESS - AES128 encryption key */ +#define FESS_AES_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + +/* FESS - AES128 initial vector */ +#define FESS_AES_IV {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + +/* PUS Service providers and user */ + +#ifdef PUS1_PROVIDER +PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); +#endif + +#ifdef PUS5_PROVIDER +PUS5_PROVIDER_INIT(pus5); +#endif + +#ifdef PUS8_PROVIDER +PUS8_PROVIDER_INIT(pus8); +#endif + +#ifdef PUS17_PROVIDER +PUS17_PROVIDER_INIT(pus17, PUS17_VCID); +#endif + +/* Packet Services */ + +#ifdef PS_LAYER +PS_INIT(ps, PS_MAX_SEND_PACKET_SIZE, PS_MAX_RECV_PACKET_SIZE, PS_PKT_CHECKSUM_TYPE, PS_PKT_CHECKSUM_LEN); +#endif + + +/* FESS Layer */ + +#ifdef FESS_LAYER +FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEND_BUF_SIZE, FESS_RECV_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_AES_KEY, FESS_AES_IV); +#endif + +/* User Code */ + +extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + +/* On-board Events */ + +po_evt_t evt[] = { +}; + +/* User Functions */ +extern po_result_t UserPus8Fn(uint8_t functionid, uint8_t *data, uint16_t len); + +po_fnc_t fnc[] = { + { + .id = 1U, + .name = "Test function", + .desc = "Example test function", + .addr = &UserPus8Fn + } +}; + +/* HK Parameters */ + +po_obparam_t obparams[] = { +#ifdef FESS_LAYER +PO_MDB_PARAMS_FESS +#endif +#ifdef PS_LAYER +PO_MDB_PARAMS_PS +#endif +#ifdef VC_LAYER +PO_MDB_PARAMS_VC +#endif +#ifdef PUS1_PROVIDER +PO_MDB_PARAMS_PUS1 +#endif +#ifdef PUS3_PROVIDER +PO_MDB_PARAMS_PUS3 +#endif +#ifdef PUS5_PROVIDER +PO_MDB_PARAMS_PUS5 +#endif +#ifdef PUS8_PROVIDER +PO_MDB_PARAMS_PUS8 +#endif +#ifdef PUS13_PROVIDER +PO_MDB_PARAMS_PUS13 +#endif +#ifdef PUS17_PROVIDER +PO_MDB_PARAMS_PUS17 +#endif +#ifdef PUS_USR +PO_MDB_PARAMS_PUSUSR +#endif +}; + +/* HK Reports */ + +po_hkreport_t hkreps[] = { +}; + +/* PUSopen(R) Mission Database */ + +po_mdbapid_t po_mdb_apid = { + .apid = 1, + .apuid = 2, + + .pus1 = POADDR(pus1), + .pus3 = PONULL, + .pus5 = POADDR(pus5), + .pus8 = POADDR(pus8), + .pus13 = PONULL, + .pus17 = POADDR(pus17), + .pusUsr = PONULL, + .ps = POADDR(ps), + .vc = PONULL, + .fess = POADDR(fess), + + .numevt = 0U, + .numparams = 40U, + .numreports = 0U, + .numfct = 1U, + .events = evt, + .obparams = obparams, + .func = fnc, + .hkreports = hkreps +}; + +/** + * Default implementation of pususr_tm to satisfy + * dependencies if PUS Service User is not used. + */ +#ifndef PUS_USR +EMPTY_PUSUSR_TM +#endif + +/** + * Default implementation of po_time to satisfy + * dependencies if user does not implements po_time. + */ +#ifndef PUS_CUSTOM_TIME +EMPTY_PO_TIME +#endif + +/** + * Default implementation of po_tc to satisfy + * dependencies if user does not implements po_tc. + */ +#ifndef PUS_CUSTOM_SERVICES +EMPTY_PO_TC +#endif + +/* MDB format version */ +#define MDB_VERSION 1 From ba071d6580f36b248b662cdcbcf53ce2cf81b74c Mon Sep 17 00:00:00 2001 From: Lewis Jaggi Date: Thu, 14 Jan 2021 11:25:06 +0100 Subject: [PATCH 02/29] change gitignore in Lib --- Lib/.gitignore | 7 +++++++ Lib/Readme | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 Lib/.gitignore create mode 100644 Lib/Readme diff --git a/Lib/.gitignore b/Lib/.gitignore new file mode 100644 index 00000000000..9af9f33bcf1 --- /dev/null +++ b/Lib/.gitignore @@ -0,0 +1,7 @@ +## PUSOpen lib + +lib +bin +examples +includes + diff --git a/Lib/Readme b/Lib/Readme new file mode 100644 index 00000000000..2eff819b0e5 --- /dev/null +++ b/Lib/Readme @@ -0,0 +1,3 @@ +#PUSOpen + +you need to put PUSOpen lib here From 3db1347ad7ec3ee1088797b52f53cedc2b6c68bf Mon Sep 17 00:00:00 2001 From: Lewis Jaggi Date: Thu, 14 Jan 2021 14:28:20 +0100 Subject: [PATCH 03/29] add com for pusopen --- Svc/GroundInterface/GroundInterface.cpp | 51 ++++++++++++++++++++++++- Svc/GroundInterface/GroundInterface.hpp | 1 + config/SocketIpDriverCfg.hpp | 6 ++- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index d9eab8cc253..2a6e51c98db 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -38,6 +38,12 @@ namespace Svc { ) { GroundInterfaceComponentBase::init(instance); + #if defined _PUS + po_initPus1(); // macro for pus1_reset(PO_DEF_PUS1) + po_initPs(); // macro for ps_reset(PO_DEF_PS) + po_initFess(); // macro for fess_reset(PO_DEF_FESS) + // @todo check return values +#endif } GroundInterfaceComponentImpl :: @@ -57,8 +63,11 @@ namespace Svc { U32 context ) { - FW_ASSERT(data.getBuffLength() <= MAX_DATA_SIZE); - frame_send(data.getBuffAddr(), data.getBuffLength()); +#if defined _GDS + // Downlink TM disabled + FW_ASSERT(data.getBuffLength() <= MAX_DATA_SIZE); + frame_send(data.getBuffAddr(), data.getBuffLength()); +#endif } void GroundInterfaceComponentImpl :: @@ -67,9 +76,11 @@ namespace Svc { Fw::Buffer &fwBuffer ) { +#if defined _GDS FW_ASSERT(fwBuffer.getSize() <= MAX_DATA_SIZE); frame_send(fwBuffer.getData(), fwBuffer.getSize(), Fw::ComPacket::FW_PACKET_FILE); fileDownlinkBufferSendOut_out(0, fwBuffer); +#endif } void GroundInterfaceComponentImpl :: @@ -78,7 +89,11 @@ namespace Svc { Fw::Buffer &buffer ) { +#if defined _PUS + processPUS(buffer); +#elif defined _GDS processBuffer(buffer); +#endif } void GroundInterfaceComponentImpl :: @@ -206,6 +221,38 @@ namespace Svc { } } + void GroundInterfaceComponentImpl :: + processPUS(Fw::Buffer& buffer) + { + printf("Data received : %u\n", buffer.getSize()); + Fw::Buffer extBuff = m_ext_buffer; + /* Push received data byte-by-byte into PUSopen(R) stack */ + U8 service = buffer.getData()[9]; + for(int i = 0; i < buffer.getSize(); i++) { + printf("%d data : %hhu \n",i,buffer.getData()[i]); + po_accept(buffer.getData()[i]); // todo propre reinterpret_cast + } + + /* Unwrap TC[17,x] from received CCSDS packet */ + po_triggerPs(); + + /* Forward TC[17,x] to PUS 17 */ + po_triggerPus1(); + + /* Transmission buffer */ + U8 buf[128]; + U16 len; + + /* Retrieve created TM[17,x] byte stream from PUSopen(R) stack and send it */ + po_frame(buf, &len); + + if (len > 0) { + extBuff.setSize(len); + extBuff.setData(buf); + write_out(0,extBuff); + } + } + #ifdef __cplusplus extern "C" { #endif diff --git a/Svc/GroundInterface/GroundInterface.hpp b/Svc/GroundInterface/GroundInterface.hpp index 12f78222922..02e729510cd 100644 --- a/Svc/GroundInterface/GroundInterface.hpp +++ b/Svc/GroundInterface/GroundInterface.hpp @@ -92,6 +92,7 @@ namespace Svc { //! Process a data buffer containing a read from the serial port void processBuffer(Fw::Buffer& data /*!< Data to process */); + void processPUS(Fw::Buffer& data /*!< Data to process */); // Basic data movement variables Fw::Buffer m_ext_buffer; diff --git a/config/SocketIpDriverCfg.hpp b/config/SocketIpDriverCfg.hpp index 512da740c53..67b3955cd4e 100644 --- a/config/SocketIpDriverCfg.hpp +++ b/config/SocketIpDriverCfg.hpp @@ -18,7 +18,11 @@ enum SocketIpCfg { SOCKET_TIMEOUT_SECONDS = 1, // Seconds component of timeout SOCKET_TIMEOUT_MICROSECONDS = 0, // Milliseconds component of timeout - SOCKET_SEND_UDP = 1, // 0 - Send down using TCP, 1 - Send down using UDP + #if defined _PUS + SOCKET_SEND_UDP = 0, + #elif _GDS + SOCKET_SEND_UDP = 1, + #endif // 0 - Send down using TCP, 1 - Send down using UDP SOCKET_SEND_FLAGS = 0, // send, sendto FLAGS argument SOCKET_RECV_FLAGS = 0, // recv FLAGS argument RECONNECT_AUTOMATICALLY = 1, // Attempt to reconnect when a socket closes From 6a9f8f9528ab3f667907c6e3e8717230c244756e Mon Sep 17 00:00:00 2001 From: Lewis Jaggi Date: Thu, 14 Jan 2021 14:31:01 +0100 Subject: [PATCH 04/29] update gitignore --- Lib/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/.gitignore b/Lib/.gitignore index 9af9f33bcf1..d22aba831e2 100644 --- a/Lib/.gitignore +++ b/Lib/.gitignore @@ -3,5 +3,5 @@ lib bin examples -includes +Includes From 5ffcc4116d3ea9126815fffa8e268cd9323fd7d7 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 14 Jan 2021 14:40:49 +0100 Subject: [PATCH 05/29] Minor FreeRTOSSim modification --- Drv/SocketIpDriver/SocketHelper.cpp | 2 +- Drv/SocketIpDriver/SocketIpDriverComponentImpl.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Drv/SocketIpDriver/SocketHelper.cpp b/Drv/SocketIpDriver/SocketHelper.cpp index 03697337344..bba58f317d6 100644 --- a/Drv/SocketIpDriver/SocketHelper.cpp +++ b/Drv/SocketIpDriver/SocketHelper.cpp @@ -29,7 +29,7 @@ #include #include #include -#elif defined TGT_OS_TYPE_LINUX || TGT_OS_TYPE_DARWIN || TGT_OS_TYPE_FREERTOS_SIM +#elif defined TGT_OS_TYPE_LINUX || TGT_OS_TYPE_DARWIN #include #include #include diff --git a/Drv/SocketIpDriver/SocketIpDriverComponentImpl.hpp b/Drv/SocketIpDriver/SocketIpDriverComponentImpl.hpp index fa54bf13625..60c10fdca4c 100644 --- a/Drv/SocketIpDriver/SocketIpDriverComponentImpl.hpp +++ b/Drv/SocketIpDriver/SocketIpDriverComponentImpl.hpp @@ -24,7 +24,7 @@ // Includes for the IP layer #ifdef TGT_OS_TYPE_VXWORKS #include -#elif defined TGT_OS_TYPE_LINUX || TGT_OS_TYPE_DARWIN || TGT_OS_TYPE_FREERTOS_SIM +#elif defined TGT_OS_TYPE_LINUX || TGT_OS_TYPE_DARWIN #include #else #error OS not supported for IP Socket Communications From 8288884db15c56bddb04e2a580e35321a30e2c03 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 14 Jan 2021 14:44:14 +0100 Subject: [PATCH 06/29] Rename PUSOpen MDB files --- Svc/GroundInterface/CMakeLists.txt | 4 +- ...{mdb_ground.xml => pusopen_ground_mdb.xml} | 0 .../{pusopen_mdb.c => pusopen_onboard_mdb.c} | 465 +++++++++--------- ...db_onboard.xml => pusopen_onboard_mdb.xml} | 309 +++++++----- 4 files changed, 430 insertions(+), 348 deletions(-) rename Svc/GroundInterface/{mdb_ground.xml => pusopen_ground_mdb.xml} (100%) rename Svc/GroundInterface/{pusopen_mdb.c => pusopen_onboard_mdb.c} (82%) rename Svc/GroundInterface/{mdb_onboard.xml => pusopen_onboard_mdb.xml} (64%) diff --git a/Svc/GroundInterface/CMakeLists.txt b/Svc/GroundInterface/CMakeLists.txt index af68d4843df..ff103052c31 100644 --- a/Svc/GroundInterface/CMakeLists.txt +++ b/Svc/GroundInterface/CMakeLists.txt @@ -10,7 +10,7 @@ set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/GroundInterfaceComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/GroundInterface.cpp" - "${CMAKE_CURRENT_LIST_DIR}/pusopen_mdb.c" # PUSOpen mission database + "${CMAKE_CURRENT_LIST_DIR}/pusopen_onboard_mdb.c" # PUSOpen mission database ) set(MOD_DEPS "Utils/Types") register_fprime_module() @@ -31,7 +31,7 @@ set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestMain.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/GroundInterfaceRules.cpp" - "${CMAKE_CURRENT_LIST_DIR}/pusopen_mdb.c" # PUSOpen mission database + "${CMAKE_CURRENT_LIST_DIR}/pusopen_onboard_mdb.c" # PUSOpen mission database ) # Test Includes for this UT register_fprime_ut() diff --git a/Svc/GroundInterface/mdb_ground.xml b/Svc/GroundInterface/pusopen_ground_mdb.xml similarity index 100% rename from Svc/GroundInterface/mdb_ground.xml rename to Svc/GroundInterface/pusopen_ground_mdb.xml diff --git a/Svc/GroundInterface/pusopen_mdb.c b/Svc/GroundInterface/pusopen_onboard_mdb.c similarity index 82% rename from Svc/GroundInterface/pusopen_mdb.c rename to Svc/GroundInterface/pusopen_onboard_mdb.c index 3cbb2c7db35..201c67323f7 100644 --- a/Svc/GroundInterface/pusopen_mdb.c +++ b/Svc/GroundInterface/pusopen_onboard_mdb.c @@ -1,219 +1,246 @@ -/** - * PUSopen(R) Mission Database - * - * THIS FILE HAS BEEN AUTOGENERATED. - * ANY MANUAL MODIFICATIONS MAY BE OVERWRITTEN. - */ - -/* Include files */ -#include "pusopen.h" - -/* Included PUSopen(R) modules */ - -#define PUS1_PROVIDER -/* #define PUS3_PROVIDER */ -#define PUS5_PROVIDER -#define PUS8_PROVIDER -/* #define PUS13_PROVIDER */ -#define PUS17_PROVIDER -/* #define PUS_USR */ - -/* PUSopen(R) configuration */ - -/* PUS 1 - Size of reception buffer (in bytes) */ -#define PUS1_RECV_BUF_SIZE 512 - -/* PUS 1 - Virtual Channel for TM[1,x] */ -#define PUS1_VCID 1 - -/* PUS 17 - Virtual Channel for TM[17,x] */ -#define PUS17_VCID 0 - -#define PS_LAYER - -/* PS - Max size of sent packet (in bytes) */ -#define PS_MAX_SEND_PACKET_SIZE 512 - -/* PS - Max size of received packet (in bytes) */ -#define PS_MAX_RECV_PACKET_SIZE 512 - -/* PS - Checksum type */ -#define PS_PKT_CHECKSUM_TYPE PKT_ISO16 - -/* PS - Checksum length (in bytes) */ -#define PS_PKT_CHECKSUM_LEN 2 - -#define FESS_LAYER - -/* FESS - Size of send buffer (in bytes) */ -#define FESS_SEND_BUF_SIZE 2048 - -/* FESS - Size of reception buffer (in bytes) */ -#define FESS_RECV_BUF_SIZE 2048 - -/* FESS - Size of FESS temporary buffers (in bytes) */ -#define FESS_TEMP_BUF_SIZE 2048 - -/* FESS - Attached Synchronization Mark (ASM) */ -#define FESS_ASM FESS_DEF_ASM - -/* FESS - Length of ASM */ -#define FESS_ASM_LEN 3 - -/* FESS - Frame encoding algorithm */ -#define FESS_ENCODING SLIP - -/* FESS - Frame encryption algorithm */ -#define FESS_ENCRYPTION NOENCRYPTION - -/* FESS - AES128 encryption key */ -#define FESS_AES_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} - -/* FESS - AES128 initial vector */ -#define FESS_AES_IV {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} - -/* PUS Service providers and user */ - -#ifdef PUS1_PROVIDER -PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); -#endif - -#ifdef PUS5_PROVIDER -PUS5_PROVIDER_INIT(pus5); -#endif - -#ifdef PUS8_PROVIDER -PUS8_PROVIDER_INIT(pus8); -#endif - -#ifdef PUS17_PROVIDER -PUS17_PROVIDER_INIT(pus17, PUS17_VCID); -#endif - -/* Packet Services */ - -#ifdef PS_LAYER -PS_INIT(ps, PS_MAX_SEND_PACKET_SIZE, PS_MAX_RECV_PACKET_SIZE, PS_PKT_CHECKSUM_TYPE, PS_PKT_CHECKSUM_LEN); -#endif - - -/* FESS Layer */ - -#ifdef FESS_LAYER -FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEND_BUF_SIZE, FESS_RECV_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_AES_KEY, FESS_AES_IV); -#endif - -/* User Code */ - -extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); - -/* On-board Events */ - -po_evt_t evt[] = { -}; - -/* User Functions */ -extern po_result_t UserPus8Fn(uint8_t functionid, uint8_t *data, uint16_t len); - -po_fnc_t fnc[] = { - { - .id = 1U, - .name = "Test function", - .desc = "Example test function", - .addr = &UserPus8Fn - } -}; - -/* HK Parameters */ - -po_obparam_t obparams[] = { -#ifdef FESS_LAYER -PO_MDB_PARAMS_FESS -#endif -#ifdef PS_LAYER -PO_MDB_PARAMS_PS -#endif -#ifdef VC_LAYER -PO_MDB_PARAMS_VC -#endif -#ifdef PUS1_PROVIDER -PO_MDB_PARAMS_PUS1 -#endif -#ifdef PUS3_PROVIDER -PO_MDB_PARAMS_PUS3 -#endif -#ifdef PUS5_PROVIDER -PO_MDB_PARAMS_PUS5 -#endif -#ifdef PUS8_PROVIDER -PO_MDB_PARAMS_PUS8 -#endif -#ifdef PUS13_PROVIDER -PO_MDB_PARAMS_PUS13 -#endif -#ifdef PUS17_PROVIDER -PO_MDB_PARAMS_PUS17 -#endif -#ifdef PUS_USR -PO_MDB_PARAMS_PUSUSR -#endif -}; - -/* HK Reports */ - -po_hkreport_t hkreps[] = { -}; - -/* PUSopen(R) Mission Database */ - -po_mdbapid_t po_mdb_apid = { - .apid = 1, - .apuid = 2, - - .pus1 = POADDR(pus1), - .pus3 = PONULL, - .pus5 = POADDR(pus5), - .pus8 = POADDR(pus8), - .pus13 = PONULL, - .pus17 = POADDR(pus17), - .pusUsr = PONULL, - .ps = POADDR(ps), - .vc = PONULL, - .fess = POADDR(fess), - - .numevt = 0U, - .numparams = 40U, - .numreports = 0U, - .numfct = 1U, - .events = evt, - .obparams = obparams, - .func = fnc, - .hkreports = hkreps -}; - -/** - * Default implementation of pususr_tm to satisfy - * dependencies if PUS Service User is not used. - */ -#ifndef PUS_USR -EMPTY_PUSUSR_TM -#endif - -/** - * Default implementation of po_time to satisfy - * dependencies if user does not implements po_time. - */ -#ifndef PUS_CUSTOM_TIME -EMPTY_PO_TIME -#endif - -/** - * Default implementation of po_tc to satisfy - * dependencies if user does not implements po_tc. - */ -#ifndef PUS_CUSTOM_SERVICES -EMPTY_PO_TC -#endif - -/* MDB format version */ -#define MDB_VERSION 1 +/** + * PUSopen(R) Mission Database + * + * THIS FILE HAS BEEN AUTOGENERATED. + * ANY MANUAL MODIFICATIONS MAY BE OVERWRITTEN. + */ + +/* Include files */ +#include "pusopen.h" + +/* Included PUSopen(R) modules */ + +#define PUS1_PROVIDER +/* #define PUS3_PROVIDER */ +#define PUS5_PROVIDER +#define PUS8_PROVIDER +/* #define PUS13_PROVIDER */ +#define PUS17_PROVIDER +/* #define PUS_USR */ + +/* PUSopen(R) configuration */ + +/* PUS 1 - Size of reception buffer (in bytes) */ +#define PUS1_RECV_BUF_SIZE 512 + +/* PUS 1 - Virtual Channel for TM[1,x] */ +#define PUS1_VCID 1 + +/* PUS 17 - Virtual Channel for TM[17,x] */ +#define PUS17_VCID 0 + +#define PS_LAYER + +/* PS - Max size of sent packet (in bytes) */ +#define PS_MAX_SEND_PACKET_SIZE 512 + +/* PS - Max size of received packet (in bytes) */ +#define PS_MAX_RECV_PACKET_SIZE 512 + +/* PS - Checksum type */ +#define PS_PKT_CHECKSUM_TYPE PKT_ISO16 + +/* PS - Checksum length (in bytes) */ +#define PS_PKT_CHECKSUM_LEN 2 + +#define FESS_LAYER + +/* FESS - Size of send buffer (in bytes) */ +#define FESS_SEND_BUF_SIZE 2048 + +/* FESS - Size of reception buffer (in bytes) */ +#define FESS_RECV_BUF_SIZE 2048 + +/* FESS - Size of FESS temporary buffers (in bytes) */ +#define FESS_TEMP_BUF_SIZE 2048 + +/* FESS - Attached Synchronization Mark (ASM) */ +#define FESS_ASM FESS_DEF_ASM + +/* FESS - Length of ASM */ +#define FESS_ASM_LEN 3 + +/* FESS - Frame encoding algorithm */ +#define FESS_ENCODING SLIP + +/* FESS - Frame encryption algorithm */ +#define FESS_ENCRYPTION NOENCRYPTION + +/* FESS - AES128 encryption key */ +#define FESS_AES_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + +/* FESS - AES128 initial vector */ +#define FESS_AES_IV {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + +/* PUS Service providers and user */ + +#ifdef PUS1_PROVIDER +PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); +#endif + +#ifdef PUS5_PROVIDER +PUS5_PROVIDER_INIT(pus5); +#endif + +#ifdef PUS8_PROVIDER +PUS8_PROVIDER_INIT(pus8); +#endif + +#ifdef PUS17_PROVIDER +PUS17_PROVIDER_INIT(pus17, PUS17_VCID); +#endif + +/* Packet Services */ + +#ifdef PS_LAYER +PS_INIT(ps, PS_MAX_SEND_PACKET_SIZE, PS_MAX_RECV_PACKET_SIZE, PS_PKT_CHECKSUM_TYPE, PS_PKT_CHECKSUM_LEN); +#endif + + +/* FESS Layer */ + +#ifdef FESS_LAYER +FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEND_BUF_SIZE, FESS_RECV_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_AES_KEY, FESS_AES_IV); +#endif + +/* User Code */ + +extern uint32_t charge_estimation; +extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + +/* On-board Events */ + +po_evt_t evt[] = { + { + .id = 1U, + .level = PUS5_EVT_INFO, + .desc = "Informative event", + .dataLen = 4U, + .vcid = 1U + } +}; + +/* User Functions */ +extern po_result_t UserPus8Fn(uint8_t functionid, uint8_t *data, uint16_t len); + +po_fnc_t fnc[] = { + { + .id = 1U, + .name = "Test function", + .desc = "Example test function", + .addr = &UserPus8Fn + } +}; + +/* HK Parameters */ + +po_obparam_t obparams[] = { +#ifdef FESS_LAYER +PO_MDB_PARAMS_FESS +#endif +#ifdef PS_LAYER +PO_MDB_PARAMS_PS +#endif +#ifdef VC_LAYER +PO_MDB_PARAMS_VC +#endif +#ifdef PUS1_PROVIDER +PO_MDB_PARAMS_PUS1 +#endif +#ifdef PUS3_PROVIDER +PO_MDB_PARAMS_PUS3 +#endif +#ifdef PUS5_PROVIDER +PO_MDB_PARAMS_PUS5 +#endif +#ifdef PUS8_PROVIDER +PO_MDB_PARAMS_PUS8 +#endif +#ifdef PUS13_PROVIDER +PO_MDB_PARAMS_PUS13 +#endif +#ifdef PUS17_PROVIDER +PO_MDB_PARAMS_PUS17 +#endif +#ifdef PUS_USR +PO_MDB_PARAMS_PUSUSR +#endif + { + .id = 100U, + .name = "EPS_charge_estimation", + .desc = "EPS Charge estimation", + .type = PO_UINT32, + .addr = &charge_estimation + } +}; + +/* HK Reports */ + +po_hkreport_t hkreps[] = { + { + .id = 1U, + .name = "Report #1", + .desc = "Report #1 description", + .enabled = POTRUE, + .interval = 1U, + .sinceLast = 0U, + .destApid = 3U, + .vcid = 0U, + .numHk = 8U, + .obparams = { 100 } + } +}; + +/* PUSopen(R) Mission Database */ + +po_mdbapid_t po_mdb_apid = { + .apid = 1, + .apuid = 2, + + .pus1 = POADDR(pus1), + .pus3 = PONULL, + .pus5 = POADDR(pus5), + .pus8 = POADDR(pus8), + .pus13 = PONULL, + .pus17 = POADDR(pus17), + .pusUsr = PONULL, + .ps = POADDR(ps), + .vc = PONULL, + .fess = POADDR(fess), + + .numevt = 1U, + .numparams = 41U, + .numreports = 1U, + .numfct = 1U, + .events = evt, + .obparams = obparams, + .func = fnc, + .hkreports = hkreps +}; + +/** + * Default implementation of pususr_tm to satisfy + * dependencies if PUS Service User is not used. + */ +#ifndef PUS_USR +EMPTY_PUSUSR_TM +#endif + +/** + * Default implementation of po_time to satisfy + * dependencies if user does not implements po_time. + */ +#ifndef PUS_CUSTOM_TIME +EMPTY_PO_TIME +#endif + +/** + * Default implementation of po_tc to satisfy + * dependencies if user does not implements po_tc. + */ +#ifndef PUS_CUSTOM_SERVICES +EMPTY_PO_TC +#endif + +/* MDB format version */ +#define MDB_VERSION 1 diff --git a/Svc/GroundInterface/mdb_onboard.xml b/Svc/GroundInterface/pusopen_onboard_mdb.xml similarity index 64% rename from Svc/GroundInterface/mdb_onboard.xml rename to Svc/GroundInterface/pusopen_onboard_mdb.xml index 45845e55866..a1f1eb2c5ca 100644 --- a/Svc/GroundInterface/mdb_onboard.xml +++ b/Svc/GroundInterface/pusopen_onboard_mdb.xml @@ -1,128 +1,183 @@ - - - - - 1.1 - - - 1 - - - 2 - - - - - - - true - - - 512 - - - - false - - - - true - - - - true - - - - false - - - - true - - - - false - - - - - true - - - 512 - 512 - - - - - - - - - - false - - - - - true - - - 2048 - 2048 - - - 2048 - - - FESS_DEF_ASM - 3 - - - - SLIP - NOENCRYPTION - - - - - - - - extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); - - - - - 1 - Test function - Example test function - UserPus8Fn - - - - - - - - - + + + + + + 1.1 + + + 1 + + + 2 + + + + + + + true + + + 512 + + + + false + + + + true + + + + true + + + + false + + + + true + + + + false + + + + + true + + + 512 + 512 + + + + + + + + + + false + + + + + true + + + 2048 + 2048 + + + 2048 + + + FESS_DEF_ASM + 3 + + + + SLIP + NOENCRYPTION + + + + + + + + + 1 + PUS5_EVT_INFO + Informative event + 4 + + + + + extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + + + + + 1 + Test function + Example test function + UserPus8Fn + + + + + + 100 + EPS_charge_estimation + EPS Charge estimation + PO_UINT32 + charge_estimation + + + + + + 1 + Report #1 + Report #1 description + true + 1 + 3 + + + 100 + + + + \ No newline at end of file From c64c5acd772be4c70bf4dd5dcf21268ccd9564e2 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 14 Jan 2021 14:46:46 +0100 Subject: [PATCH 07/29] Implement PUS3 and 5 base, modify TlmChan --- Svc/GroundInterface/GroundInterface.cpp | 439 +++++++++++------- Svc/GroundInterface/GroundInterface.hpp | 24 +- .../GroundInterfaceComponentAi.xml | 15 +- Svc/TlmChan/CMakeLists.txt | 4 - Svc/TlmChan/TlmChanComponentAi.xml | 5 + Svc/TlmChan/TlmChanImpl.cpp | 123 ++++- Svc/TlmChan/TlmChanImpl.hpp | 1 - 7 files changed, 426 insertions(+), 185 deletions(-) diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 2a6e51c98db..4e227e55723 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -4,212 +4,312 @@ // \brief cpp file for GroundInterface component implementation class // ====================================================================== +#include + #include +#include #include #include "Fw/Types/BasicTypes.hpp" -#include + +#include #include "pusopen.h" namespace Svc { - const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; - const TOKEN_TYPE GroundInterfaceComponentImpl::START_WORD = static_cast(0xdeadbeef); - const U32 GroundInterfaceComponentImpl::END_WORD = static_cast(0xcafecafe); - - // ---------------------------------------------------------------------- - // Construction, initialization, and destruction - // ---------------------------------------------------------------------- - - GroundInterfaceComponentImpl :: - GroundInterfaceComponentImpl( - const char *const compName - ) : GroundInterfaceComponentBase(compName), - m_ext_buffer(m_buffer, GND_BUFFER_SIZE), - m_data_size(0), - m_in_ring(m_in_buffer, GND_BUFFER_SIZE) - { +const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; +const TOKEN_TYPE GroundInterfaceComponentImpl::START_WORD = static_cast(0xdeadbeef); +const U32 GroundInterfaceComponentImpl::END_WORD = static_cast(0xcafecafe); - } +#ifdef __cplusplus +extern "C" { +#endif +U32 charge_estimation = 0x32U; +#ifdef __cplusplus +} +#endif - void GroundInterfaceComponentImpl :: - init( - const NATIVE_INT_TYPE instance - ) - { +// ------------------------------------- --------------------------------- +// Construction, initialization, and destruction +// ---------------------------------------------------------------------- + +GroundInterfaceComponentImpl :: +GroundInterfaceComponentImpl( + const char *const compName +) : GroundInterfaceComponentBase(compName), + m_ext_buffer(m_buffer, GND_BUFFER_SIZE), + m_data_size(0), + m_in_ring(m_in_buffer, GND_BUFFER_SIZE) { +} + +void GroundInterfaceComponentImpl::init(const NATIVE_INT_TYPE instance) { GroundInterfaceComponentBase::init(instance); - #if defined _PUS - po_initPus1(); // macro for pus1_reset(PO_DEF_PUS1) - po_initPs(); // macro for ps_reset(PO_DEF_PS) - po_initFess(); // macro for fess_reset(PO_DEF_FESS) - // @todo check return values -#endif - } + po_result_t res = PO_SUCCESS; - GroundInterfaceComponentImpl :: - ~GroundInterfaceComponentImpl(void) - { + res = po_initPus1(); // macro for pus1_reset(PO_DEF_PUS1) + res |= po_initPs(); // macro for ps_reset(PO_DEF_PS) + res |= po_initFess(); // macro for fess_reset(PO_DEF_FESS) - } + if (res != PO_SUCCESS) { + // PUSOpen initialisation error ! Critical error with FSW + FW_ASSERT(0); + } - // ---------------------------------------------------------------------- - // Handler implementations for user-defined typed input ports - // ---------------------------------------------------------------------- + charge_estimation = 0; +} - void GroundInterfaceComponentImpl :: - downlinkPort_handler( - const NATIVE_INT_TYPE portNum, - Fw::ComBuffer &data, - U32 context - ) - { +GroundInterfaceComponentImpl::~GroundInterfaceComponentImpl(void) {} + +// ---------------------------------------------------------------------- +// Handler implementations for user-defined typed input ports +// ---------------------------------------------------------------------- + +void GroundInterfaceComponentImpl::downlinkPort_handler( + const NATIVE_INT_TYPE portNum, + Fw::ComBuffer &data, + U32 context +) { #if defined _GDS // Downlink TM disabled FW_ASSERT(data.getBuffLength() <= MAX_DATA_SIZE); frame_send(data.getBuffAddr(), data.getBuffLength()); #endif - } +} - void GroundInterfaceComponentImpl :: - fileDownlinkBufferSendIn_handler( - const NATIVE_INT_TYPE portNum, - Fw::Buffer &fwBuffer - ) - { +void GroundInterfaceComponentImpl::fileDownlinkBufferSendIn_handler( + const NATIVE_INT_TYPE portNum, + Fw::Buffer &fwBuffer +) { #if defined _GDS FW_ASSERT(fwBuffer.getSize() <= MAX_DATA_SIZE); frame_send(fwBuffer.getData(), fwBuffer.getSize(), Fw::ComPacket::FW_PACKET_FILE); fileDownlinkBufferSendOut_out(0, fwBuffer); #endif - } +} - void GroundInterfaceComponentImpl :: - readCallback_handler( - const NATIVE_INT_TYPE portNum, - Fw::Buffer &buffer - ) - { +void GroundInterfaceComponentImpl::readCallback_handler( + const NATIVE_INT_TYPE portNum, + Fw::Buffer &buffer +) { #if defined _PUS processPUS(buffer); #elif defined _GDS processBuffer(buffer); #endif - } +} - void GroundInterfaceComponentImpl :: - schedIn_handler( - const NATIVE_INT_TYPE portNum, /*!< The port number*/ - NATIVE_UINT_TYPE context /*!< The call order*/ - ) - { - // TODO: replace with a call to a buffer manager - Fw::Buffer buffer = m_ext_buffer; - // Call read poll if it is hooked up - if (isConnected_readPoll_OutputPort(0)) { - readPoll_out(0, buffer); - processBuffer(buffer); - } - } - void GroundInterfaceComponentImpl::frame_send(U8 *data, TOKEN_TYPE size, TOKEN_TYPE packet_type) { - // TODO: replace with a call to a buffer manager - Fw::Buffer buffer = m_ext_buffer; - Fw::SerializeBufferBase& buffer_wrapper = buffer.getSerializeRepr(); - buffer_wrapper.resetSer(); - // True size is supplied size plus sizeof(TOKEN_TYPE) if a packet_type other than "UNKNOWN" was supplied. - // This is because if not UNKNOWN, the packet_type is serialized too. Otherwise it is assumed the PACKET_TYPE is - // already the first token in the UNKNOWN typed buffer. - U32 true_size = (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? size + sizeof(TOKEN_TYPE) : size; - U32 total_size = sizeof(TOKEN_TYPE) + sizeof(TOKEN_TYPE) + true_size + sizeof(U32); - // Serialize data - FW_ASSERT(GND_BUFFER_SIZE >= total_size, GND_BUFFER_SIZE, total_size); - buffer_wrapper.serialize(START_WORD); - buffer_wrapper.serialize(static_cast(true_size)); - // Explicitly set the packet type, if it didn't come with the data already - if (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) { - buffer_wrapper.serialize(packet_type); - } - buffer_wrapper.serialize(data, size, true); - buffer_wrapper.serialize(static_cast(END_WORD)); +void GroundInterfaceComponentImpl::eventReport_handler( + const NATIVE_INT_TYPE portNum, + FwEventIdType id, + Fw::Time &timeTag, + Fw::LogSeverity severity, + Fw::LogBuffer &args +) { + printf("Event received : %u\n", id); + // F' variables + Fw::Buffer buffer; + + Fw::LogPacket m_logPacket; //!< packet buffer for assembling log packets + Fw::ComBuffer m_comBuffer; //!< com buffer for sending event buffers + + m_logPacket.setId(id); + m_logPacket.setTimeTag(timeTag); + m_logPacket.setLogBuffer(args); + Fw::SerializeStatus stat = m_logPacket.serialize(m_comBuffer); + FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); + + + // PUSOpen variables + U8 po_buf[512]; + U8 po_evtData[] = {4, 3, 6, 9, 8}; + U16 po_len; + po_result_t po_res = PO_ERR; + + /** PUS Service 5 severity level + PUS5_EVT_INFO = Information event TM[5,1] + PUS5_EVT_LOW = Low severity anomaly TM[5,2] + PUS5_EVT_MEDIUM = Medium severity anomaly TM[5,3] + PUS5_EVT_HIGH = High severity anomaly TM[5,4] + **/ + + /** F' Events severity level - Conversion table + DIAGNOSTIC → PUS5_EVT_INFO + ACTIVITY_LO → PUS5_EVT_INFO + ACTIVITY_HI → PUS5_EVT_INFO + WARNING_LO → PUS5_EVT_LOW + WARNING_HI → PUS5_EVT_MEDIUM + FATAL → PUS5_EVT_HIGH + COMMAND → PUS5_EVT_INFO + **/ + + // Send TM[5,x] with event ID = x + po_res = po_pus5tm(PUS5_EVT_INFO, // event ID + po_evtData, // event data + 3U); // destination APID (GS) + + if(po_res != PO_SUCCESS) { + printf("po error: %u\n", po_res); + FW_ASSERT(0); + } - // Setup for sending by truncating unused data - buffer.setSize(buffer_wrapper.getBuffLength()); - FW_ASSERT(buffer.getSize() == total_size, buffer.getSize(), total_size); - write_out(0, buffer); - } + // Retrieve created TM[5,x] byte stream from PUSopen stack and send it + po_res = po_frame(po_buf, &po_len); + if(po_res != PO_SUCCESS) { + printf("po error: %u\n", po_res); + FW_ASSERT(0); + } - void GroundInterfaceComponentImpl :: - routeComData() - { - // Read the packet type from the data buffer - U32 packet_type = Fw::ComPacket::FW_PACKET_UNKNOWN; - m_in_ring.peek(packet_type, HEADER_SIZE); - - // Process variable type - switch (packet_type) { - case Fw::ComPacket::FW_PACKET_COMMAND: { - Fw::ComBuffer com; - m_in_ring.peek(com.getBuffAddr(), m_data_size, HEADER_SIZE); - // Reset com buffer for sending out data - com.setBuffLen(m_data_size); - uplinkPort_out(0, com, 0); - break; - } - case Fw::ComPacket::FW_PACKET_FILE: { - // If file uplink is possible, handle files. Otherwise ignore. - if (isConnected_fileUplinkBufferGet_OutputPort(0) && - isConnected_fileDownlinkBufferSendOut_OutputPort(0)) { - Fw::Buffer buffer = fileUplinkBufferGet_out(0, m_data_size); - m_in_ring.peek(buffer.getData(), m_data_size - sizeof(packet_type), HEADER_SIZE + sizeof(packet_type)); - buffer.setSize(m_data_size - sizeof(packet_type)); - fileUplinkBufferSendOut_out(0, buffer); - } - break; - } - default: - return; - } - } + buffer.setData(po_buf); + buffer.setSize(po_len); + //write_out(0, buffer); // @todo uncomment +} - void GroundInterfaceComponentImpl :: - processRing() - { - // Header items for the packet - TOKEN_TYPE start; - U32 checksum; //TODO: make this run a CRC32 - // Inner-loop, process ring buffer looking for at least the header - while (m_in_ring.get_remaining_size() >= HEADER_SIZE) { - m_data_size = 0; - // Peek into the header and read out values - Fw::SerializeStatus status = m_in_ring.peek(start, 0); - FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); - status = m_in_ring.peek(m_data_size, sizeof(TOKEN_TYPE)); - FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); - // Check the header for correctness - if (start != START_WORD || m_data_size >= MAX_DATA_SIZE) { - m_in_ring.rotate(1); - continue; - } - // Check for enough data to deserialize everything otherwise break and wait for more. - else if (m_in_ring.get_remaining_size() < (HEADER_SIZE + m_data_size + sizeof(END_WORD))) { - break; - } - // Continue with the data portion and checksum - m_in_ring.peek(checksum, HEADER_SIZE + m_data_size); - // Check checksum - if (checksum == END_WORD) { - routeComData(); - m_in_ring.rotate(HEADER_SIZE + m_data_size + sizeof(U32)); - } - // Failed checksum, keep looking for valid message - else { - m_in_ring.rotate(1); - } - } +void GroundInterfaceComponentImpl::hkReport_handler( + const NATIVE_INT_TYPE portNum, + FwChanIdType id, + Fw::Time &timeTag, + Fw::TlmBuffer &val +) { + // F' variables + Fw::Buffer buffer; + + // PUSOpen variables + U8 po_buf[512]; + U16 po_len; + po_result_t po_res = PO_ERR; + + printf("Housekeeping received : %u\n", id); + + // Trigger PUS 3 Service provider to generate TM[3,25] + po_triggerPus3(); + + // Retrieve created TM[3,25] byte stream from PUSopen stack and send it + po_res = po_frame(po_buf, &po_len); + + if(po_res != PO_SUCCESS) { + printf("po error: %u\n", po_res); + FW_ASSERT(0); + } + + buffer.setData(po_buf); + buffer.setSize(po_len); + //write_out(0, buffer); // @todo uncomment + + // Increment charge_estimation for demonstration + charge_estimation++; +} + +void GroundInterfaceComponentImpl::schedIn_handler( + const NATIVE_INT_TYPE portNum, /*!< The port number*/ + NATIVE_UINT_TYPE context /*!< The call order*/ +) { + // TODO: replace with a call to a buffer manager + Fw::Buffer buffer = m_ext_buffer; + // Call read poll if it is hooked up + if (isConnected_readPoll_OutputPort(0)) { + readPoll_out(0, buffer); + processBuffer(buffer); + } +} + +void GroundInterfaceComponentImpl::frame_send(U8 *data, TOKEN_TYPE size, TOKEN_TYPE packet_type) { + // TODO: replace with a call to a buffer manager + Fw::Buffer buffer = m_ext_buffer; + Fw::SerializeBufferBase& buffer_wrapper = buffer.getSerializeRepr(); + buffer_wrapper.resetSer(); + // True size is supplied size plus sizeof(TOKEN_TYPE) if a packet_type other than "UNKNOWN" was supplied. + // This is because if not UNKNOWN, the packet_type is serialized too. Otherwise it is assumed the PACKET_TYPE is + // already the first token in the UNKNOWN typed buffer. + U32 true_size = (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? size + sizeof(TOKEN_TYPE) : size; + // Frame format : | START_WORD | data_size | data | END_WORD | + U32 total_size = sizeof(TOKEN_TYPE) + sizeof(TOKEN_TYPE) + true_size + sizeof(U32); + // Serialize data + FW_ASSERT(GND_BUFFER_SIZE >= total_size, GND_BUFFER_SIZE, total_size); + buffer_wrapper.serialize(START_WORD); + buffer_wrapper.serialize(static_cast(true_size)); + // Explicitly set the packet type, if it didn't come with the data already + if (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) { + buffer_wrapper.serialize(packet_type); + } + buffer_wrapper.serialize(data, size, true); + buffer_wrapper.serialize(static_cast(END_WORD)); + + // Setup for sending by truncating unused data + buffer.setSize(buffer_wrapper.getBuffLength()); + FW_ASSERT(buffer.getSize() == total_size, buffer.getSize(), total_size); + write_out(0, buffer); +} + +void GroundInterfaceComponentImpl::routeComData() { + // Read the packet type from the data buffer + U32 packet_type = Fw::ComPacket::FW_PACKET_UNKNOWN; + m_in_ring.peek(packet_type, HEADER_SIZE); + + // Process variable type + switch (packet_type) { + case Fw::ComPacket::FW_PACKET_COMMAND: { + Fw::ComBuffer com; + m_in_ring.peek(com.getBuffAddr(), m_data_size, HEADER_SIZE); + // Reset com buffer for sending out data + com.setBuffLen(m_data_size); + uplinkPort_out(0, com, 0); // → send to CommandDispatcher + break; + } + case Fw::ComPacket::FW_PACKET_FILE: { + // If file uplink is possible, handle files. Otherwise ignore. + FW_ASSERT(0); + if (isConnected_fileUplinkBufferGet_OutputPort(0) && + isConnected_fileDownlinkBufferSendOut_OutputPort(0)) { + Fw::Buffer buffer = fileUplinkBufferGet_out(0, m_data_size); + m_in_ring.peek(buffer.getData(), m_data_size - sizeof(packet_type), HEADER_SIZE + sizeof(packet_type)); + buffer.setSize(m_data_size - sizeof(packet_type)); + fileUplinkBufferSendOut_out(0, buffer); + } + break; + } + default: + return; + } } - void GroundInterfaceComponentImpl :: - processBuffer(Fw::Buffer& buffer) +void GroundInterfaceComponentImpl::processRing() { + // Header items for the packet + TOKEN_TYPE start; + U32 checksum; //TODO: make this run a CRC32 + // Inner-loop, process ring buffer looking for at least the header + while (m_in_ring.get_remaining_size() >= HEADER_SIZE) { + m_data_size = 0; + // Peek into the header and read out values + Fw::SerializeStatus status = m_in_ring.peek(start, 0); + FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); + status = m_in_ring.peek(m_data_size, sizeof(TOKEN_TYPE)); + FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); + // Check the header for correctness + if (start != START_WORD || m_data_size >= MAX_DATA_SIZE) { + m_in_ring.rotate(1); + continue; + } + // Check for enough data to deserialize everything otherwise break and wait for more. + else if (m_in_ring.get_remaining_size() < (HEADER_SIZE + m_data_size + sizeof(END_WORD))) { + break; + } + // Continue with the data portion and checksum + m_in_ring.peek(checksum, HEADER_SIZE + m_data_size); + // Check checksum + if (checksum == END_WORD) { + routeComData(); + m_in_ring.rotate(HEADER_SIZE + m_data_size + sizeof(END_WORD)); + } + // Failed checksum, keep looking for valid message + else { + m_in_ring.rotate(1); + } + } + //*/ +} + +void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { NATIVE_UINT_TYPE buffer_offset = 0; while (buffer_offset < buffer.getSize()) { @@ -221,9 +321,7 @@ namespace Svc { } } - void GroundInterfaceComponentImpl :: - processPUS(Fw::Buffer& buffer) - { + void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { printf("Data received : %u\n", buffer.getSize()); Fw::Buffer extBuff = m_ext_buffer; /* Push received data byte-by-byte into PUSopen(R) stack */ @@ -302,4 +400,5 @@ po_result_t subnet_indication(uint8_t * const data, uint16_t *len) { #ifdef __cplusplus } #endif + } // end namespace Svc diff --git a/Svc/GroundInterface/GroundInterface.hpp b/Svc/GroundInterface/GroundInterface.hpp index 02e729510cd..06ac584a1c9 100644 --- a/Svc/GroundInterface/GroundInterface.hpp +++ b/Svc/GroundInterface/GroundInterface.hpp @@ -3,11 +3,12 @@ // \author lestarch // \brief hpp file for GroundInterface component implementation class // ====================================================================== +#ifndef GroundInterface_HPP +#define GroundInterface_HPP + #include #include "Svc/GroundInterface/GroundInterfaceComponentAc.hpp" #include "Utils/Types/CircularBuffer.hpp" -#ifndef GroundInterface_HPP -#define GroundInterface_HPP #define GND_BUFFER_SIZE 1024 #define TOKEN_TYPE U32 @@ -56,6 +57,25 @@ namespace Svc { U32 context /*!< Call context value; meaning chosen by user*/ ); + //! Handler implementation for eventReport + //! + void eventReport_handler( + const NATIVE_INT_TYPE portNum, /*!< The port number*/ + FwEventIdType id, /*!< Log ID*/ + Fw::Time &timeTag, /*!< Time Tag*/ + Fw::LogSeverity severity, /*!< The severity argument*/ + Fw::LogBuffer &args /*!< Buffer containing serialized log entry*/ + ); + + //! Handler implementation for hkReport + //! + void hkReport_handler( + const NATIVE_INT_TYPE portNum, /*!< The port number*/ + FwChanIdType id, /*!< Telemetry Channel ID*/ + Fw::Time &timeTag, /*!< Time Tag*/ + Fw::TlmBuffer &val /*!< Buffer containing serialized telemetry value*/ + ); + //! Handler implementation for fileDownlinkBufferSendIn //! void fileDownlinkBufferSendIn_handler( diff --git a/Svc/GroundInterface/GroundInterfaceComponentAi.xml b/Svc/GroundInterface/GroundInterfaceComponentAi.xml index f09375c5c17..0bcdc15ae1e 100644 --- a/Svc/GroundInterface/GroundInterfaceComponentAi.xml +++ b/Svc/GroundInterface/GroundInterfaceComponentAi.xml @@ -9,11 +9,24 @@ Fw/Time/TimePortAi.xml Fw/Buffer/BufferGetPortAi.xml Svc/Sched/SchedPortAi.xml + Fw/Tlm/TlmPortAi.xml Svc/GroundInterface/Events.xml - + + + + + + Event input port + + + + + + Housekeeping input port + diff --git a/Svc/TlmChan/CMakeLists.txt b/Svc/TlmChan/CMakeLists.txt index 171181dd181..c64b464bf92 100644 --- a/Svc/TlmChan/CMakeLists.txt +++ b/Svc/TlmChan/CMakeLists.txt @@ -9,14 +9,10 @@ set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/TlmChanComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/TlmChanImpl.cpp" - "${CMAKE_CURRENT_LIST_DIR}/TlmChanImplGet.cpp" - "${CMAKE_CURRENT_LIST_DIR}/TlmChanImplRecv.cpp" - "${CMAKE_CURRENT_LIST_DIR}/TlmChanImplTask.cpp" ) register_fprime_module() - ### UTs ### set(UT_SOURCE_FILES "${FPRIME_FRAMEWORK_PATH}/Svc/TlmChan/TlmChanComponentAi.xml" diff --git a/Svc/TlmChan/TlmChanComponentAi.xml b/Svc/TlmChan/TlmChanComponentAi.xml index 4619238bdc4..aac5e5350c1 100644 --- a/Svc/TlmChan/TlmChanComponentAi.xml +++ b/Svc/TlmChan/TlmChanComponentAi.xml @@ -18,6 +18,11 @@ Telemetry input port + + + Telemetry output port + + Run port for starting packet send cycle diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index a3b1ea9689e..f0908d8af3d 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -10,11 +10,12 @@ *

*/ #include -#include #include #include #include +#include +#include #include namespace Svc { @@ -44,12 +45,9 @@ namespace Svc { // clear free index this->m_tlmEntries[0].free = 0; this->m_tlmEntries[1].free = 0; - - } - TlmChanImpl::~TlmChanImpl() { - } + TlmChanImpl::~TlmChanImpl() {} void TlmChanImpl::init( NATIVE_INT_TYPE queueDepth, /*!< The queue depth*/ @@ -65,11 +63,122 @@ namespace Svc { void TlmChanImpl::pingIn_handler( const NATIVE_INT_TYPE portNum, U32 key - ) - { + ) { // return key this->pingOut_out(0,key); } + void TlmChanImpl::Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) { + // Only write packets if connected + if (not this->isConnected_PktSend_OutputPort(0)) { + return; + } + + // lock mutex long enough to modify active telemetry buffer + // so the data can be read without worrying about updates + this->lock(); + this->m_activeBuffer = 1 - this->m_activeBuffer; + // set activeBuffer to not updated + for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { + this->m_tlmEntries[this->m_activeBuffer].buckets[entry].updated = false; + } + this->unLock(); + + // go through each entry and send a packet if it has been updated + + for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { + TlmEntry* p_entry = &this->m_tlmEntries[1-this->m_activeBuffer].buckets[entry]; + if ((p_entry->updated) && (p_entry->used)) { + this->m_tlmPacket.setId(p_entry->id); + this->m_tlmPacket.setTimeTag(p_entry->lastUpdate); + this->m_tlmPacket.setTlmBuffer(p_entry->buffer); + this->m_comBuffer.resetSer(); + Fw::SerializeStatus stat = this->m_tlmPacket.serialize(this->m_comBuffer); + FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); + p_entry->updated = false; + + if (this->isConnected_PktSend_OutputPort(0)) { + this->PktSend_out(0,this->m_comBuffer,0); + } + + if (this->isConnected_PktSend_OutputPort(0)) { + this->TlmSend_out(0, p_entry->id, p_entry->lastUpdate, p_entry->buffer); + } + + } + } + } + void TlmChanImpl::TlmRecv_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { + // Compute index for entry + NATIVE_UINT_TYPE index = this->doHash(id); + TlmEntry* entryToUse = 0; + TlmEntry* prevEntry = 0; + + // Search to see if channel has already been stored or a bucket needs to be added + if (this->m_tlmEntries[this->m_activeBuffer].slots[index]) { + entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index]; + for (NATIVE_UINT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + if (entryToUse) { + if (entryToUse->id == id) { // found the matching entry + break; + } else { // try next entry + prevEntry = entryToUse; + entryToUse = entryToUse->next; + } + } else { + // Make sure that we haven't run out of buckets + FW_ASSERT(this->m_tlmEntries[this->m_activeBuffer].free < TLMCHAN_HASH_BUCKETS); + // add new bucket from free list + entryToUse = &this->m_tlmEntries[this->m_activeBuffer].buckets[this->m_tlmEntries[this->m_activeBuffer].free++]; + prevEntry->next = entryToUse; + // clear next pointer + entryToUse->next = 0; + break; + } + } + } else { + // Make sure that we haven't run out of buckets + FW_ASSERT(this->m_tlmEntries[this->m_activeBuffer].free < TLMCHAN_HASH_BUCKETS); + // create new entry at slot head + this->m_tlmEntries[this->m_activeBuffer].slots[index] = &this->m_tlmEntries[this->m_activeBuffer].buckets[this->m_tlmEntries[this->m_activeBuffer].free++]; + entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index]; + entryToUse->next = 0; + } + + // copy into entry + FW_ASSERT(entryToUse); + entryToUse->used = true; + entryToUse->id = id; + entryToUse->updated = true; + entryToUse->lastUpdate = timeTag; + entryToUse->buffer = val; + + } + void TlmChanImpl::TlmGet_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { + // Compute index for entry + NATIVE_UINT_TYPE index = this->doHash(id); + + // Search to see if channel has been stored + TlmEntry *entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index]; + for (NATIVE_UINT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + if (entryToUse) { // If bucket exists, check id + if (entryToUse->id == id) { + break; + } else { // otherwise go to next bucket + entryToUse = entryToUse->next; + } + } else { // no buckets left to search + break; + } + } + + if (entryToUse) { + val = entryToUse->buffer; + timeTag = entryToUse->lastUpdate; + } else { // requested entry may not be written yet; empty buffer + val.resetSer(); + } + + } } diff --git a/Svc/TlmChan/TlmChanImpl.hpp b/Svc/TlmChan/TlmChanImpl.hpp index 3a7f801cb9e..45da4ac0364 100644 --- a/Svc/TlmChan/TlmChanImpl.hpp +++ b/Svc/TlmChan/TlmChanImpl.hpp @@ -70,7 +70,6 @@ namespace Svc { Fw::TlmPacket m_tlmPacket; }; - } #endif /* TELEMCHANIMPL_HPP_ */ From 8a453154874f769eb3e31d35aa2cc99cca971c98 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 14 Jan 2021 14:55:36 +0100 Subject: [PATCH 08/29] Fix merge changes --- Svc/GroundInterface/GroundInterface.cpp | 42 ++++++++++++------------- Utils/Types/CircularBuffer.hpp | 4 +-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 4e227e55723..58e81c4c67a 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -98,7 +98,6 @@ void GroundInterfaceComponentImpl::readCallback_handler( #endif } - void GroundInterfaceComponentImpl::eventReport_handler( const NATIVE_INT_TYPE portNum, FwEventIdType id, @@ -166,10 +165,10 @@ void GroundInterfaceComponentImpl::eventReport_handler( } void GroundInterfaceComponentImpl::hkReport_handler( - const NATIVE_INT_TYPE portNum, - FwChanIdType id, - Fw::Time &timeTag, - Fw::TlmBuffer &val + const NATIVE_INT_TYPE portNum, + FwChanIdType id, + Fw::Time &timeTag, + Fw::TlmBuffer &val ) { // F' variables Fw::Buffer buffer; @@ -200,6 +199,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( charge_estimation++; } + void GroundInterfaceComponentImpl::schedIn_handler( const NATIVE_INT_TYPE portNum, /*!< The port number*/ NATIVE_UINT_TYPE context /*!< The call order*/ @@ -309,20 +309,19 @@ void GroundInterfaceComponentImpl::processRing() { //*/ } -void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) - { - NATIVE_UINT_TYPE buffer_offset = 0; - while (buffer_offset < buffer.getSize()) { - NATIVE_UINT_TYPE ser_size = (buffer.getSize() >= m_in_ring.get_remaining_size(true)) ? - m_in_ring.get_remaining_size(true) : static_cast(buffer.getSize()); - m_in_ring.serialize(buffer.getData() + buffer_offset, ser_size); - buffer_offset = buffer_offset + ser_size; - processRing(); - } - } +void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { + NATIVE_UINT_TYPE buffer_offset = 0; + while (buffer_offset < buffer.getSize()) { + NATIVE_UINT_TYPE ser_size = (buffer.getSize() >= m_in_ring.get_remaining_size(true)) ? + m_in_ring.get_remaining_size(true) : static_cast(buffer.getSize()); + m_in_ring.serialize(buffer.getData() + buffer_offset, ser_size); + buffer_offset = buffer_offset + ser_size; + processRing(); + } +} - void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { - printf("Data received : %u\n", buffer.getSize()); +void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { + printf("Data received : %u\n", buffer.getSize()); Fw::Buffer extBuff = m_ext_buffer; /* Push received data byte-by-byte into PUSopen(R) stack */ U8 service = buffer.getData()[9]; @@ -330,7 +329,7 @@ void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) printf("%d data : %hhu \n",i,buffer.getData()[i]); po_accept(buffer.getData()[i]); // todo propre reinterpret_cast } - + /* Unwrap TC[17,x] from received CCSDS packet */ po_triggerPs(); @@ -343,13 +342,14 @@ void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) /* Retrieve created TM[17,x] byte stream from PUSopen(R) stack and send it */ po_frame(buf, &len); - + if (len > 0) { extBuff.setSize(len); extBuff.setData(buf); write_out(0,extBuff); } - } +} + #ifdef __cplusplus extern "C" { diff --git a/Utils/Types/CircularBuffer.hpp b/Utils/Types/CircularBuffer.hpp index ecfc6b3a45b..0070129079b 100644 --- a/Utils/Types/CircularBuffer.hpp +++ b/Utils/Types/CircularBuffer.hpp @@ -18,7 +18,7 @@ #ifndef TYPES_CIRCULAR_BUFFER_HPP #define TYPES_CIRCULAR_BUFFER_HPP -//#define CIRCULAR_DEBUG +// #define CIRCULAR_DEBUG // An assertion to guarantee the self-consistency of a head/tail pointer w.r.t. the store and size #define ASSERT_CONSISTENT(store, size, X) \ @@ -51,7 +51,7 @@ class CircularBuffer { /** * Deserialize data into the given variable without moving the head pointer - * \param U8& value: value to fill + * \param char& value: value to fill */ Fw::SerializeStatus peek(char& value, NATIVE_UINT_TYPE offset = 0); /** From d03970ab1646af7656de4801a820d076949873e9 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 14 Jan 2021 19:34:14 +0100 Subject: [PATCH 09/29] Improve downlink services - PoC --- Lib/.gitignore | 1 + .../PingReceiverComponentImpl.cpp | 4 +- .../PingReceiverComponentImpl.hpp | 2 - Svc/ActiveLogger/ActiveLoggerImpl.cpp | 6 +- Svc/GroundInterface/GroundInterface.cpp | 201 +++++++++++------- Svc/GroundInterface/GroundInterface.hpp | 5 + Svc/GroundInterface/GroundInterfaceCfg.hpp | 14 ++ Svc/GroundInterface/pusopen_onboard_mdb.c | 52 ++++- Svc/GroundInterface/pusopen_onboard_mdb.xml | 38 +++- Svc/TlmChan/TlmChanImpl.cpp | 5 +- config/ActiveLoggerImplCfg.hpp | 4 +- config/SocketIpDriverCfg.hpp | 2 +- 12 files changed, 235 insertions(+), 99 deletions(-) create mode 100644 Svc/GroundInterface/GroundInterfaceCfg.hpp diff --git a/Lib/.gitignore b/Lib/.gitignore index d22aba831e2..3f1579efd78 100644 --- a/Lib/.gitignore +++ b/Lib/.gitignore @@ -3,5 +3,6 @@ lib bin examples +!examples/gs Includes diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.cpp b/Ref/PingReceiver/PingReceiverComponentImpl.cpp index 8d6e5e68695..1867176a1b1 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.cpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.cpp @@ -53,8 +53,8 @@ namespace Ref { U32 key ) { - //this->log_DIAGNOSTIC_PR_PingReceived(key); - this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); + this->log_DIAGNOSTIC_PR_PingReceived(key); + //this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); if (not this->m_inhibitPings) { PingOut_out(0,key); } diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.hpp b/Ref/PingReceiver/PingReceiverComponentImpl.hpp index 053604ef8a1..458a7b25af0 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.hpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.hpp @@ -64,8 +64,6 @@ namespace Ref { bool m_inhibitPings; U32 m_pingsRecvd; - - }; } // end namespace Ref diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index d32a242da0d..5a26a5761f9 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -187,15 +187,17 @@ namespace Svc { FW_ASSERT(0,static_cast(severity)); return; } - + +#if defined _GDS if (this->isConnected_PktSend_OutputPort(0)) { this->PktSend_out(0, this->m_comBuffer,0); } - +#elif defined _PUS // redirect event through event output if (this->isConnected_LogSend_OutputPort(0)) { this->LogSend_out(0, id, timeTag, static_cast(severity) , args); } +#endif } void ActiveLoggerImpl::ALOG_SET_EVENT_REPORT_FILTER_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, InputFilterLevel FilterLevel, InputFilterEnabled FilterEnable) { diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 58e81c4c67a..67de792e9cc 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -2,6 +2,9 @@ // \title GroundInterface.cpp // \author lestarch // \brief cpp file for GroundInterface component implementation class +// +// Define _PUS or _GDS depending on GS/protocols needs. +// Currently set in App/CmakeLists.txt // ====================================================================== #include @@ -9,6 +12,7 @@ #include #include #include +#include #include "Fw/Types/BasicTypes.hpp" #include @@ -24,11 +28,13 @@ const U32 GroundInterfaceComponentImpl::END_WORD = static_cast(0xcafecafe); #ifdef __cplusplus extern "C" { #endif -U32 charge_estimation = 0x32U; +U32 PR_NumPings = 0; #ifdef __cplusplus } #endif + + // ------------------------------------- --------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -54,8 +60,6 @@ void GroundInterfaceComponentImpl::init(const NATIVE_INT_TYPE instance) { // PUSOpen initialisation error ! Critical error with FSW FW_ASSERT(0); } - - charge_estimation = 0; } GroundInterfaceComponentImpl::~GroundInterfaceComponentImpl(void) {} @@ -81,9 +85,9 @@ void GroundInterfaceComponentImpl::fileDownlinkBufferSendIn_handler( Fw::Buffer &fwBuffer ) { #if defined _GDS - FW_ASSERT(fwBuffer.getSize() <= MAX_DATA_SIZE); - frame_send(fwBuffer.getData(), fwBuffer.getSize(), Fw::ComPacket::FW_PACKET_FILE); - fileDownlinkBufferSendOut_out(0, fwBuffer); + FW_ASSERT(fwBuffer.getSize() <= MAX_DATA_SIZE); + frame_send(fwBuffer.getData(), fwBuffer.getSize(), Fw::ComPacket::FW_PACKET_FILE); + fileDownlinkBufferSendOut_out(0, fwBuffer); #endif } @@ -91,10 +95,15 @@ void GroundInterfaceComponentImpl::readCallback_handler( const NATIVE_INT_TYPE portNum, Fw::Buffer &buffer ) { + if(isConnected_readPoll_OutputPort(0)) { + // User should chose to use callback or poll method for uplink data + FW_ASSERT(0); + } + #if defined _PUS - processPUS(buffer); + processPUS(buffer); #elif defined _GDS - processBuffer(buffer); + processBuffer(buffer); #endif } @@ -105,63 +114,95 @@ void GroundInterfaceComponentImpl::eventReport_handler( Fw::LogSeverity severity, Fw::LogBuffer &args ) { - printf("Event received : %u\n", id); // F' variables - Fw::Buffer buffer; - - Fw::LogPacket m_logPacket; //!< packet buffer for assembling log packets - Fw::ComBuffer m_comBuffer; //!< com buffer for sending event buffers - - m_logPacket.setId(id); - m_logPacket.setTimeTag(timeTag); - m_logPacket.setLogBuffer(args); - Fw::SerializeStatus stat = m_logPacket.serialize(m_comBuffer); - FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); + Fw::Buffer buffer; //!< buffer to send frame to SocketIpDriver + //Fw::LogPacket m_logPacket; //!< Packet buffer for assembling log packets + //Fw::ComBuffer m_comBuffer; //!< Com buffer for sending event buffers // PUSOpen variables U8 po_buf[512]; - U8 po_evtData[] = {4, 3, 6, 9, 8}; + U8 po_evtData = 0; U16 po_len; po_result_t po_res = PO_ERR; + pus5_evtId_t po_pus5_eventId = PUS5_EVT_HIGH; // default value + + printf("[PUS] Event received : %u (0x%02X)\n", id, id); - /** PUS Service 5 severity level + /** + ---- PUS Service 5 severity level ---- PUS5_EVT_INFO = Information event TM[5,1] PUS5_EVT_LOW = Low severity anomaly TM[5,2] PUS5_EVT_MEDIUM = Medium severity anomaly TM[5,3] PUS5_EVT_HIGH = High severity anomaly TM[5,4] - **/ - /** F' Events severity level - Conversion table - DIAGNOSTIC → PUS5_EVT_INFO - ACTIVITY_LO → PUS5_EVT_INFO - ACTIVITY_HI → PUS5_EVT_INFO - WARNING_LO → PUS5_EVT_LOW - WARNING_HI → PUS5_EVT_MEDIUM - FATAL → PUS5_EVT_HIGH - COMMAND → PUS5_EVT_INFO + ---- F' Events severity level ---- + LOG_DIAGNOSTIC → PUS5_EVT_INFO + LOG_ACTIVITY_LO → PUS5_EVT_INFO + LOG_COMMAND → PUS5_EVT_INFO + LOG_ACTIVITY_HI → PUS5_EVT_LOW + LOG_WARNING_LO → PUS5_EVT_MEDIUM + LOG_ACTIVITY_HI → PUS5_EVT_HIGH + LOG_FATAL → PUS5_EVT_HIGH - internal handling in the future **/ + switch(severity) { + case Fw::LOG_DIAGNOSTIC: + case Fw::LOG_ACTIVITY_LO: + case Fw::LOG_COMMAND: + po_pus5_eventId = PUS5_EVT_INFO; + break; + case Fw::LOG_ACTIVITY_HI: + po_pus5_eventId = PUS5_EVT_LOW; + break; + case Fw::LOG_WARNING_LO: + po_pus5_eventId = PUS5_EVT_MEDIUM; + break; + case Fw::LOG_WARNING_HI: + po_pus5_eventId = PUS5_EVT_HIGH; + break; + case Fw::LOG_FATAL: + po_pus5_eventId = PUS5_EVT_HIGH; + break; + default: + po_pus5_eventId = PUS5_EVT_HIGH; + } - // Send TM[5,x] with event ID = x - po_res = po_pus5tm(PUS5_EVT_INFO, // event ID - po_evtData, // event data - 3U); // destination APID (GS) + /*/ Event arguments to serialize + m_logPacket.setId(id); + m_logPacket.setTimeTag(timeTag); + m_logPacket.setLogBuffer(args); + Fw::SerializeStatus stat = m_logPacket.serialize(m_comBuffer); + FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); + //*/ + // Sample - In the future serialize id and LogBuffer + po_evtData = id; + + this->m_poStackMutex.lock(); + + // Send TM[5,x] with F' event ID = x + po_res = po_pus5tm( po_pus5_eventId, // event ID PUS[5, x] + &po_evtData, // event data + GS_APID); // destination APID (GS) if(po_res != PO_SUCCESS) { - printf("po error: %u\n", po_res); + printf("[PUS] po error: %u\n", po_res); FW_ASSERT(0); } // Retrieve created TM[5,x] byte stream from PUSopen stack and send it po_res = po_frame(po_buf, &po_len); + if(po_res != PO_SUCCESS) { - printf("po error: %u\n", po_res); + printf("[PUS] po error: %u\n", po_res); FW_ASSERT(0); } + this->m_poStackMutex.unLock(); + buffer.setData(po_buf); buffer.setSize(po_len); - //write_out(0, buffer); // @todo uncomment + write_out(0, buffer); + } void GroundInterfaceComponentImpl::hkReport_handler( @@ -172,34 +213,42 @@ void GroundInterfaceComponentImpl::hkReport_handler( ) { // F' variables Fw::Buffer buffer; + U32 tlmVal; // PUSOpen variables U8 po_buf[512]; U16 po_len; po_result_t po_res = PO_ERR; - printf("Housekeeping received : %u\n", id); + // printf("[PUS] Housekeeping received : %u (0x%02X)\n", id, id); + + this->m_poStackMutex.lock(); - // Trigger PUS 3 Service provider to generate TM[3,25] - po_triggerPus3(); + // Sample - In the future serialize id and TlmBuffer + switch(id) { + case 0x29: // (41) PR_NumPings + val.deserialize(tlmVal); + PR_NumPings = tlmVal; + printf("[PUS] Housekeeping PR_NumPings received : %u \n", tlmVal); + // Trigger PUS 3 Service provider to generate TM[3,25] + po_triggerPus3(); + break; + } // Retrieve created TM[3,25] byte stream from PUSopen stack and send it po_res = po_frame(po_buf, &po_len); - if(po_res != PO_SUCCESS) { - printf("po error: %u\n", po_res); - FW_ASSERT(0); - } - - buffer.setData(po_buf); - buffer.setSize(po_len); - //write_out(0, buffer); // @todo uncomment + this->m_poStackMutex.unLock(); - // Increment charge_estimation for demonstration - charge_estimation++; + // If a report has been generated, send it + if(po_len > 0) { + buffer.setData(po_buf); + buffer.setSize(po_len); + printf("[PUS] Send report\n"); + write_out(0, buffer); + } } - void GroundInterfaceComponentImpl::schedIn_handler( const NATIVE_INT_TYPE portNum, /*!< The port number*/ NATIVE_UINT_TYPE context /*!< The call order*/ @@ -209,7 +258,11 @@ void GroundInterfaceComponentImpl::schedIn_handler( // Call read poll if it is hooked up if (isConnected_readPoll_OutputPort(0)) { readPoll_out(0, buffer); - processBuffer(buffer); +#if defined _PUS + processPUS(buffer); +#elif defined _GDS + processBuffer(buffer); +#endif } } @@ -271,7 +324,7 @@ void GroundInterfaceComponentImpl::routeComData() { default: return; } - } +} void GroundInterfaceComponentImpl::processRing() { // Header items for the packet @@ -321,28 +374,34 @@ void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { } void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { - printf("Data received : %u\n", buffer.getSize()); Fw::Buffer extBuff = m_ext_buffer; - /* Push received data byte-by-byte into PUSopen(R) stack */ - U8 service = buffer.getData()[9]; + + // Transmission buffer + U8 buf[128]; + U16 len; + + // printf("[PUS] Data received : %u\n", buffer.getSize()); + + + this->m_poStackMutex.lock(); + + // Push received data byte-by-byte into PUSopen(R) stack for(int i = 0; i < buffer.getSize(); i++) { - printf("%d data : %hhu \n",i,buffer.getData()[i]); + //printf("[PUS] %d data : %hhu \n",i,buffer.getData()[i]); po_accept(buffer.getData()[i]); // todo propre reinterpret_cast } - /* Unwrap TC[17,x] from received CCSDS packet */ + // Unwrap TC[x,y] from received CCSDS packet po_triggerPs(); - /* Forward TC[17,x] to PUS 17 */ + // Forward TC[x,y] to PUS x po_triggerPus1(); - /* Transmission buffer */ - U8 buf[128]; - U16 len; - - /* Retrieve created TM[17,x] byte stream from PUSopen(R) stack and send it */ + // Retrieve potentially created TM[17,x] byte stream from PUSopen(R) stack and send it po_frame(buf, &len); + this->m_poStackMutex.unLock(); + if (len > 0) { extBuff.setSize(len); extBuff.setData(buf); @@ -356,15 +415,15 @@ extern "C" { #endif /** - * User-defined function triggered by PUS 8 provider. - * This function is defined in the Mission Database - * mdb_server.xml under . - */ +* User-defined function triggered by PUS 8 provider. +* This function is defined in the Mission Database +* mdb_server.xml under . +*/ po_result_t UserPus8Fn (uint8_t fid, uint8_t *data, uint16_t len) { - printf("PUS8 User Function triggered.\n"); - printf("Function ID = %u.\n", fid); - printf("Received data (len = %u): %u %u %u %u\n", len, data[0], data[1], data[2], data[3]); + printf("[PUS] PUS8 User Function triggered.\n"); + printf("[PUS] Function ID = %u.\n", fid); + printf("[PUS] Received data (len = %u): %u %u %u %u\n", len, data[0], data[1], data[2], data[3]); return PO_SUCCESS; } diff --git a/Svc/GroundInterface/GroundInterface.hpp b/Svc/GroundInterface/GroundInterface.hpp index 06ac584a1c9..70082424d13 100644 --- a/Svc/GroundInterface/GroundInterface.hpp +++ b/Svc/GroundInterface/GroundInterface.hpp @@ -7,6 +7,8 @@ #define GroundInterface_HPP #include +#include + #include "Svc/GroundInterface/GroundInterfaceComponentAc.hpp" #include "Utils/Types/CircularBuffer.hpp" @@ -117,10 +119,13 @@ namespace Svc { // Basic data movement variables Fw::Buffer m_ext_buffer; U8 m_buffer[GND_BUFFER_SIZE]; + // Input variables TOKEN_TYPE m_data_size; //!< Data size expected in incoming data U8 m_in_buffer[GND_BUFFER_SIZE]; Types::CircularBuffer m_in_ring; + + Os::Mutex m_poStackMutex; /*!< Protect access to PUSOpen stack */ }; } // end namespace Svc diff --git a/Svc/GroundInterface/GroundInterfaceCfg.hpp b/Svc/GroundInterface/GroundInterfaceCfg.hpp new file mode 100644 index 00000000000..a4c7e59eb65 --- /dev/null +++ b/Svc/GroundInterface/GroundInterfaceCfg.hpp @@ -0,0 +1,14 @@ +// ====================================================================== +// \title GroundInterfaceCfg.hpp +// \author jonathanmichel +// \brief hpp file for GroundInterface component configuration +// ====================================================================== + +#ifndef SVC_GROUNDINTERFACECGF_HPP +#define SVC_GROUNDINTERFACECGF_HPP + +enum GroundIntefaceCfg { + GS_APID = 3U, // Ground segement APID +}; + +#endif //SVC_GROUNDINTERFACECGF_HPP diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.c b/Svc/GroundInterface/pusopen_onboard_mdb.c index 201c67323f7..f411ced8142 100644 --- a/Svc/GroundInterface/pusopen_onboard_mdb.c +++ b/Svc/GroundInterface/pusopen_onboard_mdb.c @@ -11,7 +11,7 @@ /* Included PUSopen(R) modules */ #define PUS1_PROVIDER -/* #define PUS3_PROVIDER */ +#define PUS3_PROVIDER #define PUS5_PROVIDER #define PUS8_PROVIDER /* #define PUS13_PROVIDER */ @@ -26,6 +26,9 @@ /* PUS 1 - Virtual Channel for TM[1,x] */ #define PUS1_VCID 1 +/* PUS 3 - Size of buffer in which TM[3,25] report is composed (in bytes) */ +#define PUS3_REPORT_BUF_SIZE 1 + /* PUS 17 - Virtual Channel for TM[17,x] */ #define PUS17_VCID 0 @@ -78,6 +81,10 @@ PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); #endif +#ifdef PUS3_PROVIDER +PUS3_PROVIDER_INIT(pus3, PUS3_REPORT_BUF_SIZE); +#endif + #ifdef PUS5_PROVIDER PUS5_PROVIDER_INIT(pus5); #endif @@ -105,8 +112,10 @@ FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEN /* User Code */ -extern uint32_t charge_estimation; -extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + + extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + extern uint32_t PR_NumPings; + /* On-board Events */ @@ -114,8 +123,29 @@ po_evt_t evt[] = { { .id = 1U, .level = PUS5_EVT_INFO, - .desc = "Informative event", - .dataLen = 4U, + .desc = "Information event", + .dataLen = 1U, + .vcid = 1U + }, + { + .id = 2U, + .level = PUS5_EVT_LOW, + .desc = "Low severity anomaly", + .dataLen = 1U, + .vcid = 1U + }, + { + .id = 3U, + .level = PUS5_EVT_MEDIUM, + .desc = "Medium severity anomaly", + .dataLen = 1U, + .vcid = 1U + }, + { + .id = 4U, + .level = PUS5_EVT_HIGH, + .desc = "High severity anomaly", + .dataLen = 1U, .vcid = 1U } }; @@ -167,10 +197,10 @@ PO_MDB_PARAMS_PUSUSR #endif { .id = 100U, - .name = "EPS_charge_estimation", - .desc = "EPS Charge estimation", + .name = "PR_NumPings", + .desc = "Number of pings received", .type = PO_UINT32, - .addr = &charge_estimation + .addr = &PR_NumPings } }; @@ -198,7 +228,7 @@ po_mdbapid_t po_mdb_apid = { .apuid = 2, .pus1 = POADDR(pus1), - .pus3 = PONULL, + .pus3 = POADDR(pus3), .pus5 = POADDR(pus5), .pus8 = POADDR(pus8), .pus13 = PONULL, @@ -208,8 +238,8 @@ po_mdbapid_t po_mdb_apid = { .vc = PONULL, .fess = POADDR(fess), - .numevt = 1U, - .numparams = 41U, + .numevt = 4U, + .numparams = 42U, .numreports = 1U, .numfct = 1U, .events = evt, diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.xml b/Svc/GroundInterface/pusopen_onboard_mdb.xml index a1f1eb2c5ca..2a8e27f3cbc 100644 --- a/Svc/GroundInterface/pusopen_onboard_mdb.xml +++ b/Svc/GroundInterface/pusopen_onboard_mdb.xml @@ -28,7 +28,7 @@ Compile this xml into .c file with poconfig tool : - false + true @@ -137,13 +137,37 @@ Compile this xml into .c file with poconfig tool : 1 PUS5_EVT_INFO - Informative event - 4 + Information event + 1 + + + + 2 + PUS5_EVT_LOW + Low severity anomaly + 1 + + + + 3 + PUS5_EVT_MEDIUM + Medium severity anomaly + 1 + + + + 4 + PUS5_EVT_HIGH + High severity anomaly + 1 - extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + + extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); + extern uint32_t PR_NumPings; + @@ -158,10 +182,10 @@ Compile this xml into .c file with poconfig tool : 100 - EPS_charge_estimation - EPS Charge estimation + PR_NumPings + Number of pings received PO_UINT32 - charge_estimation + PR_NumPings diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index f0908d8af3d..71aab307e4f 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -89,6 +89,7 @@ namespace Svc { for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { TlmEntry* p_entry = &this->m_tlmEntries[1-this->m_activeBuffer].buckets[entry]; if ((p_entry->updated) && (p_entry->used)) { +#if defined _GDS this->m_tlmPacket.setId(p_entry->id); this->m_tlmPacket.setTimeTag(p_entry->lastUpdate); this->m_tlmPacket.setTlmBuffer(p_entry->buffer); @@ -100,11 +101,13 @@ namespace Svc { if (this->isConnected_PktSend_OutputPort(0)) { this->PktSend_out(0,this->m_comBuffer,0); } +#elif defined _PUS + p_entry->updated = false; if (this->isConnected_PktSend_OutputPort(0)) { this->TlmSend_out(0, p_entry->id, p_entry->lastUpdate, p_entry->buffer); } - +#endif } } } diff --git a/config/ActiveLoggerImplCfg.hpp b/config/ActiveLoggerImplCfg.hpp index 5a94cd30d44..19fb277e49a 100644 --- a/config/ActiveLoggerImplCfg.hpp +++ b/config/ActiveLoggerImplCfg.hpp @@ -18,14 +18,14 @@ enum { INPUT_COMMAND_DEFAULT = true, //!< COMMAND events are filtered at input INPUT_ACTIVITY_HI_DEFAULT = true, //!< ACTIVITY HI events are filtered at input INPUT_ACTIVITY_LO_DEFAULT = true, //!< ACTIVITY LO events are filtered at input - INPUT_DIAGNOSTIC_DEFAULT = false, //!< DIAGNOSTIC events are filtered at input + INPUT_DIAGNOSTIC_DEFAULT = true, //!< DIAGNOSTIC events are filtered at input SEND_WARNING_HI_DEFAULT = true, //!< WARNING HI events are filtered at output SEND_WARNING_LO_DEFAULT = true, //!< WARNING LO events are filtered at output SEND_COMMAND_DEFAULT = true, //!< COMMAND events are filtered at output SEND_ACTIVITY_HI_DEFAULT = true, //!< ACTIVITY HO events are filtered at output SEND_ACTIVITY_LO_DEFAULT = true, //!< ACTIVITY LO events are filtered at output - SEND_DIAGNOSTIC_DEFAULT = false //!< DIAGNOSTIC events are filtered at output + SEND_DIAGNOSTIC_DEFAULT = true //!< DIAGNOSTIC events are filtered at output }; // set event history circular buffer sizes diff --git a/config/SocketIpDriverCfg.hpp b/config/SocketIpDriverCfg.hpp index 67b3955cd4e..50ba7d76862 100644 --- a/config/SocketIpDriverCfg.hpp +++ b/config/SocketIpDriverCfg.hpp @@ -20,7 +20,7 @@ enum SocketIpCfg { SOCKET_TIMEOUT_MICROSECONDS = 0, // Milliseconds component of timeout #if defined _PUS SOCKET_SEND_UDP = 0, - #elif _GDS + #elif defined _GDS SOCKET_SEND_UDP = 1, #endif // 0 - Send down using TCP, 1 - Send down using UDP SOCKET_SEND_FLAGS = 0, // send, sendto FLAGS argument From 6c368ce04c7357c61f77c955b1053e4b91224d35 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 14 Jan 2021 19:39:54 +0100 Subject: [PATCH 10/29] GS PUS example --- Lib/.gitignore | 5 +- Lib/examples/gs/gs | Bin 0 -> 39712 bytes Lib/examples/gs/main_gs.c | 143 +++++++++++++++++++++++ Lib/examples/gs/mdb_gs.c | 213 +++++++++++++++++++++++++++++++++++ Lib/examples/gs/mdb_gs.xml | 121 ++++++++++++++++++++ Lib/examples/gs/subnetwork.c | 65 +++++++++++ 6 files changed, 545 insertions(+), 2 deletions(-) create mode 100755 Lib/examples/gs/gs create mode 100644 Lib/examples/gs/main_gs.c create mode 100644 Lib/examples/gs/mdb_gs.c create mode 100644 Lib/examples/gs/mdb_gs.xml create mode 100644 Lib/examples/gs/subnetwork.c diff --git a/Lib/.gitignore b/Lib/.gitignore index 3f1579efd78..833a732f5b6 100644 --- a/Lib/.gitignore +++ b/Lib/.gitignore @@ -2,7 +2,8 @@ lib bin -examples -!examples/gs +examples/* +!examples/gs/ + Includes diff --git a/Lib/examples/gs/gs b/Lib/examples/gs/gs new file mode 100755 index 0000000000000000000000000000000000000000..50f0cb901c338e26f9e66f4203d9cd2a185f839c GIT binary patch literal 39712 zcmeHwdwdjCmVb4p6Pi~#Dndq4TWvH^h-pMf6g5q{p&}hb6T}_SCM4aEAurR_JVwws zooH%eJM4_ku(Pu(zZqxN*>xRe#RSoT4nZEiCgO_`)aas9F{sf|Km_{tJ@?V6Zj#;o z{672N&*DSQz2AH8xvz82J@;01)qOtyT&u;R$SXs+L7`aFSsW=534K2k0gw`j!LR1P6kju zs;j-8MM0e`AZd=M*b@_Zy39w_qkOp{U#`d}>7b~Xq_Ta~Hu_&F+LunfNTW+q;-zch zM_LVq>lU!+8T3gZPg0rh7U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o(rVAv``ZugMtC%3VL6Lxxd8RefzW>O^Zv0p@^G0JpOquB6$2 z{eKLT8&6v_xZ~`S_pv3F=k+3)@yak!+IM5im&{)&1WD>dn)#CF3=(rAV9u|J{E~|8 zoMgwnfz*rKd%OaqQPzK>2uLdHk7FoyVSAKvEkKO+qsi=E3zf)FY$j$%P-G`Bt2W~V`Y9> zu8jXCEx&y3K~ij2Q?B&(|6b&m<0sGaBz;K^oRH#7k)|krOv_(K69Si{PfEcYKBNEn zefS~$k+K!2oTqCPLh9Ren~$;iaCGsT)K&8 zq5Bl(%V~}vJc$1!OO`L6FUgH?MtUcb`Er^g2!D +#include "clientserver.h" + +#include "pusopen.h" + +// Stop flag for main application loop +uint8_t stop = 0U; + + +// PUSopen(R) callback for telemetry (TM) reception +po_result_t pususr_tm(po_tmdesc_t * tm) +{ + uint16_t i = 0U; + + printf(" TM %2u %2u Dest APID:%2u Flags:%u Count:%5u Payload (%2u bytes) ", + tm->service, tm->subservice, tm->destid, tm->pktSeqFlags, tm->pktSeqCount, tm->dataLen); + + for (i = 0U; i < tm->dataLen; i++) { + printf("%02x ", tm->data[i]); + } + + /*/ Break when [17, 4] received + if (tm->service == 17U && tm->subservice == 4U) { + stop = 1U; // Break the main application loop + } + //*/ + + printf("\n"); + return PO_SUCCESS; +} + +int main(int argc, const char* argv[]) +{ + // Received byte + uint8_t data; + + // Transmission buffer + uint8_t buf[128]; + uint16_t len; + + // Info + printf("PUSopen(R) Example: PUS 17 (client)\n"); + printf("Copyright (C) 2019, 12G Flight Systems Sweden AB\n"); + printf("APID: %u\n\n", CURRENT_APID); + + // Open socket + server(); + + // Initialize PUSopen(R) stack + po_initPus1(); + po_initPusUsr(); + po_initPs(); + po_initFess(); + + // Send TC[17,1] to server + po_sendTc(17U, 1U, // TC[17,1] + &data, // TC payload + 0U, // TC payload length + 1U); // Destination APID + + // Retrieve created TC[17,1] from stack and send it + (void) po_frame(buf, &len); + server_send((char*)buf, (int)len); + + sleep_ms(100); + //*/ + + /*/ + // Send TC[17,3] to server + po_sendTc(17U, 3U, // TC[17,1] + &data, // TC payload + 0U, // TC payload length + 1U); // Destination APID + + // Retrieve created TC[17,3] from stack and send it + (void) po_frame(buf, &len); + server_send((char*)buf, (int)len); + //*/ + + sleep_ms(100); + + /*/ Function TC[8,1] + po_sendTc(8U, 1U, // TC[8,1] + &data, // TC payload + 4U, // TC payload length + 1U); // Destination APID + + // Retrieve created TC[8,1] byte stream from PUSopen(R) stack and send it + (void) po_frame(buf, &len); + + server_send((char*)buf, (int)len); + //*/ + + // Main loop - wait for reception of TM[17,2] and TM[17,4] from server + while (stop == 0U) { + + // Push received data byte-by-byte into PUSopen(R) stack + while (client_recv(&data, 1) == 1) { + po_accept(data); + } + + // Trigger stack to process received TM[17,x] + + // Unwrap TM[17,x] from received CCSDS packet + po_triggerPs(); + + // Forward TM[17,x] to PUS User + po_triggerPus1(); + + sleep_ms(100); + } + + client_close(); + return 0; +} \ No newline at end of file diff --git a/Lib/examples/gs/mdb_gs.c b/Lib/examples/gs/mdb_gs.c new file mode 100644 index 00000000000..3ed29b06e72 --- /dev/null +++ b/Lib/examples/gs/mdb_gs.c @@ -0,0 +1,213 @@ +/** + * PUSopen(R) Mission Database + * + * THIS FILE HAS BEEN AUTOGENERATED. + * ANY MANUAL MODIFICATIONS MAY BE OVERWRITTEN. + */ + +/* Include files */ +#include "pusopen.h" + +/* Included PUSopen(R) modules */ + +#define PUS1_PROVIDER +/* #define PUS3_PROVIDER */ +/* #define PUS5_PROVIDER */ +/* #define PUS8_PROVIDER */ +/* #define PUS13_PROVIDER */ +/* #define PUS17_PROVIDER */ +#define PUS_USR + +/* PUSopen(R) configuration */ + +/* PUS 1 - Size of reception buffer (in bytes) */ +#define PUS1_RECV_BUF_SIZE 256 + +/* PUS 1 - Virtual Channel for TM[1,x] */ +#define PUS1_VCID 1 + +/* PUS Service User - Size of send buffer (in bytes) */ +#define PUSUSR_SEND_BUF_SIZE 1 + +/* PUS Service User - Virtual Channel for TC */ +#define PUSUSR_VCID 1 + +/* PUS Service User - TM header type */ +#define PUSUSR_TM_HDR_TYPE ECSS_E_ST_70_41C + +/* PUS Service User - TM header length */ +#define PUSUSR_TM_HDR_LEN 11 + +#define PS_LAYER + +/* PS - Max size of sent packet (in bytes) */ +#define PS_MAX_SEND_PACKET_SIZE 128 + +/* PS - Max size of received packet (in bytes) */ +#define PS_MAX_RECV_PACKET_SIZE 128 + +/* PS - Checksum type */ +#define PS_PKT_CHECKSUM_TYPE PKT_ISO16 + +/* PS - Checksum length (in bytes) */ +#define PS_PKT_CHECKSUM_LEN 2 + +#define FESS_LAYER + +/* FESS - Size of send buffer (in bytes) */ +#define FESS_SEND_BUF_SIZE 512 + +/* FESS - Size of reception buffer (in bytes) */ +#define FESS_RECV_BUF_SIZE 512 + +/* FESS - Size of FESS temporary buffers (in bytes) */ +#define FESS_TEMP_BUF_SIZE 512 + +/* FESS - Attached Synchronization Mark (ASM) */ +#define FESS_ASM FESS_DEF_ASM + +/* FESS - Length of ASM */ +#define FESS_ASM_LEN 3 + +/* FESS - Frame encoding algorithm */ +#define FESS_ENCODING SLIP + +/* FESS - Frame encryption algorithm */ +#define FESS_ENCRYPTION NOENCRYPTION + +/* FESS - AES128 encryption key */ +#define FESS_AES_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + +/* FESS - AES128 initial vector */ +#define FESS_AES_IV {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + +/* PUS Service providers and user */ + +#ifdef PUS1_PROVIDER +PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); +#endif + +#ifdef PUS_USR +PUSUSR_INIT(pusUsr, PUSUSR_SEND_BUF_SIZE, PUSUSR_VCID, PUSUSR_TM_HDR_TYPE, PUSUSR_TM_HDR_LEN); +#endif + +/* Packet Services */ + +#ifdef PS_LAYER +PS_INIT(ps, PS_MAX_SEND_PACKET_SIZE, PS_MAX_RECV_PACKET_SIZE, PS_PKT_CHECKSUM_TYPE, PS_PKT_CHECKSUM_LEN); +#endif + + +/* FESS Layer */ + +#ifdef FESS_LAYER +FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEND_BUF_SIZE, FESS_RECV_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_AES_KEY, FESS_AES_IV); +#endif + +/* User Code */ + + + +/* On-board Events */ + +po_evt_t evt[] = { +}; + +/* User Functions */ + +po_fnc_t fnc[] = { +}; + +/* HK Parameters */ + +po_obparam_t obparams[] = { +#ifdef FESS_LAYER +PO_MDB_PARAMS_FESS +#endif +#ifdef PS_LAYER +PO_MDB_PARAMS_PS +#endif +#ifdef VC_LAYER +PO_MDB_PARAMS_VC +#endif +#ifdef PUS1_PROVIDER +PO_MDB_PARAMS_PUS1 +#endif +#ifdef PUS3_PROVIDER +PO_MDB_PARAMS_PUS3 +#endif +#ifdef PUS5_PROVIDER +PO_MDB_PARAMS_PUS5 +#endif +#ifdef PUS8_PROVIDER +PO_MDB_PARAMS_PUS8 +#endif +#ifdef PUS13_PROVIDER +PO_MDB_PARAMS_PUS13 +#endif +#ifdef PUS17_PROVIDER +PO_MDB_PARAMS_PUS17 +#endif +#ifdef PUS_USR +PO_MDB_PARAMS_PUSUSR +#endif +}; + +/* HK Reports */ + +po_hkreport_t hkreps[] = { +}; + +/* PUSopen(R) Mission Database */ + +po_mdbapid_t po_mdb_apid = { + .apid = 3, + .apuid = 4, + + .pus1 = POADDR(pus1), + .pus3 = PONULL, + .pus5 = PONULL, + .pus8 = PONULL, + .pus13 = PONULL, + .pus17 = PONULL, + .pusUsr = POADDR(pusUsr), + .ps = POADDR(ps), + .vc = PONULL, + .fess = POADDR(fess), + + .numevt = 0U, + .numparams = 19U, + .numreports = 0U, + .numfct = 0U, + .events = evt, + .obparams = obparams, + .func = fnc, + .hkreports = hkreps +}; + +/** + * Default implementation of pususr_tm to satisfy + * dependencies if PUS Service User is not used. + */ +#ifndef PUS_USR +EMPTY_PUSUSR_TM +#endif + +/** + * Default implementation of po_time to satisfy + * dependencies if user does not implements po_time. + */ +#ifndef PUS_CUSTOM_TIME +EMPTY_PO_TIME +#endif + +/** + * Default implementation of po_tc to satisfy + * dependencies if user does not implements po_tc. + */ +#ifndef PUS_CUSTOM_SERVICES +EMPTY_PO_TC +#endif + +/* MDB format version */ +#define MDB_VERSION 1 diff --git a/Lib/examples/gs/mdb_gs.xml b/Lib/examples/gs/mdb_gs.xml new file mode 100644 index 00000000000..73c017984bb --- /dev/null +++ b/Lib/examples/gs/mdb_gs.xml @@ -0,0 +1,121 @@ + + + + + 1.1 + + + 3 + + + 4 + + + + + + true + + + 256 + + + + false + + + + false + + + + false + + + + false + + + + false + + + + + true + + + + + true + + + 128 + 128 + + + + + + + + + + false + + + + + true + + + 512 + 512 + + + 512 + + + FESS_DEF_ASM + 3 + + + + SLIP + NOENCRYPTION + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Lib/examples/gs/subnetwork.c b/Lib/examples/gs/subnetwork.c new file mode 100644 index 00000000000..218daeb3e31 --- /dev/null +++ b/Lib/examples/gs/subnetwork.c @@ -0,0 +1,65 @@ +/** + * @file subnetwork.c + * @brief Example Subnetwork layer implementation. + * + * This code shall only be used in examples of PUSopen(R) usage. + * It shall not be used for the mission or critical code. + * + * @copyright + * + * Copyright (c) 2019, 12G Flight Systems Sweden AB. + * + * This program is the property of 12G Flight Systems Sweden AB. + * The right to copy, distribute, modify or otherwise make use + * of this software may be licensed only pursuant to the terms + * of agreement obtained from 12G Flight Systems Sweden AB. + * + */ + +/* -- Includes -- */ + +#include "pusopen.h" + +/* -- Defines -- */ + +/* -- Typedefs -- */ + +/* -- Global data -- */ + +/* -- Local data -- */ + +/* -- Local functions declarations -- */ + +/* -- Local functions -- */ + +/* -- Global functions -- */ + +po_result_t subnet_request( + uint8_t * const data, + const uint16_t len, + const po_apid_t apid, + const uint16_t vcid) +{ + po_result_t res = PO_SUCCESS; /* Result of this function */ + + (void)apid; + (void)vcid; + + /* Forward requested data directly down to FESS */ + res = fessChannelAccess_request(PO_DEF_FESS, data, len); + + return res; +} + +po_result_t subnet_indication(uint8_t * const data, uint16_t *len) +{ + po_result_t res = PO_SUCCESS; /* Result of this function */ + uint8_t quality = 0U; + uint8_t sequence = 0U; + + /* Call FESS indication API to retrieve received data */ + res = fessChannelAccess_indication(PO_DEF_FESS, data, len, &quality, &sequence); + + return res; +} + From c45db35337c79f45c0362d168fcf2f726a080361 Mon Sep 17 00:00:00 2001 From: Lewis Jaggi Date: Thu, 14 Jan 2021 20:20:12 +0100 Subject: [PATCH 11/29] Auto stash before merge of "chess-pusopen_" and "origin/chess-pusopen_" --- Svc/GroundInterface/GroundInterface.cpp | 17 ++++++++++++----- Svc/GroundInterface/GroundInterface.hpp | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 67de792e9cc..87e3a2ed56b 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -16,6 +16,7 @@ #include "Fw/Types/BasicTypes.hpp" #include +#include #include "pusopen.h" @@ -34,7 +35,6 @@ U32 PR_NumPings = 0; #endif - // ------------------------------------- --------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -364,6 +364,7 @@ void GroundInterfaceComponentImpl::processRing() { void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { NATIVE_UINT_TYPE buffer_offset = 0; + while (buffer_offset < buffer.getSize()) { NATIVE_UINT_TYPE ser_size = (buffer.getSize() >= m_in_ring.get_remaining_size(true)) ? m_in_ring.get_remaining_size(true) : static_cast(buffer.getSize()); @@ -374,6 +375,7 @@ void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { } void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { + printf("Data received : %u\n", buffer.getSize()); Fw::Buffer extBuff = m_ext_buffer; // Transmission buffer @@ -387,7 +389,7 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { // Push received data byte-by-byte into PUSopen(R) stack for(int i = 0; i < buffer.getSize(); i++) { - //printf("[PUS] %d data : %hhu \n",i,buffer.getData()[i]); + printf("%d data : %hhu \n",i,buffer.getData()[i]); po_accept(buffer.getData()[i]); // todo propre reinterpret_cast } @@ -421,9 +423,14 @@ extern "C" { */ po_result_t UserPus8Fn (uint8_t fid, uint8_t *data, uint16_t len) { - printf("[PUS] PUS8 User Function triggered.\n"); - printf("[PUS] Function ID = %u.\n", fid); - printf("[PUS] Received data (len = %u): %u %u %u %u\n", len, data[0], data[1], data[2], data[3]); + printf("PUS8 User Function triggered.\n"); + printf("Function ID = %u.\n", fid); + Fw::Buffer extBuff; + U8* dataExt = &data[1]; + extBuff.setSize(len-1); + extBuff.setData(dataExt); + groundIf.processBuffer(extBuff); + return PO_SUCCESS; } diff --git a/Svc/GroundInterface/GroundInterface.hpp b/Svc/GroundInterface/GroundInterface.hpp index 70082424d13..dd6a9c6f97b 100644 --- a/Svc/GroundInterface/GroundInterface.hpp +++ b/Svc/GroundInterface/GroundInterface.hpp @@ -25,6 +25,7 @@ namespace Svc { static const U32 MAX_DATA_SIZE; static const TOKEN_TYPE START_WORD; static const U32 END_WORD; + void processBuffer(Fw::Buffer& data /*!< Data to process */); // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -113,7 +114,6 @@ namespace Svc { void processRing(); //! Process a data buffer containing a read from the serial port - void processBuffer(Fw::Buffer& data /*!< Data to process */); void processPUS(Fw::Buffer& data /*!< Data to process */); // Basic data movement variables From 5ff240a7ec3f0a4d781d399af59ac52a4482b3a4 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Fri, 15 Jan 2021 10:52:11 +0100 Subject: [PATCH 12/29] Remove PUSOpen Lib folder --- .gitignore | 3 + Lib/.gitignore | 9 - Lib/Readme | 3 - Lib/examples/gs/gs | Bin 39712 -> 0 bytes Lib/examples/gs/main_gs.c | 143 ---------------- Lib/examples/gs/mdb_gs.c | 213 ------------------------ Lib/examples/gs/mdb_gs.xml | 121 -------------- Lib/examples/gs/subnetwork.c | 65 -------- Svc/GroundInterface/GroundInterface.cpp | 2 - 9 files changed, 3 insertions(+), 556 deletions(-) delete mode 100644 Lib/.gitignore delete mode 100644 Lib/Readme delete mode 100755 Lib/examples/gs/gs delete mode 100644 Lib/examples/gs/main_gs.c delete mode 100644 Lib/examples/gs/mdb_gs.c delete mode 100644 Lib/examples/gs/mdb_gs.xml delete mode 100644 Lib/examples/gs/subnetwork.c diff --git a/.gitignore b/.gitignore index 2a5fb5771e4..0932ca07413 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,6 @@ GTestBase.* /Fw/Python/src/fprime.egg-info /Gds/src/fprime_gds.egg-info **/DefaultDict/serializable/* + +# Clone CHESS-mission/pusopen as "Lib" in fprime root - Due to license restriction with PUSOpen +Lib \ No newline at end of file diff --git a/Lib/.gitignore b/Lib/.gitignore deleted file mode 100644 index 833a732f5b6..00000000000 --- a/Lib/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -## PUSOpen lib - -lib -bin -examples/* -!examples/gs/ - -Includes - diff --git a/Lib/Readme b/Lib/Readme deleted file mode 100644 index 2eff819b0e5..00000000000 --- a/Lib/Readme +++ /dev/null @@ -1,3 +0,0 @@ -#PUSOpen - -you need to put PUSOpen lib here diff --git a/Lib/examples/gs/gs b/Lib/examples/gs/gs deleted file mode 100755 index 50f0cb901c338e26f9e66f4203d9cd2a185f839c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 39712 zcmeHwdwdjCmVb4p6Pi~#Dndq4TWvH^h-pMf6g5q{p&}hb6T}_SCM4aEAurR_JVwws zooH%eJM4_ku(Pu(zZqxN*>xRe#RSoT4nZEiCgO_`)aas9F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P1Bj{o9r)Bg6tIPGS8V)-93{v zC#k!)2Adk8Kw?cyEin*)&6GIb9(`(3@a$lTv^+Fj(N3Q#MVjS}tPC8zKeE zBDHlj(=faR6vI1jRwxBEYa1YsQ>~e&z*PxjK}(4Qkk%ZmtD+1d)KsS_1#Hd~AXu=x z5m60`j8Z`UAD9~1Vo(rVAv``ZugMtC%3VL6Lxxd8RefzW>O^Zv0p@^G0JpOquB6$2 z{eKLT8&6v_xZ~`S_pv3F=k+3)@yak!+IM5im&{)&1WD>dn)#CF3=(rAV9u|J{E~|8 zoMgwnfz*rKd%OaqQPzK>2uLdHk7FoyVSAKvEkKO+qsi=E3zf)FY$j$%P-G`Bt2W~V`Y9> zu8jXCEx&y3K~ij2Q?B&(|6b&m<0sGaBz;K^oRH#7k)|krOv_(K69Si{PfEcYKBNEn zefS~$k+K!2oTqCPLh9Ren~$;iaCGsT)K&8 zq5Bl(%V~}vJc$1!OO`L6FUgH?MtUcb`Er^g2!D -#include "clientserver.h" - -#include "pusopen.h" - -// Stop flag for main application loop -uint8_t stop = 0U; - - -// PUSopen(R) callback for telemetry (TM) reception -po_result_t pususr_tm(po_tmdesc_t * tm) -{ - uint16_t i = 0U; - - printf(" TM %2u %2u Dest APID:%2u Flags:%u Count:%5u Payload (%2u bytes) ", - tm->service, tm->subservice, tm->destid, tm->pktSeqFlags, tm->pktSeqCount, tm->dataLen); - - for (i = 0U; i < tm->dataLen; i++) { - printf("%02x ", tm->data[i]); - } - - /*/ Break when [17, 4] received - if (tm->service == 17U && tm->subservice == 4U) { - stop = 1U; // Break the main application loop - } - //*/ - - printf("\n"); - return PO_SUCCESS; -} - -int main(int argc, const char* argv[]) -{ - // Received byte - uint8_t data; - - // Transmission buffer - uint8_t buf[128]; - uint16_t len; - - // Info - printf("PUSopen(R) Example: PUS 17 (client)\n"); - printf("Copyright (C) 2019, 12G Flight Systems Sweden AB\n"); - printf("APID: %u\n\n", CURRENT_APID); - - // Open socket - server(); - - // Initialize PUSopen(R) stack - po_initPus1(); - po_initPusUsr(); - po_initPs(); - po_initFess(); - - // Send TC[17,1] to server - po_sendTc(17U, 1U, // TC[17,1] - &data, // TC payload - 0U, // TC payload length - 1U); // Destination APID - - // Retrieve created TC[17,1] from stack and send it - (void) po_frame(buf, &len); - server_send((char*)buf, (int)len); - - sleep_ms(100); - //*/ - - /*/ - // Send TC[17,3] to server - po_sendTc(17U, 3U, // TC[17,1] - &data, // TC payload - 0U, // TC payload length - 1U); // Destination APID - - // Retrieve created TC[17,3] from stack and send it - (void) po_frame(buf, &len); - server_send((char*)buf, (int)len); - //*/ - - sleep_ms(100); - - /*/ Function TC[8,1] - po_sendTc(8U, 1U, // TC[8,1] - &data, // TC payload - 4U, // TC payload length - 1U); // Destination APID - - // Retrieve created TC[8,1] byte stream from PUSopen(R) stack and send it - (void) po_frame(buf, &len); - - server_send((char*)buf, (int)len); - //*/ - - // Main loop - wait for reception of TM[17,2] and TM[17,4] from server - while (stop == 0U) { - - // Push received data byte-by-byte into PUSopen(R) stack - while (client_recv(&data, 1) == 1) { - po_accept(data); - } - - // Trigger stack to process received TM[17,x] - - // Unwrap TM[17,x] from received CCSDS packet - po_triggerPs(); - - // Forward TM[17,x] to PUS User - po_triggerPus1(); - - sleep_ms(100); - } - - client_close(); - return 0; -} \ No newline at end of file diff --git a/Lib/examples/gs/mdb_gs.c b/Lib/examples/gs/mdb_gs.c deleted file mode 100644 index 3ed29b06e72..00000000000 --- a/Lib/examples/gs/mdb_gs.c +++ /dev/null @@ -1,213 +0,0 @@ -/** - * PUSopen(R) Mission Database - * - * THIS FILE HAS BEEN AUTOGENERATED. - * ANY MANUAL MODIFICATIONS MAY BE OVERWRITTEN. - */ - -/* Include files */ -#include "pusopen.h" - -/* Included PUSopen(R) modules */ - -#define PUS1_PROVIDER -/* #define PUS3_PROVIDER */ -/* #define PUS5_PROVIDER */ -/* #define PUS8_PROVIDER */ -/* #define PUS13_PROVIDER */ -/* #define PUS17_PROVIDER */ -#define PUS_USR - -/* PUSopen(R) configuration */ - -/* PUS 1 - Size of reception buffer (in bytes) */ -#define PUS1_RECV_BUF_SIZE 256 - -/* PUS 1 - Virtual Channel for TM[1,x] */ -#define PUS1_VCID 1 - -/* PUS Service User - Size of send buffer (in bytes) */ -#define PUSUSR_SEND_BUF_SIZE 1 - -/* PUS Service User - Virtual Channel for TC */ -#define PUSUSR_VCID 1 - -/* PUS Service User - TM header type */ -#define PUSUSR_TM_HDR_TYPE ECSS_E_ST_70_41C - -/* PUS Service User - TM header length */ -#define PUSUSR_TM_HDR_LEN 11 - -#define PS_LAYER - -/* PS - Max size of sent packet (in bytes) */ -#define PS_MAX_SEND_PACKET_SIZE 128 - -/* PS - Max size of received packet (in bytes) */ -#define PS_MAX_RECV_PACKET_SIZE 128 - -/* PS - Checksum type */ -#define PS_PKT_CHECKSUM_TYPE PKT_ISO16 - -/* PS - Checksum length (in bytes) */ -#define PS_PKT_CHECKSUM_LEN 2 - -#define FESS_LAYER - -/* FESS - Size of send buffer (in bytes) */ -#define FESS_SEND_BUF_SIZE 512 - -/* FESS - Size of reception buffer (in bytes) */ -#define FESS_RECV_BUF_SIZE 512 - -/* FESS - Size of FESS temporary buffers (in bytes) */ -#define FESS_TEMP_BUF_SIZE 512 - -/* FESS - Attached Synchronization Mark (ASM) */ -#define FESS_ASM FESS_DEF_ASM - -/* FESS - Length of ASM */ -#define FESS_ASM_LEN 3 - -/* FESS - Frame encoding algorithm */ -#define FESS_ENCODING SLIP - -/* FESS - Frame encryption algorithm */ -#define FESS_ENCRYPTION NOENCRYPTION - -/* FESS - AES128 encryption key */ -#define FESS_AES_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} - -/* FESS - AES128 initial vector */ -#define FESS_AES_IV {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} - -/* PUS Service providers and user */ - -#ifdef PUS1_PROVIDER -PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); -#endif - -#ifdef PUS_USR -PUSUSR_INIT(pusUsr, PUSUSR_SEND_BUF_SIZE, PUSUSR_VCID, PUSUSR_TM_HDR_TYPE, PUSUSR_TM_HDR_LEN); -#endif - -/* Packet Services */ - -#ifdef PS_LAYER -PS_INIT(ps, PS_MAX_SEND_PACKET_SIZE, PS_MAX_RECV_PACKET_SIZE, PS_PKT_CHECKSUM_TYPE, PS_PKT_CHECKSUM_LEN); -#endif - - -/* FESS Layer */ - -#ifdef FESS_LAYER -FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEND_BUF_SIZE, FESS_RECV_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_AES_KEY, FESS_AES_IV); -#endif - -/* User Code */ - - - -/* On-board Events */ - -po_evt_t evt[] = { -}; - -/* User Functions */ - -po_fnc_t fnc[] = { -}; - -/* HK Parameters */ - -po_obparam_t obparams[] = { -#ifdef FESS_LAYER -PO_MDB_PARAMS_FESS -#endif -#ifdef PS_LAYER -PO_MDB_PARAMS_PS -#endif -#ifdef VC_LAYER -PO_MDB_PARAMS_VC -#endif -#ifdef PUS1_PROVIDER -PO_MDB_PARAMS_PUS1 -#endif -#ifdef PUS3_PROVIDER -PO_MDB_PARAMS_PUS3 -#endif -#ifdef PUS5_PROVIDER -PO_MDB_PARAMS_PUS5 -#endif -#ifdef PUS8_PROVIDER -PO_MDB_PARAMS_PUS8 -#endif -#ifdef PUS13_PROVIDER -PO_MDB_PARAMS_PUS13 -#endif -#ifdef PUS17_PROVIDER -PO_MDB_PARAMS_PUS17 -#endif -#ifdef PUS_USR -PO_MDB_PARAMS_PUSUSR -#endif -}; - -/* HK Reports */ - -po_hkreport_t hkreps[] = { -}; - -/* PUSopen(R) Mission Database */ - -po_mdbapid_t po_mdb_apid = { - .apid = 3, - .apuid = 4, - - .pus1 = POADDR(pus1), - .pus3 = PONULL, - .pus5 = PONULL, - .pus8 = PONULL, - .pus13 = PONULL, - .pus17 = PONULL, - .pusUsr = POADDR(pusUsr), - .ps = POADDR(ps), - .vc = PONULL, - .fess = POADDR(fess), - - .numevt = 0U, - .numparams = 19U, - .numreports = 0U, - .numfct = 0U, - .events = evt, - .obparams = obparams, - .func = fnc, - .hkreports = hkreps -}; - -/** - * Default implementation of pususr_tm to satisfy - * dependencies if PUS Service User is not used. - */ -#ifndef PUS_USR -EMPTY_PUSUSR_TM -#endif - -/** - * Default implementation of po_time to satisfy - * dependencies if user does not implements po_time. - */ -#ifndef PUS_CUSTOM_TIME -EMPTY_PO_TIME -#endif - -/** - * Default implementation of po_tc to satisfy - * dependencies if user does not implements po_tc. - */ -#ifndef PUS_CUSTOM_SERVICES -EMPTY_PO_TC -#endif - -/* MDB format version */ -#define MDB_VERSION 1 diff --git a/Lib/examples/gs/mdb_gs.xml b/Lib/examples/gs/mdb_gs.xml deleted file mode 100644 index 73c017984bb..00000000000 --- a/Lib/examples/gs/mdb_gs.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - 1.1 - - - 3 - - - 4 - - - - - - true - - - 256 - - - - false - - - - false - - - - false - - - - false - - - - false - - - - - true - - - - - true - - - 128 - 128 - - - - - - - - - - false - - - - - true - - - 512 - 512 - - - 512 - - - FESS_DEF_ASM - 3 - - - - SLIP - NOENCRYPTION - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Lib/examples/gs/subnetwork.c b/Lib/examples/gs/subnetwork.c deleted file mode 100644 index 218daeb3e31..00000000000 --- a/Lib/examples/gs/subnetwork.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file subnetwork.c - * @brief Example Subnetwork layer implementation. - * - * This code shall only be used in examples of PUSopen(R) usage. - * It shall not be used for the mission or critical code. - * - * @copyright - * - * Copyright (c) 2019, 12G Flight Systems Sweden AB. - * - * This program is the property of 12G Flight Systems Sweden AB. - * The right to copy, distribute, modify or otherwise make use - * of this software may be licensed only pursuant to the terms - * of agreement obtained from 12G Flight Systems Sweden AB. - * - */ - -/* -- Includes -- */ - -#include "pusopen.h" - -/* -- Defines -- */ - -/* -- Typedefs -- */ - -/* -- Global data -- */ - -/* -- Local data -- */ - -/* -- Local functions declarations -- */ - -/* -- Local functions -- */ - -/* -- Global functions -- */ - -po_result_t subnet_request( - uint8_t * const data, - const uint16_t len, - const po_apid_t apid, - const uint16_t vcid) -{ - po_result_t res = PO_SUCCESS; /* Result of this function */ - - (void)apid; - (void)vcid; - - /* Forward requested data directly down to FESS */ - res = fessChannelAccess_request(PO_DEF_FESS, data, len); - - return res; -} - -po_result_t subnet_indication(uint8_t * const data, uint16_t *len) -{ - po_result_t res = PO_SUCCESS; /* Result of this function */ - uint8_t quality = 0U; - uint8_t sequence = 0U; - - /* Call FESS indication API to retrieve received data */ - res = fessChannelAccess_indication(PO_DEF_FESS, data, len, &quality, &sequence); - - return res; -} - diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 87e3a2ed56b..1c8015700f5 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -375,7 +375,6 @@ void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { } void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { - printf("Data received : %u\n", buffer.getSize()); Fw::Buffer extBuff = m_ext_buffer; // Transmission buffer @@ -384,7 +383,6 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { // printf("[PUS] Data received : %u\n", buffer.getSize()); - this->m_poStackMutex.lock(); // Push received data byte-by-byte into PUSopen(R) stack From 161fd033fedb101a576abe7234c7734d34174d4a Mon Sep 17 00:00:00 2001 From: Lewis Jaggi Date: Fri, 15 Jan 2021 15:59:54 +0100 Subject: [PATCH 13/29] update size for PUS TCP buffer in config, extern groundif --- Svc/GroundInterface/GroundInterface.cpp | 32 +++++++++++++++---------- config/SocketIpDriverCfg.hpp | 7 +++--- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 1c8015700f5..91db0a16bd7 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -14,12 +14,13 @@ #include #include #include "Fw/Types/BasicTypes.hpp" - #include -#include + #include "pusopen.h" +extern Svc::GroundInterfaceComponentImpl groundIf; + namespace Svc { const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; @@ -375,19 +376,20 @@ void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { } void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { - Fw::Buffer extBuff = m_ext_buffer; - + Fw::Buffer extBuff = m_ext_buffer; + //printf("[PUS] service pus received \n"); + //printf("[PUS] size data %u\n",buffer.getSize()); // Transmission buffer - U8 buf[128]; + U8 buf[512]; U16 len; // printf("[PUS] Data received : %u\n", buffer.getSize()); + this->m_poStackMutex.lock(); // Push received data byte-by-byte into PUSopen(R) stack for(int i = 0; i < buffer.getSize(); i++) { - printf("%d data : %hhu \n",i,buffer.getData()[i]); po_accept(buffer.getData()[i]); // todo propre reinterpret_cast } @@ -401,8 +403,12 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { po_frame(buf, &len); this->m_poStackMutex.unLock(); - + //printf("[PUS] size buf %u\n",len); + for(int i = 0;i 0) { + printf("[PUS] return data \n"); extBuff.setSize(len); extBuff.setData(buf); write_out(0,extBuff); @@ -421,18 +427,18 @@ extern "C" { */ po_result_t UserPus8Fn (uint8_t fid, uint8_t *data, uint16_t len) { - printf("PUS8 User Function triggered.\n"); - printf("Function ID = %u.\n", fid); - Fw::Buffer extBuff; - U8* dataExt = &data[1]; - extBuff.setSize(len-1); - extBuff.setData(dataExt); + printf("[PUS8] User Function triggered with function ID = %u.\n",fid); + Fw::Buffer extBuff; + U8* dataExt = &data[1]; + extBuff.setSize(len-1); + extBuff.setData(dataExt); groundIf.processBuffer(extBuff); return PO_SUCCESS; } + /* -- Global functions -- */ po_result_t subnet_request( uint8_t * const data, diff --git a/config/SocketIpDriverCfg.hpp b/config/SocketIpDriverCfg.hpp index 50ba7d76862..c18fa28af6f 100644 --- a/config/SocketIpDriverCfg.hpp +++ b/config/SocketIpDriverCfg.hpp @@ -20,14 +20,15 @@ enum SocketIpCfg { SOCKET_TIMEOUT_MICROSECONDS = 0, // Milliseconds component of timeout #if defined _PUS SOCKET_SEND_UDP = 0, + MAX_RECV_BUFFER_SIZE = 1, // Maximum and allocation size of the send buffer. TODO: use buffer manager #elif defined _GDS - SOCKET_SEND_UDP = 1, + SOCKET_SEND_UDP = 1, + MAX_RECV_BUFFER_SIZE = 2048, // Maximum and allocation size of the send buffer. TODO: use buffer manager #endif // 0 - Send down using TCP, 1 - Send down using UDP SOCKET_SEND_FLAGS = 0, // send, sendto FLAGS argument SOCKET_RECV_FLAGS = 0, // recv FLAGS argument RECONNECT_AUTOMATICALLY = 1, // Attempt to reconnect when a socket closes - MAX_SEND_ITERATIONS = 0xFFFF, // Maximum send iterations - MAX_RECV_BUFFER_SIZE = 2048, // Maximum and allocation size of the send buffer. TODO: use buffer manager + MAX_SEND_ITERATIONS = 0xFFFF, // Maximum send iterations PRE_CONNECTION_RETRY_INTERVAL_MS = 1000, // Interval between connection retries before main recv thread starts MAX_HOSTNAME_SIZE = 256 // Maximum stored hostname }; From 918c7db635be1090418d773a8513a17bdf3a4639 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Tue, 19 Jan 2021 09:15:03 +0100 Subject: [PATCH 14/29] Fix PUS3-5 seg fault --- .../PingReceiverComponentImpl.cpp | 2 +- Svc/GroundInterface/GroundInterface.cpp | 127 ++++++++++-------- Svc/GroundInterface/pusopen_onboard_mdb.c | 20 +-- Svc/GroundInterface/pusopen_onboard_mdb.xml | 32 ++--- Svc/TlmChan/TlmChanImpl.hpp | 1 - 5 files changed, 98 insertions(+), 84 deletions(-) diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.cpp b/Ref/PingReceiver/PingReceiverComponentImpl.cpp index 1867176a1b1..61c4d643232 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.cpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.cpp @@ -54,7 +54,7 @@ namespace Ref { ) { this->log_DIAGNOSTIC_PR_PingReceived(key); - //this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); + this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); if (not this->m_inhibitPings) { PingOut_out(0,key); } diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 91db0a16bd7..908b2a5f1ed 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include "Fw/Types/BasicTypes.hpp" @@ -108,6 +109,62 @@ void GroundInterfaceComponentImpl::readCallback_handler( #endif } +void GroundInterfaceComponentImpl::hkReport_handler( + const NATIVE_INT_TYPE portNum, + FwChanIdType id, + Fw::Time &timeTag, + Fw::TlmBuffer &val +) { + // F' variables + Fw::Buffer buffer; + U32 tlmVal; + + Fw::TlmPacket m_tlmPacket; //!< Packet buffer for assembling tlm packets + Fw::ComBuffer m_comBuffer; //!< Com buffer for sending event buffers + + // PUSOpen variables + U8 po_buf[4096]; // @todo use definition + U16 po_len; + po_result_t po_res = PO_ERR; + + // printf("[PUS] Housekeeping received : %u (0x%02X)\n", id, id); + + this->m_poStackMutex.lock(); + + /*/ + m_tlmPacket.setId(id); + m_tlmPacket.setTimeTag(timeTag); + m_tlmPacket.setTlmBuffer(val); + m_comBuffer.resetSer(); + Fw::SerializeStatus stat = m_tlmPacket.serialize(m_comBuffer); + FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); + //*/ + + // Sample - In the future serialize id and TlmBuffer + switch(id) { + case 0x29: // (41) PR_NumPings + val.deserialize(tlmVal); + PR_NumPings = tlmVal; + printf("[PUS] Housekeeping PR_NumPings received : %u \n", tlmVal); + // Trigger PUS 3 Service provider to generate TM[3,25] + po_triggerPus3(); + break; + } + + // Retrieve created TM[3,25] byte stream from PUSopen stack and send it + po_res = po_frame(po_buf, &po_len); + + this->m_poStackMutex.unLock(); + + // If a report has been generated, send it + if(po_len > 0) { + buffer.setData(po_buf); + buffer.setSize(po_len); + printf("[PUS] Send report\n"); + write_out(0, buffer); + } +} + void GroundInterfaceComponentImpl::eventReport_handler( const NATIVE_INT_TYPE portNum, FwEventIdType id, @@ -118,11 +175,11 @@ void GroundInterfaceComponentImpl::eventReport_handler( // F' variables Fw::Buffer buffer; //!< buffer to send frame to SocketIpDriver - //Fw::LogPacket m_logPacket; //!< Packet buffer for assembling log packets - //Fw::ComBuffer m_comBuffer; //!< Com buffer for sending event buffers + Fw::LogPacket m_logPacket; //!< Packet buffer for assembling log packets + Fw::ComBuffer m_comBuffer; //!< Com buffer for sending event buffers // PUSOpen variables - U8 po_buf[512]; + U8 po_buf[4096]; // @todo use definition U8 po_evtData = 0; U16 po_len; po_result_t po_res = PO_ERR; @@ -172,20 +229,24 @@ void GroundInterfaceComponentImpl::eventReport_handler( m_logPacket.setId(id); m_logPacket.setTimeTag(timeTag); m_logPacket.setLogBuffer(args); + m_comBuffer.resetSer(); Fw::SerializeStatus stat = m_logPacket.serialize(m_comBuffer); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); //*/ - // Sample - In the future serialize id and LogBuffer + + // simple data tests po_evtData = id; this->m_poStackMutex.lock(); // Send TM[5,x] with F' event ID = x - po_res = po_pus5tm( po_pus5_eventId, // event ID PUS[5, x] - &po_evtData, // event data - GS_APID); // destination APID (GS) + po_res = po_pus5tm( + po_pus5_eventId, // event ID PUS[5, x] + &po_evtData, // m_comBuffer.getBuffAddr(), // event data + GS_APID); // destination APID (GS) if(po_res != PO_SUCCESS) { + // PO_ERR_LOWSPACE 2 No space to store input data if too small printf("[PUS] po error: %u\n", po_res); FW_ASSERT(0); } @@ -203,51 +264,6 @@ void GroundInterfaceComponentImpl::eventReport_handler( buffer.setData(po_buf); buffer.setSize(po_len); write_out(0, buffer); - -} - -void GroundInterfaceComponentImpl::hkReport_handler( - const NATIVE_INT_TYPE portNum, - FwChanIdType id, - Fw::Time &timeTag, - Fw::TlmBuffer &val -) { - // F' variables - Fw::Buffer buffer; - U32 tlmVal; - - // PUSOpen variables - U8 po_buf[512]; - U16 po_len; - po_result_t po_res = PO_ERR; - - // printf("[PUS] Housekeeping received : %u (0x%02X)\n", id, id); - - this->m_poStackMutex.lock(); - - // Sample - In the future serialize id and TlmBuffer - switch(id) { - case 0x29: // (41) PR_NumPings - val.deserialize(tlmVal); - PR_NumPings = tlmVal; - printf("[PUS] Housekeeping PR_NumPings received : %u \n", tlmVal); - // Trigger PUS 3 Service provider to generate TM[3,25] - po_triggerPus3(); - break; - } - - // Retrieve created TM[3,25] byte stream from PUSopen stack and send it - po_res = po_frame(po_buf, &po_len); - - this->m_poStackMutex.unLock(); - - // If a report has been generated, send it - if(po_len > 0) { - buffer.setData(po_buf); - buffer.setSize(po_len); - printf("[PUS] Send report\n"); - write_out(0, buffer); - } } void GroundInterfaceComponentImpl::schedIn_handler( @@ -380,12 +396,9 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { //printf("[PUS] service pus received \n"); //printf("[PUS] size data %u\n",buffer.getSize()); // Transmission buffer - U8 buf[512]; + U8 buf[4096]; // @todo use definition U16 len; - // printf("[PUS] Data received : %u\n", buffer.getSize()); - - this->m_poStackMutex.lock(); // Push received data byte-by-byte into PUSopen(R) stack @@ -471,4 +484,4 @@ po_result_t subnet_indication(uint8_t * const data, uint16_t *len) { } #endif -} // end namespace Svc +} // end namespace Svc \ No newline at end of file diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.c b/Svc/GroundInterface/pusopen_onboard_mdb.c index f411ced8142..4d255516cd5 100644 --- a/Svc/GroundInterface/pusopen_onboard_mdb.c +++ b/Svc/GroundInterface/pusopen_onboard_mdb.c @@ -21,13 +21,13 @@ /* PUSopen(R) configuration */ /* PUS 1 - Size of reception buffer (in bytes) */ -#define PUS1_RECV_BUF_SIZE 512 +#define PUS1_RECV_BUF_SIZE 2048 /* PUS 1 - Virtual Channel for TM[1,x] */ #define PUS1_VCID 1 /* PUS 3 - Size of buffer in which TM[3,25] report is composed (in bytes) */ -#define PUS3_REPORT_BUF_SIZE 1 +#define PUS3_REPORT_BUF_SIZE 512 /* PUS 17 - Virtual Channel for TM[17,x] */ #define PUS17_VCID 0 @@ -35,10 +35,10 @@ #define PS_LAYER /* PS - Max size of sent packet (in bytes) */ -#define PS_MAX_SEND_PACKET_SIZE 512 +#define PS_MAX_SEND_PACKET_SIZE 2048 /* PS - Max size of received packet (in bytes) */ -#define PS_MAX_RECV_PACKET_SIZE 512 +#define PS_MAX_RECV_PACKET_SIZE 2048 /* PS - Checksum type */ #define PS_PKT_CHECKSUM_TYPE PKT_ISO16 @@ -49,13 +49,13 @@ #define FESS_LAYER /* FESS - Size of send buffer (in bytes) */ -#define FESS_SEND_BUF_SIZE 2048 +#define FESS_SEND_BUF_SIZE 4096 /* FESS - Size of reception buffer (in bytes) */ -#define FESS_RECV_BUF_SIZE 2048 +#define FESS_RECV_BUF_SIZE 4096 /* FESS - Size of FESS temporary buffers (in bytes) */ -#define FESS_TEMP_BUF_SIZE 2048 +#define FESS_TEMP_BUF_SIZE 4096 /* FESS - Attached Synchronization Mark (ASM) */ #define FESS_ASM FESS_DEF_ASM @@ -112,9 +112,9 @@ FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEN /* User Code */ - - extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); - extern uint32_t PR_NumPings; + +extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); +extern uint32_t PR_NumPings; /* On-board Events */ diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.xml b/Svc/GroundInterface/pusopen_onboard_mdb.xml index 2a8e27f3cbc..2a0fadd7050 100644 --- a/Svc/GroundInterface/pusopen_onboard_mdb.xml +++ b/Svc/GroundInterface/pusopen_onboard_mdb.xml @@ -4,7 +4,7 @@ Compile this xml into .c file with poconfig tool : ../../Lib/bin/poconfig.exe pusopen_onboard_mdb.xml pusopen_onboard_mdb.c --> - + 1.1 @@ -24,11 +24,14 @@ Compile this xml into .c file with poconfig tool : - 512 + 2048 true + + + 512 @@ -56,12 +59,11 @@ Compile this xml into .c file with poconfig tool : true - 512 - 512 + + 2048 + 2048 - - @@ -77,12 +79,12 @@ Compile this xml into .c file with poconfig tool : - 2048 - 2048 + 4096 + 4096 - 2048 + 4096 2 PUS5_EVT_LOW Low severity anomaly - 1 + 1 3 PUS5_EVT_MEDIUM Medium severity anomaly - 1 + 1 4 PUS5_EVT_HIGH High severity anomaly - 1 + 1 - extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); - extern uint32_t PR_NumPings; +extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); +extern uint32_t PR_NumPings; diff --git a/Svc/TlmChan/TlmChanImpl.hpp b/Svc/TlmChan/TlmChanImpl.hpp index 45da4ac0364..d94818c8b6d 100644 --- a/Svc/TlmChan/TlmChanImpl.hpp +++ b/Svc/TlmChan/TlmChanImpl.hpp @@ -68,7 +68,6 @@ namespace Svc { // work variables Fw::ComBuffer m_comBuffer; Fw::TlmPacket m_tlmPacket; - }; } From 619d6bf9c586d585a1b0b0ef96890abc9c8c8a56 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Tue, 19 Jan 2021 12:01:21 +0100 Subject: [PATCH 15/29] Update PUS5 data buffer size --- Svc/GroundInterface/pusopen_onboard_mdb.c | 56 +++++++++++++++------ Svc/GroundInterface/pusopen_onboard_mdb.xml | 32 +++++++++--- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.c b/Svc/GroundInterface/pusopen_onboard_mdb.c index 4d255516cd5..ee6966bc6c9 100644 --- a/Svc/GroundInterface/pusopen_onboard_mdb.c +++ b/Svc/GroundInterface/pusopen_onboard_mdb.c @@ -27,7 +27,7 @@ #define PUS1_VCID 1 /* PUS 3 - Size of buffer in which TM[3,25] report is composed (in bytes) */ -#define PUS3_REPORT_BUF_SIZE 512 +#define PUS3_REPORT_BUF_SIZE 2048 /* PUS 17 - Virtual Channel for TM[17,x] */ #define PUS17_VCID 0 @@ -49,13 +49,13 @@ #define FESS_LAYER /* FESS - Size of send buffer (in bytes) */ -#define FESS_SEND_BUF_SIZE 4096 +#define FESS_SEND_BUF_SIZE 2048 /* FESS - Size of reception buffer (in bytes) */ -#define FESS_RECV_BUF_SIZE 4096 +#define FESS_RECV_BUF_SIZE 2048 /* FESS - Size of FESS temporary buffers (in bytes) */ -#define FESS_TEMP_BUF_SIZE 4096 +#define FESS_TEMP_BUF_SIZE 2048 /* FESS - Attached Synchronization Mark (ASM) */ #define FESS_ASM FESS_DEF_ASM @@ -112,9 +112,9 @@ FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEN /* User Code */ - -extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); -extern uint32_t PR_NumPings; + +extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); +extern uint32_t PR_NumPings; /* On-board Events */ @@ -124,28 +124,28 @@ po_evt_t evt[] = { .id = 1U, .level = PUS5_EVT_INFO, .desc = "Information event", - .dataLen = 1U, + .dataLen = 1102U, .vcid = 1U }, { .id = 2U, .level = PUS5_EVT_LOW, .desc = "Low severity anomaly", - .dataLen = 1U, + .dataLen = 1102U, .vcid = 1U }, { .id = 3U, .level = PUS5_EVT_MEDIUM, .desc = "Medium severity anomaly", - .dataLen = 1U, + .dataLen = 1102U, .vcid = 1U }, { .id = 4U, .level = PUS5_EVT_HIGH, .desc = "High severity anomaly", - .dataLen = 1U, + .dataLen = 1102U, .vcid = 1U } }; @@ -218,6 +218,18 @@ po_hkreport_t hkreps[] = { .vcid = 0U, .numHk = 8U, .obparams = { 100 } + }, + { + .id = 2U, + .name = "Report #2", + .desc = "Report #2 description", + .enabled = POTRUE, + .interval = 1U, + .sinceLast = 0U, + .destApid = 3U, + .vcid = 0U, + .numHk = 8U, + .obparams = { 100 } } }; @@ -240,7 +252,7 @@ po_mdbapid_t po_mdb_apid = { .numevt = 4U, .numparams = 42U, - .numreports = 1U, + .numreports = 2U, .numfct = 1U, .events = evt, .obparams = obparams, @@ -258,7 +270,7 @@ EMPTY_PUSUSR_TM /** * Default implementation of po_time to satisfy - * dependencies if user does not implements po_time. + * dependencies if user does not implement po_time. */ #ifndef PUS_CUSTOM_TIME EMPTY_PO_TIME @@ -266,11 +278,27 @@ EMPTY_PO_TIME /** * Default implementation of po_tc to satisfy - * dependencies if user does not implements po_tc. + * dependencies if user does not implement po_tc. */ #ifndef PUS_CUSTOM_SERVICES EMPTY_PO_TC #endif +/** + * Default implementation of pus13_tc to satisfy + * dependencies if user does not implement pus13_tc. + */ +#ifndef PUS13_PROVIDER +EMPTY_PUS13_TC +#endif + +/** + * Default implementation Subnetwork functions + * to satisfy libps dependencies. + */ +#ifdef NO_SUBNET +EMPTY_SUBNET +#endif + /* MDB format version */ #define MDB_VERSION 1 diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.xml b/Svc/GroundInterface/pusopen_onboard_mdb.xml index 2a0fadd7050..6c9f7983dfb 100644 --- a/Svc/GroundInterface/pusopen_onboard_mdb.xml +++ b/Svc/GroundInterface/pusopen_onboard_mdb.xml @@ -31,7 +31,7 @@ Compile this xml into .c file with poconfig tool : true - 512 + 2048 @@ -60,6 +60,7 @@ Compile this xml into .c file with poconfig tool : + 2048 2048 @@ -79,12 +80,12 @@ Compile this xml into .c file with poconfig tool : - 4096 - 4096 + 2048 + 2048 - 4096 + 2048 + 1102 2 PUS5_EVT_LOW Low severity anomaly - 1 + 1102 3 PUS5_EVT_MEDIUM Medium severity anomaly - 1 + 1102 4 PUS5_EVT_HIGH High severity anomaly - 1 + 1102 @@ -206,4 +207,19 @@ extern uint32_t PR_NumPings; + + + 2 + Report #2 + Report #2 description + true + 1 + 3 + + + 100 + + + + \ No newline at end of file From b1c533b8a2b782be85f91827caeb299582ba4280 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Wed, 20 Jan 2021 17:49:38 +0100 Subject: [PATCH 16/29] Implement PUS3 reports logic --- .gitignore | 2 +- Fw/Com/ComBuffer.cpp | 2 +- .../PingReceiverComponentImpl.cpp | 3 +- Svc/ActiveLogger/ActiveLoggerImpl.cpp | 2 +- Svc/GroundInterface/CMakeLists.txt | 4 +- Svc/GroundInterface/GroundInterface.cpp | 155 +++++---- Svc/GroundInterface/GroundInterface.hpp | 20 +- Svc/GroundInterface/pusopen_ground_mdb.xml | 120 ------- Svc/GroundInterface/pusopen_onboard_mdb.c | 304 ------------------ Svc/GroundInterface/pusopen_onboard_mdb.xml | 225 ------------- Svc/TlmChan/CMakeLists.txt | 7 + Svc/TlmChan/TlmChanImpl.cpp | 71 +++- Svc/TlmChan/TlmChanImpl.hpp | 19 +- Svc/TlmChan/TlmTypes.hpp | 8 + config/TlmChanImplCfg.hpp | 2 +- 15 files changed, 196 insertions(+), 748 deletions(-) delete mode 100644 Svc/GroundInterface/pusopen_ground_mdb.xml delete mode 100644 Svc/GroundInterface/pusopen_onboard_mdb.c delete mode 100644 Svc/GroundInterface/pusopen_onboard_mdb.xml create mode 100644 Svc/TlmChan/TlmTypes.hpp diff --git a/.gitignore b/.gitignore index 0932ca07413..b961cb951ac 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,4 @@ GTestBase.* **/DefaultDict/serializable/* # Clone CHESS-mission/pusopen as "Lib" in fprime root - Due to license restriction with PUSOpen -Lib \ No newline at end of file +#Lib # disable to allow VSCode to index Lib file \ No newline at end of file diff --git a/Fw/Com/ComBuffer.cpp b/Fw/Com/ComBuffer.cpp index 41d36c442a8..acd9a663bea 100644 --- a/Fw/Com/ComBuffer.cpp +++ b/Fw/Com/ComBuffer.cpp @@ -5,7 +5,7 @@ namespace Fw { ComBuffer::ComBuffer(const U8 *args, NATIVE_UINT_TYPE size) { SerializeStatus stat = SerializeBufferBase::setBuff(args,size); - FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); + FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } ComBuffer::ComBuffer() { diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.cpp b/Ref/PingReceiver/PingReceiverComponentImpl.cpp index 61c4d643232..a3e441e3fe2 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.cpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.cpp @@ -15,7 +15,6 @@ #include "Fw/Types/BasicTypes.hpp" namespace Ref { - // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -53,7 +52,7 @@ namespace Ref { U32 key ) { - this->log_DIAGNOSTIC_PR_PingReceived(key); + //this->log_DIAGNOSTIC_PR_PingReceived(key); this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); if (not this->m_inhibitPings) { PingOut_out(0,key); diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index 5a26a5761f9..92fb4b91937 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -188,7 +188,7 @@ namespace Svc { return; } -#if defined _GDS +#ifdef _GDS if (this->isConnected_PktSend_OutputPort(0)) { this->PktSend_out(0, this->m_comBuffer,0); } diff --git a/Svc/GroundInterface/CMakeLists.txt b/Svc/GroundInterface/CMakeLists.txt index ff103052c31..c61846483fd 100644 --- a/Svc/GroundInterface/CMakeLists.txt +++ b/Svc/GroundInterface/CMakeLists.txt @@ -10,7 +10,7 @@ set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/GroundInterfaceComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/GroundInterface.cpp" - "${CMAKE_CURRENT_LIST_DIR}/pusopen_onboard_mdb.c" # PUSOpen mission database + "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database ) set(MOD_DEPS "Utils/Types") register_fprime_module() @@ -31,7 +31,7 @@ set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestMain.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/GroundInterfaceRules.cpp" - "${CMAKE_CURRENT_LIST_DIR}/pusopen_onboard_mdb.c" # PUSOpen mission database + "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database ) # Test Includes for this UT register_fprime_ut() diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 908b2a5f1ed..9c25494b628 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -17,10 +17,14 @@ #include "Fw/Types/BasicTypes.hpp" #include +#ifdef _PUS +#include #include "pusopen.h" extern Svc::GroundInterfaceComponentImpl groundIf; +extern Os::Mutex PO_STACK_MUTEX; +#endif // defined _PUS namespace Svc { @@ -28,6 +32,7 @@ const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; const TOKEN_TYPE GroundInterfaceComponentImpl::START_WORD = static_cast(0xdeadbeef); const U32 GroundInterfaceComponentImpl::END_WORD = static_cast(0xcafecafe); +// PUSOpen global function test #ifdef __cplusplus extern "C" { #endif @@ -52,6 +57,7 @@ GroundInterfaceComponentImpl( void GroundInterfaceComponentImpl::init(const NATIVE_INT_TYPE instance) { GroundInterfaceComponentBase::init(instance); +#ifdef _PUS po_result_t res = PO_SUCCESS; res = po_initPus1(); // macro for pus1_reset(PO_DEF_PUS1) @@ -62,6 +68,7 @@ void GroundInterfaceComponentImpl::init(const NATIVE_INT_TYPE instance) { // PUSOpen initialisation error ! Critical error with FSW FW_ASSERT(0); } +#endif // defined _PUS } GroundInterfaceComponentImpl::~GroundInterfaceComponentImpl(void) {} @@ -75,22 +82,31 @@ void GroundInterfaceComponentImpl::downlinkPort_handler( Fw::ComBuffer &data, U32 context ) { -#if defined _GDS +#ifdef _GDS // Downlink TM disabled FW_ASSERT(data.getBuffLength() <= MAX_DATA_SIZE); frame_send(data.getBuffAddr(), data.getBuffLength()); +#endif // defined _GDS + +#ifdef _PUS + Fw::Buffer buffer; //!< Com buffer for sending event buffers + buffer.setData(data.getBuffAddr()); + buffer.setSize(data.getBuffCapacity()); + + write_out(0, buffer); #endif + } void GroundInterfaceComponentImpl::fileDownlinkBufferSendIn_handler( const NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer ) { -#if defined _GDS +#ifdef _GDS FW_ASSERT(fwBuffer.getSize() <= MAX_DATA_SIZE); frame_send(fwBuffer.getData(), fwBuffer.getSize(), Fw::ComPacket::FW_PACKET_FILE); fileDownlinkBufferSendOut_out(0, fwBuffer); -#endif +#endif // defined _GDS } void GroundInterfaceComponentImpl::readCallback_handler( @@ -102,19 +118,37 @@ void GroundInterfaceComponentImpl::readCallback_handler( FW_ASSERT(0); } -#if defined _PUS +#ifdef _PUS processPUS(buffer); #elif defined _GDS processBuffer(buffer); #endif } +void GroundInterfaceComponentImpl::schedIn_handler( + const NATIVE_INT_TYPE portNum, /*!< The port number*/ + NATIVE_UINT_TYPE context /*!< The call order*/ +) { + // TODO: replace with a call to a buffer manager + Fw::Buffer buffer = m_ext_buffer; + // Call read poll if it is hooked up + if (isConnected_readPoll_OutputPort(0)) { + readPoll_out(0, buffer); +#ifdef _PUS + processPUS(buffer); +#elif defined _GDS + processBuffer(buffer); +#endif + } +} + void GroundInterfaceComponentImpl::hkReport_handler( const NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val ) { +#ifdef _PUS // F' variables Fw::Buffer buffer; U32 tlmVal; @@ -129,7 +163,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( // printf("[PUS] Housekeeping received : %u (0x%02X)\n", id, id); - this->m_poStackMutex.lock(); + PO_STACK_MUTEX.lock(); /*/ m_tlmPacket.setId(id); @@ -154,7 +188,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( // Retrieve created TM[3,25] byte stream from PUSopen stack and send it po_res = po_frame(po_buf, &po_len); - this->m_poStackMutex.unLock(); + PO_STACK_MUTEX.unLock(); // If a report has been generated, send it if(po_len > 0) { @@ -163,6 +197,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( printf("[PUS] Send report\n"); write_out(0, buffer); } +#endif // defined _PUS } void GroundInterfaceComponentImpl::eventReport_handler( @@ -172,6 +207,7 @@ void GroundInterfaceComponentImpl::eventReport_handler( Fw::LogSeverity severity, Fw::LogBuffer &args ) { +#ifdef _PUS // F' variables Fw::Buffer buffer; //!< buffer to send frame to SocketIpDriver @@ -225,7 +261,7 @@ void GroundInterfaceComponentImpl::eventReport_handler( po_pus5_eventId = PUS5_EVT_HIGH; } - /*/ Event arguments to serialize + // Event arguments to serialize m_logPacket.setId(id); m_logPacket.setTimeTag(timeTag); m_logPacket.setLogBuffer(args); @@ -235,14 +271,14 @@ void GroundInterfaceComponentImpl::eventReport_handler( //*/ // simple data tests - po_evtData = id; + // po_evtData = id; - this->m_poStackMutex.lock(); + PO_STACK_MUTEX.lock(); // Send TM[5,x] with F' event ID = x po_res = po_pus5tm( po_pus5_eventId, // event ID PUS[5, x] - &po_evtData, // m_comBuffer.getBuffAddr(), // event data + m_comBuffer.getBuffAddr(), // event data GS_APID); // destination APID (GS) if(po_res != PO_SUCCESS) { @@ -259,56 +295,24 @@ void GroundInterfaceComponentImpl::eventReport_handler( FW_ASSERT(0); } - this->m_poStackMutex.unLock(); + PO_STACK_MUTEX.unLock(); buffer.setData(po_buf); buffer.setSize(po_len); - write_out(0, buffer); + //write_out(0, buffer); +#endif // defined _PUS } -void GroundInterfaceComponentImpl::schedIn_handler( - const NATIVE_INT_TYPE portNum, /*!< The port number*/ - NATIVE_UINT_TYPE context /*!< The call order*/ -) { - // TODO: replace with a call to a buffer manager - Fw::Buffer buffer = m_ext_buffer; - // Call read poll if it is hooked up - if (isConnected_readPoll_OutputPort(0)) { - readPoll_out(0, buffer); -#if defined _PUS - processPUS(buffer); -#elif defined _GDS - processBuffer(buffer); -#endif - } -} +void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { + NATIVE_UINT_TYPE buffer_offset = 0; -void GroundInterfaceComponentImpl::frame_send(U8 *data, TOKEN_TYPE size, TOKEN_TYPE packet_type) { - // TODO: replace with a call to a buffer manager - Fw::Buffer buffer = m_ext_buffer; - Fw::SerializeBufferBase& buffer_wrapper = buffer.getSerializeRepr(); - buffer_wrapper.resetSer(); - // True size is supplied size plus sizeof(TOKEN_TYPE) if a packet_type other than "UNKNOWN" was supplied. - // This is because if not UNKNOWN, the packet_type is serialized too. Otherwise it is assumed the PACKET_TYPE is - // already the first token in the UNKNOWN typed buffer. - U32 true_size = (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? size + sizeof(TOKEN_TYPE) : size; - // Frame format : | START_WORD | data_size | data | END_WORD | - U32 total_size = sizeof(TOKEN_TYPE) + sizeof(TOKEN_TYPE) + true_size + sizeof(U32); - // Serialize data - FW_ASSERT(GND_BUFFER_SIZE >= total_size, GND_BUFFER_SIZE, total_size); - buffer_wrapper.serialize(START_WORD); - buffer_wrapper.serialize(static_cast(true_size)); - // Explicitly set the packet type, if it didn't come with the data already - if (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) { - buffer_wrapper.serialize(packet_type); + while (buffer_offset < buffer.getSize()) { + NATIVE_UINT_TYPE ser_size = (buffer.getSize() >= m_in_ring.get_remaining_size(true)) ? + m_in_ring.get_remaining_size(true) : static_cast(buffer.getSize()); + m_in_ring.serialize(buffer.getData() + buffer_offset, ser_size); + buffer_offset = buffer_offset + ser_size; + processRing(); } - buffer_wrapper.serialize(data, size, true); - buffer_wrapper.serialize(static_cast(END_WORD)); - - // Setup for sending by truncating unused data - buffer.setSize(buffer_wrapper.getBuffLength()); - FW_ASSERT(buffer.getSize() == total_size, buffer.getSize(), total_size); - write_out(0, buffer); } void GroundInterfaceComponentImpl::routeComData() { @@ -379,17 +383,37 @@ void GroundInterfaceComponentImpl::processRing() { //*/ } -void GroundInterfaceComponentImpl::processBuffer(Fw::Buffer& buffer) { - NATIVE_UINT_TYPE buffer_offset = 0; - - while (buffer_offset < buffer.getSize()) { - NATIVE_UINT_TYPE ser_size = (buffer.getSize() >= m_in_ring.get_remaining_size(true)) ? - m_in_ring.get_remaining_size(true) : static_cast(buffer.getSize()); - m_in_ring.serialize(buffer.getData() + buffer_offset, ser_size); - buffer_offset = buffer_offset + ser_size; - processRing(); +#ifdef _GDS +void GroundInterfaceComponentImpl::frame_send(U8 *data, TOKEN_TYPE size, TOKEN_TYPE packet_type) { + // TODO: replace with a call to a buffer manager + Fw::Buffer buffer = m_ext_buffer; + Fw::SerializeBufferBase& buffer_wrapper = buffer.getSerializeRepr(); + buffer_wrapper.resetSer(); + // True size is supplied size plus sizeof(TOKEN_TYPE) if a packet_type other than "UNKNOWN" was supplied. + // This is because if not UNKNOWN, the packet_type is serialized too. Otherwise it is assumed the PACKET_TYPE is + // already the first token in the UNKNOWN typed buffer. + U32 true_size = (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? size + sizeof(TOKEN_TYPE) : size; + // Frame format : | START_WORD | data_size | data | END_WORD | + U32 total_size = sizeof(TOKEN_TYPE) + sizeof(TOKEN_TYPE) + true_size + sizeof(U32); + // Serialize data + FW_ASSERT(GND_BUFFER_SIZE >= total_size, GND_BUFFER_SIZE, total_size); + buffer_wrapper.serialize(START_WORD); + buffer_wrapper.serialize(static_cast(true_size)); + // Explicitly set the packet type, if it didn't come with the data already + if (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) { + buffer_wrapper.serialize(packet_type); } + buffer_wrapper.serialize(data, size, true); + buffer_wrapper.serialize(static_cast(END_WORD)); + + // Setup for sending by truncating unused data + buffer.setSize(buffer_wrapper.getBuffLength()); + FW_ASSERT(buffer.getSize() == total_size, buffer.getSize(), total_size); + write_out(0, buffer); } +#endif // defined GDS + +#ifdef _PUS void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { Fw::Buffer extBuff = m_ext_buffer; @@ -399,7 +423,7 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { U8 buf[4096]; // @todo use definition U16 len; - this->m_poStackMutex.lock(); + PO_STACK_MUTEX.lock(); // Push received data byte-by-byte into PUSopen(R) stack for(int i = 0; i < buffer.getSize(); i++) { @@ -415,7 +439,7 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { // Retrieve potentially created TM[17,x] byte stream from PUSopen(R) stack and send it po_frame(buf, &len); - this->m_poStackMutex.unLock(); + PO_STACK_MUTEX.unLock(); //printf("[PUS] size buf %u\n",len); for(int i = 0;i -#include #include "Svc/GroundInterface/GroundInterfaceComponentAc.hpp" #include "Utils/Types/CircularBuffer.hpp" @@ -99,6 +98,14 @@ namespace Svc { const NATIVE_INT_TYPE portNum, /*!< The port number*/ NATIVE_UINT_TYPE context /*!< The call order*/ ); + + //! Processes the out-going data into coms order + void routeComData(); + + //! Process all the data in the ring + void processRing(); + +#ifdef _GDS //! Frame and send some data //! void frame_send( @@ -106,15 +113,12 @@ namespace Svc { TOKEN_TYPE size, /*!< Size of data in typed format */ TOKEN_TYPE packet_type = Fw::ComPacket::FW_PACKET_UNKNOWN /*!< Packet type override for anoymous data i.e. file downlink */ ); +#endif // defined _GDS - //! Processes the out-going data into coms order - void routeComData(); - - //! Process all the data in the ring - void processRing(); - +#ifdef _PUS //! Process a data buffer containing a read from the serial port void processPUS(Fw::Buffer& data /*!< Data to process */); +#endif // defined _PUS // Basic data movement variables Fw::Buffer m_ext_buffer; @@ -124,8 +128,6 @@ namespace Svc { TOKEN_TYPE m_data_size; //!< Data size expected in incoming data U8 m_in_buffer[GND_BUFFER_SIZE]; Types::CircularBuffer m_in_ring; - - Os::Mutex m_poStackMutex; /*!< Protect access to PUSOpen stack */ }; } // end namespace Svc diff --git a/Svc/GroundInterface/pusopen_ground_mdb.xml b/Svc/GroundInterface/pusopen_ground_mdb.xml deleted file mode 100644 index 5f282005925..00000000000 --- a/Svc/GroundInterface/pusopen_ground_mdb.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - 1.1 - - - 3 - - - 4 - - - - - - - true - - - 512 - - - - false - - - - false - - - - false - - - - false - - - - false - - - - true - - - - - true - - - 512 - 512 - - - - - - - - - - false - - - - - true - - - 2048 - 2048 - - - 2048 - - - FESS_DEF_ASM - 3 - - - - SLIP - NOENCRYPTION - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.c b/Svc/GroundInterface/pusopen_onboard_mdb.c deleted file mode 100644 index ee6966bc6c9..00000000000 --- a/Svc/GroundInterface/pusopen_onboard_mdb.c +++ /dev/null @@ -1,304 +0,0 @@ -/** - * PUSopen(R) Mission Database - * - * THIS FILE HAS BEEN AUTOGENERATED. - * ANY MANUAL MODIFICATIONS MAY BE OVERWRITTEN. - */ - -/* Include files */ -#include "pusopen.h" - -/* Included PUSopen(R) modules */ - -#define PUS1_PROVIDER -#define PUS3_PROVIDER -#define PUS5_PROVIDER -#define PUS8_PROVIDER -/* #define PUS13_PROVIDER */ -#define PUS17_PROVIDER -/* #define PUS_USR */ - -/* PUSopen(R) configuration */ - -/* PUS 1 - Size of reception buffer (in bytes) */ -#define PUS1_RECV_BUF_SIZE 2048 - -/* PUS 1 - Virtual Channel for TM[1,x] */ -#define PUS1_VCID 1 - -/* PUS 3 - Size of buffer in which TM[3,25] report is composed (in bytes) */ -#define PUS3_REPORT_BUF_SIZE 2048 - -/* PUS 17 - Virtual Channel for TM[17,x] */ -#define PUS17_VCID 0 - -#define PS_LAYER - -/* PS - Max size of sent packet (in bytes) */ -#define PS_MAX_SEND_PACKET_SIZE 2048 - -/* PS - Max size of received packet (in bytes) */ -#define PS_MAX_RECV_PACKET_SIZE 2048 - -/* PS - Checksum type */ -#define PS_PKT_CHECKSUM_TYPE PKT_ISO16 - -/* PS - Checksum length (in bytes) */ -#define PS_PKT_CHECKSUM_LEN 2 - -#define FESS_LAYER - -/* FESS - Size of send buffer (in bytes) */ -#define FESS_SEND_BUF_SIZE 2048 - -/* FESS - Size of reception buffer (in bytes) */ -#define FESS_RECV_BUF_SIZE 2048 - -/* FESS - Size of FESS temporary buffers (in bytes) */ -#define FESS_TEMP_BUF_SIZE 2048 - -/* FESS - Attached Synchronization Mark (ASM) */ -#define FESS_ASM FESS_DEF_ASM - -/* FESS - Length of ASM */ -#define FESS_ASM_LEN 3 - -/* FESS - Frame encoding algorithm */ -#define FESS_ENCODING SLIP - -/* FESS - Frame encryption algorithm */ -#define FESS_ENCRYPTION NOENCRYPTION - -/* FESS - AES128 encryption key */ -#define FESS_AES_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} - -/* FESS - AES128 initial vector */ -#define FESS_AES_IV {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} - -/* PUS Service providers and user */ - -#ifdef PUS1_PROVIDER -PUS1_PROVIDER_INIT(pus1, PUS1_RECV_BUF_SIZE, PUS1_VCID); -#endif - -#ifdef PUS3_PROVIDER -PUS3_PROVIDER_INIT(pus3, PUS3_REPORT_BUF_SIZE); -#endif - -#ifdef PUS5_PROVIDER -PUS5_PROVIDER_INIT(pus5); -#endif - -#ifdef PUS8_PROVIDER -PUS8_PROVIDER_INIT(pus8); -#endif - -#ifdef PUS17_PROVIDER -PUS17_PROVIDER_INIT(pus17, PUS17_VCID); -#endif - -/* Packet Services */ - -#ifdef PS_LAYER -PS_INIT(ps, PS_MAX_SEND_PACKET_SIZE, PS_MAX_RECV_PACKET_SIZE, PS_PKT_CHECKSUM_TYPE, PS_PKT_CHECKSUM_LEN); -#endif - - -/* FESS Layer */ - -#ifdef FESS_LAYER -FESS_INIT(fess, FESS_ASM, FESS_ASM_LEN, FESS_ENCODING, FESS_ENCRYPTION, FESS_SEND_BUF_SIZE, FESS_RECV_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_TEMP_BUF_SIZE, FESS_AES_KEY, FESS_AES_IV); -#endif - -/* User Code */ - - -extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); -extern uint32_t PR_NumPings; - - -/* On-board Events */ - -po_evt_t evt[] = { - { - .id = 1U, - .level = PUS5_EVT_INFO, - .desc = "Information event", - .dataLen = 1102U, - .vcid = 1U - }, - { - .id = 2U, - .level = PUS5_EVT_LOW, - .desc = "Low severity anomaly", - .dataLen = 1102U, - .vcid = 1U - }, - { - .id = 3U, - .level = PUS5_EVT_MEDIUM, - .desc = "Medium severity anomaly", - .dataLen = 1102U, - .vcid = 1U - }, - { - .id = 4U, - .level = PUS5_EVT_HIGH, - .desc = "High severity anomaly", - .dataLen = 1102U, - .vcid = 1U - } -}; - -/* User Functions */ -extern po_result_t UserPus8Fn(uint8_t functionid, uint8_t *data, uint16_t len); - -po_fnc_t fnc[] = { - { - .id = 1U, - .name = "Test function", - .desc = "Example test function", - .addr = &UserPus8Fn - } -}; - -/* HK Parameters */ - -po_obparam_t obparams[] = { -#ifdef FESS_LAYER -PO_MDB_PARAMS_FESS -#endif -#ifdef PS_LAYER -PO_MDB_PARAMS_PS -#endif -#ifdef VC_LAYER -PO_MDB_PARAMS_VC -#endif -#ifdef PUS1_PROVIDER -PO_MDB_PARAMS_PUS1 -#endif -#ifdef PUS3_PROVIDER -PO_MDB_PARAMS_PUS3 -#endif -#ifdef PUS5_PROVIDER -PO_MDB_PARAMS_PUS5 -#endif -#ifdef PUS8_PROVIDER -PO_MDB_PARAMS_PUS8 -#endif -#ifdef PUS13_PROVIDER -PO_MDB_PARAMS_PUS13 -#endif -#ifdef PUS17_PROVIDER -PO_MDB_PARAMS_PUS17 -#endif -#ifdef PUS_USR -PO_MDB_PARAMS_PUSUSR -#endif - { - .id = 100U, - .name = "PR_NumPings", - .desc = "Number of pings received", - .type = PO_UINT32, - .addr = &PR_NumPings - } -}; - -/* HK Reports */ - -po_hkreport_t hkreps[] = { - { - .id = 1U, - .name = "Report #1", - .desc = "Report #1 description", - .enabled = POTRUE, - .interval = 1U, - .sinceLast = 0U, - .destApid = 3U, - .vcid = 0U, - .numHk = 8U, - .obparams = { 100 } - }, - { - .id = 2U, - .name = "Report #2", - .desc = "Report #2 description", - .enabled = POTRUE, - .interval = 1U, - .sinceLast = 0U, - .destApid = 3U, - .vcid = 0U, - .numHk = 8U, - .obparams = { 100 } - } -}; - -/* PUSopen(R) Mission Database */ - -po_mdbapid_t po_mdb_apid = { - .apid = 1, - .apuid = 2, - - .pus1 = POADDR(pus1), - .pus3 = POADDR(pus3), - .pus5 = POADDR(pus5), - .pus8 = POADDR(pus8), - .pus13 = PONULL, - .pus17 = POADDR(pus17), - .pusUsr = PONULL, - .ps = POADDR(ps), - .vc = PONULL, - .fess = POADDR(fess), - - .numevt = 4U, - .numparams = 42U, - .numreports = 2U, - .numfct = 1U, - .events = evt, - .obparams = obparams, - .func = fnc, - .hkreports = hkreps -}; - -/** - * Default implementation of pususr_tm to satisfy - * dependencies if PUS Service User is not used. - */ -#ifndef PUS_USR -EMPTY_PUSUSR_TM -#endif - -/** - * Default implementation of po_time to satisfy - * dependencies if user does not implement po_time. - */ -#ifndef PUS_CUSTOM_TIME -EMPTY_PO_TIME -#endif - -/** - * Default implementation of po_tc to satisfy - * dependencies if user does not implement po_tc. - */ -#ifndef PUS_CUSTOM_SERVICES -EMPTY_PO_TC -#endif - -/** - * Default implementation of pus13_tc to satisfy - * dependencies if user does not implement pus13_tc. - */ -#ifndef PUS13_PROVIDER -EMPTY_PUS13_TC -#endif - -/** - * Default implementation Subnetwork functions - * to satisfy libps dependencies. - */ -#ifdef NO_SUBNET -EMPTY_SUBNET -#endif - -/* MDB format version */ -#define MDB_VERSION 1 diff --git a/Svc/GroundInterface/pusopen_onboard_mdb.xml b/Svc/GroundInterface/pusopen_onboard_mdb.xml deleted file mode 100644 index 6c9f7983dfb..00000000000 --- a/Svc/GroundInterface/pusopen_onboard_mdb.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - 1.1 - - - 1 - - - 2 - - - - - - - true - - - 2048 - - - - true - - - 2048 - - - - true - - - - true - - - - false - - - - true - - - - false - - - - - true - - - - - 2048 - 2048 - - - - - - - - false - - - - - true - - - 2048 - 2048 - - - 2048 - - - FESS_DEF_ASM - 3 - - - - SLIP - NOENCRYPTION - - - - - - - - - 1 - PUS5_EVT_INFO - Information event - 1102 - - - - 2 - PUS5_EVT_LOW - Low severity anomaly - 1102 - - - - 3 - PUS5_EVT_MEDIUM - Medium severity anomaly - 1102 - - - - 4 - PUS5_EVT_HIGH - High severity anomaly - 1102 - - - - - -extern po_result_t UserPus8Fn(uint8_t fid, uint8_t *data, uint16_t len); -extern uint32_t PR_NumPings; - - - - - - 1 - Test function - Example test function - UserPus8Fn - - - - - - 100 - PR_NumPings - Number of pings received - PO_UINT32 - PR_NumPings - - - - - - 1 - Report #1 - Report #1 description - true - 1 - 3 - - - 100 - - - - - - - 2 - Report #2 - Report #2 description - true - 1 - 3 - - - 100 - - - - - \ No newline at end of file diff --git a/Svc/TlmChan/CMakeLists.txt b/Svc/TlmChan/CMakeLists.txt index c64b464bf92..55997d876a0 100644 --- a/Svc/TlmChan/CMakeLists.txt +++ b/Svc/TlmChan/CMakeLists.txt @@ -9,15 +9,22 @@ set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/TlmChanComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/TlmChanImpl.cpp" + "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database ) register_fprime_module() +add_definitions(-D_LINUB1804_GCC750) +include_directories(../../Lib/Includes) +find_library(PUSOPEN pusopen ../../Lib/lib) +target_link_libraries(Svc_TlmChan ${PUSOPEN}) + ### UTs ### set(UT_SOURCE_FILES "${FPRIME_FRAMEWORK_PATH}/Svc/TlmChan/TlmChanComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TlmChanTester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TlmChanImplTester.cpp" + "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database ) register_fprime_ut() diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index 71aab307e4f..e590a8d756a 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -10,14 +10,32 @@ *

*/ #include +#include #include #include #include #include +#include + #include #include +#ifndef _GDS // for VS synthax highlighting +//#define _PUS +#endif + +#ifdef _PUS +#include + +#include "pusopen.h" + +extern Os::Mutex PO_STACK_MUTEX; + +extern S_PO_PARAM PO_PARAM; + +#endif // defined _PUS + namespace Svc { TlmChanImpl::TlmChanImpl(const char* name) : TlmChanComponentBase(name) @@ -29,6 +47,7 @@ namespace Svc { this->m_tlmEntries[0].slots[entry] = 0; this->m_tlmEntries[1].slots[entry] = 0; } + // clear buckets for (NATIVE_UINT_TYPE entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { this->m_tlmEntries[0].buckets[entry].used = false; @@ -42,9 +61,15 @@ namespace Svc { this->m_tlmEntries[1].buckets[entry].next = 0; this->m_tlmEntries[1].buckets[entry].id = 0; } + // clear free index this->m_tlmEntries[0].free = 0; this->m_tlmEntries[1].free = 0; + +#ifdef _PUS + // Fot testing purpose @todo remove (or replace by loop iteration) + PO_PARAM.BD_Cycles = 0; +#endif } TlmChanImpl::~TlmChanImpl() {} @@ -69,6 +94,8 @@ namespace Svc { } void TlmChanImpl::Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) { + +#ifdef _GDS // Only write packets if connected if (not this->isConnected_PktSend_OutputPort(0)) { return; @@ -77,7 +104,7 @@ namespace Svc { // lock mutex long enough to modify active telemetry buffer // so the data can be read without worrying about updates this->lock(); - this->m_activeBuffer = 1 - this->m_activeBuffer; + this->m_activeBuffer = 1 - this->m_activeBuffer; // activeBuffer is 0 or 1 // set activeBuffer to not updated for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { this->m_tlmEntries[this->m_activeBuffer].buckets[entry].updated = false; @@ -85,11 +112,9 @@ namespace Svc { this->unLock(); // go through each entry and send a packet if it has been updated - for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { TlmEntry* p_entry = &this->m_tlmEntries[1-this->m_activeBuffer].buckets[entry]; if ((p_entry->updated) && (p_entry->used)) { -#if defined _GDS this->m_tlmPacket.setId(p_entry->id); this->m_tlmPacket.setTimeTag(p_entry->lastUpdate); this->m_tlmPacket.setTlmBuffer(p_entry->buffer); @@ -101,15 +126,36 @@ namespace Svc { if (this->isConnected_PktSend_OutputPort(0)) { this->PktSend_out(0,this->m_comBuffer,0); } + } + } + #elif defined _PUS - p_entry->updated = false; + // F' variables + U32 tlmVal; - if (this->isConnected_PktSend_OutputPort(0)) { - this->TlmSend_out(0, p_entry->id, p_entry->lastUpdate, p_entry->buffer); - } -#endif + + // PUSOpen variables + U8 po_buf[4096]; // @todo use definition + U16 po_len; + po_result_t po_res = PO_ERR; + + po_triggerPus3(); + + PO_STACK_MUTEX.lock(); + + po_res = po_frame(po_buf, &po_len); + + PO_STACK_MUTEX.unLock(); + + if(po_len > 0) { + Fw::ComBuffer m_comBuffer(po_buf, po_len); //!< Com buffer for sending event buffers + printf("[PUS] Send report\n"); + if (this->isConnected_PktSend_OutputPort(0)) { + this->PktSend_out(0,m_comBuffer,0); } } +#endif + } void TlmChanImpl::TlmRecv_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { // Compute index for entry @@ -156,6 +202,15 @@ namespace Svc { entryToUse->lastUpdate = timeTag; entryToUse->buffer = val; +#ifdef _PUS + if (id == 481) { + U32 cycles; + val.deserialize(cycles); + PO_PARAM.BD_Cycles = cycles; + printf("Tlm %u val %u\n", id, cycles); + } +#endif // defined _PUS + } void TlmChanImpl::TlmGet_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { diff --git a/Svc/TlmChan/TlmChanImpl.hpp b/Svc/TlmChan/TlmChanImpl.hpp index d94818c8b6d..8cfc1ee79a3 100644 --- a/Svc/TlmChan/TlmChanImpl.hpp +++ b/Svc/TlmChan/TlmChanImpl.hpp @@ -19,7 +19,6 @@ #include namespace Svc { - class TlmChanImpl: public TlmChanComponentBase { public: friend class TlmChanImplTester; @@ -30,12 +29,10 @@ namespace Svc { NATIVE_INT_TYPE instance /*!< The instance number*/ ); PROTECTED: - // can be overridden for alternate algorithms virtual NATIVE_UINT_TYPE doHash(FwChanIdType id); PRIVATE: - // Port functions void TlmRecv_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val); void TlmGet_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val); @@ -47,6 +44,16 @@ namespace Svc { U32 key /*!< Value to return to pinger*/ ); + U32 m_activeBuffer; // !< which buffer is active for storing telemetry + // can be 1 or 2 and will define m_tlmEntries[index] + + // work variables + Fw::ComBuffer m_comBuffer; + Fw::TlmPacket m_tlmPacket; + + U32 defaultTlmValue; + + public: typedef struct tlmEntry { FwChanIdType id; //!< telemetry id stored in slot bool updated; //!< set whenever a value has been written. Used to skip if writing out values for downlinking @@ -62,12 +69,6 @@ namespace Svc { TlmEntry buckets[TLMCHAN_HASH_BUCKETS]; //!< set of buckets used in hash table NATIVE_INT_TYPE free; //!< next free bucket } m_tlmEntries[2]; - - U32 m_activeBuffer; // !< which buffer is active for storing telemetry - - // work variables - Fw::ComBuffer m_comBuffer; - Fw::TlmPacket m_tlmPacket; }; } diff --git a/Svc/TlmChan/TlmTypes.hpp b/Svc/TlmChan/TlmTypes.hpp new file mode 100644 index 00000000000..646dd2ef96b --- /dev/null +++ b/Svc/TlmChan/TlmTypes.hpp @@ -0,0 +1,8 @@ +#ifndef TLMTYPES_HPP +#define TLMTYPES_HPP + +struct S_PO_PARAM { + uint32_t BD_Cycles; +}; + +#endif \ No newline at end of file diff --git a/config/TlmChanImplCfg.hpp b/config/TlmChanImplCfg.hpp index b62009b013a..4fe369add5d 100644 --- a/config/TlmChanImplCfg.hpp +++ b/config/TlmChanImplCfg.hpp @@ -17,7 +17,7 @@ // The parameters below provide for tuning of the hash function used to -// write and read entries in the database. The has function is very simple; +// write and read entries in the database. The hash function is very simple; // It first takes the telemetry ID and does a modulo computation with // TLMCHAN_HASH_MOD_VALUE. It then does a second modulo with the number // of slots to make sure the value lands in the provided slots. From 4928c23049c29f3562fb305f53903288b44e4df0 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 21 Jan 2021 11:53:27 +0100 Subject: [PATCH 17/29] Add second output to ActiveLogger to connect EventAction --- Svc/ActiveLogger/ActiveLoggerComponentAi.xml | 2 +- Svc/ActiveLogger/ActiveLoggerImpl.cpp | 11 ++++++--- Svc/TlmChan/TlmChanImpl.cpp | 25 ++++++++++---------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Svc/ActiveLogger/ActiveLoggerComponentAi.xml b/Svc/ActiveLogger/ActiveLoggerComponentAi.xml index 729ab343b1d..a889671a664 100644 --- a/Svc/ActiveLogger/ActiveLoggerComponentAi.xml +++ b/Svc/ActiveLogger/ActiveLoggerComponentAi.xml @@ -18,7 +18,7 @@ Telemetry input port
- + Telemetry output port diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index 92fb4b91937..9badea537bd 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -188,14 +188,19 @@ namespace Svc { return; } + // Send event to EventSequence + if (this->isConnected_LogSend_OutputPort(0)) { + this->LogSend_out(0, id, timeTag, static_cast(severity) , args); + } + #ifdef _GDS if (this->isConnected_PktSend_OutputPort(0)) { this->PktSend_out(0, this->m_comBuffer,0); } #elif defined _PUS - // redirect event through event output - if (this->isConnected_LogSend_OutputPort(0)) { - this->LogSend_out(0, id, timeTag, static_cast(severity) , args); + // Send event to GroundInterface + if (this->isConnected_LogSend_OutputPort(1)) { + this->LogSend_out(1, id, timeTag, static_cast(severity) , args); } #endif } diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index e590a8d756a..eb54e5229be 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -22,7 +22,7 @@ #include #ifndef _GDS // for VS synthax highlighting -//#define _PUS +#define _PUS // will cause compiler warning for redifinition #endif #ifdef _PUS @@ -95,11 +95,12 @@ namespace Svc { void TlmChanImpl::Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) { + // Only write packets if connected + if (not this->isConnected_PktSend_OutputPort(0)) { + return; + } + #ifdef _GDS - // Only write packets if connected - if (not this->isConnected_PktSend_OutputPort(0)) { - return; - } // lock mutex long enough to modify active telemetry buffer // so the data can be read without worrying about updates @@ -123,9 +124,7 @@ namespace Svc { FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); p_entry->updated = false; - if (this->isConnected_PktSend_OutputPort(0)) { - this->PktSend_out(0,this->m_comBuffer,0); - } + this->PktSend_out(0,this->m_comBuffer,0); } } @@ -139,6 +138,8 @@ namespace Svc { U16 po_len; po_result_t po_res = PO_ERR; + // Trigger PUS service 3 to check is report + // has to generated po_triggerPus3(); PO_STACK_MUTEX.lock(); @@ -148,11 +149,10 @@ namespace Svc { PO_STACK_MUTEX.unLock(); if(po_len > 0) { + FW_ASSERT(po_len <= FW_COM_BUFFER_MAX_SIZE); Fw::ComBuffer m_comBuffer(po_buf, po_len); //!< Com buffer for sending event buffers printf("[PUS] Send report\n"); - if (this->isConnected_PktSend_OutputPort(0)) { - this->PktSend_out(0,m_comBuffer,0); - } + this->PktSend_out(0,m_comBuffer,0); } #endif @@ -203,7 +203,8 @@ namespace Svc { entryToUse->buffer = val; #ifdef _PUS - if (id == 481) { + // @todo Find a way to optimise this + if (id == 481) { // BD_cycles U32 cycles; val.deserialize(cycles); PO_PARAM.BD_Cycles = cycles; From c54ac2d596523c8518927df642afa664aa9a6b9c Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 21 Jan 2021 17:18:25 +0100 Subject: [PATCH 18/29] Implement PUS3 reports with parameters array --- Svc/ActiveLogger/docs/sdd.md | 2 +- Svc/GroundInterface/GroundInterface.cpp | 44 +++++++------------- Svc/TlmChan/TlmChanImpl.cpp | 53 ++++++++++++++++++------- Svc/TlmChan/TlmTypes.hpp | 8 ---- 4 files changed, 54 insertions(+), 53 deletions(-) delete mode 100644 Svc/TlmChan/TlmTypes.hpp diff --git a/Svc/ActiveLogger/docs/sdd.md b/Svc/ActiveLogger/docs/sdd.md index 8543d60bd61..269da319fd9 100644 --- a/Svc/ActiveLogger/docs/sdd.md +++ b/Svc/ActiveLogger/docs/sdd.md @@ -93,7 +93,7 @@ Document | Link -------- | ---- Design Checklist | [Link](Checklist_Design.xlsx) Code Checklist | [Link](Checklist_Code.xlsx) -Unit Test Checklist | [Link](Checklist_Unit_test.xlsx) +Unit Test Checklist | [Link](Checklist_Unit_Test.xls) ## 6. Unit Testing diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 9c25494b628..60b8132b11d 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -32,16 +32,6 @@ const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; const TOKEN_TYPE GroundInterfaceComponentImpl::START_WORD = static_cast(0xdeadbeef); const U32 GroundInterfaceComponentImpl::END_WORD = static_cast(0xcafecafe); -// PUSOpen global function test -#ifdef __cplusplus -extern "C" { -#endif -U32 PR_NumPings = 0; -#ifdef __cplusplus -} -#endif - - // ------------------------------------- --------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -149,7 +139,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( Fw::TlmBuffer &val ) { #ifdef _PUS - // F' variables + /*/ F' variables -- Directly done in TlmChan TlmRecvHandler Fw::Buffer buffer; U32 tlmVal; @@ -165,15 +155,6 @@ void GroundInterfaceComponentImpl::hkReport_handler( PO_STACK_MUTEX.lock(); - /*/ - m_tlmPacket.setId(id); - m_tlmPacket.setTimeTag(timeTag); - m_tlmPacket.setTlmBuffer(val); - m_comBuffer.resetSer(); - Fw::SerializeStatus stat = m_tlmPacket.serialize(m_comBuffer); - FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); - //*/ - // Sample - In the future serialize id and TlmBuffer switch(id) { case 0x29: // (41) PR_NumPings @@ -197,6 +178,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( printf("[PUS] Send report\n"); write_out(0, buffer); } + //*/ #endif // defined _PUS } @@ -221,7 +203,7 @@ void GroundInterfaceComponentImpl::eventReport_handler( po_result_t po_res = PO_ERR; pus5_evtId_t po_pus5_eventId = PUS5_EVT_HIGH; // default value - printf("[PUS] Event received : %u (0x%02X)\n", id, id); + // printf("[PUS] Event received : %u (0x%02X)\n", id, id); /** ---- PUS Service 5 severity level ---- @@ -270,9 +252,6 @@ void GroundInterfaceComponentImpl::eventReport_handler( FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); //*/ - // simple data tests - // po_evtData = id; - PO_STACK_MUTEX.lock(); // Send TM[5,x] with F' event ID = x @@ -283,23 +262,30 @@ void GroundInterfaceComponentImpl::eventReport_handler( if(po_res != PO_SUCCESS) { // PO_ERR_LOWSPACE 2 No space to store input data if too small - printf("[PUS] po error: %u\n", po_res); - FW_ASSERT(0); + if (po_res == 2) { + printf("=== [PUS] EVT - To long frame (%u)- Not send\n", po_len); + } else { + printf("=== [PUS] EVT - po_pus5tm po error: %u\n", po_res); + } + return; } // Retrieve created TM[5,x] byte stream from PUSopen stack and send it po_res = po_frame(po_buf, &po_len); if(po_res != PO_SUCCESS) { - printf("[PUS] po error: %u\n", po_res); - FW_ASSERT(0); + if (po_res == 2) { + printf("=== [PUS] EVT - To long frame (%u)- Not send\n", po_len); + } else { + printf("=== [PUS] EVT - po_frame po error: %u\n", po_res); + } return; } PO_STACK_MUTEX.unLock(); buffer.setData(po_buf); buffer.setSize(po_len); - //write_out(0, buffer); + write_out(0, buffer); #endif // defined _PUS } diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index eb54e5229be..baf585cc71a 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -10,19 +10,18 @@ *

*/ #include -#include #include #include #include #include #include - +#include "../../Lib/mdb/hk_param.h" #include #include #ifndef _GDS // for VS synthax highlighting -#define _PUS // will cause compiler warning for redifinition +//#define _PUS // will cause compiler warning for redifinition #endif #ifdef _PUS @@ -32,14 +31,16 @@ extern Os::Mutex PO_STACK_MUTEX; -extern S_PO_PARAM PO_PARAM; +extern s_PARAM PARAM; #endif // defined _PUS namespace Svc { TlmChanImpl::TlmChanImpl(const char* name) : TlmChanComponentBase(name) - { + { + U16 i = 0; + // clear data this->m_activeBuffer = 0; // clear slot pointers @@ -67,8 +68,14 @@ namespace Svc { this->m_tlmEntries[1].free = 0; #ifdef _PUS - // Fot testing purpose @todo remove (or replace by loop iteration) - PO_PARAM.BD_Cycles = 0; + // Set global PUS variable with default value + // @todo - Find a clean way to deal with PARAM struct - Dirty code :o + // Works only with U32 parameters list !! + for(i = 0; i < PO_PARAM_SIZE; i++) { + U32* ptr = reinterpret_cast(&PARAM); + ptr = ptr + i; + *ptr = (U32)0; + } #endif } @@ -149,9 +156,14 @@ namespace Svc { PO_STACK_MUTEX.unLock(); if(po_len > 0) { + // @todo Remove - Temporary + if(po_len > FW_COM_BUFFER_MAX_SIZE) { + printf("=== [PUS] TLM - To long frame (%u)- Not send\n", po_len); + return; + } FW_ASSERT(po_len <= FW_COM_BUFFER_MAX_SIZE); + printf("TLM: (%u) Send report\n", po_len); Fw::ComBuffer m_comBuffer(po_buf, po_len); //!< Com buffer for sending event buffers - printf("[PUS] Send report\n"); this->PktSend_out(0,m_comBuffer,0); } #endif @@ -203,13 +215,24 @@ namespace Svc { entryToUse->buffer = val; #ifdef _PUS - // @todo Find a way to optimise this - if (id == 481) { // BD_cycles - U32 cycles; - val.deserialize(cycles); - PO_PARAM.BD_Cycles = cycles; - printf("Tlm %u val %u\n", id, cycles); - } + // List ids used in report #1 for PUS3 service + U32 used_hk[] = {0x29, 0x79, 0x7a, 0x169, 0x1E1, 0x42f, 0x430, 0x431}; + + // Check received TM and update global variable for PUSOpen lib if + // id is used in report + // @todo - Find a clean way to deal with hk_param - Dirty code :o + // Works only with U32 parameters list !! + U16 i; + for(i = 0; i < PO_PARAM_SIZE; i++) { + if (used_hk[i] == id) { + U32 value; + val.deserialize(value); + U32* ptr = reinterpret_cast(&PARAM); + ptr = ptr + i; + *ptr = value; + // printf("Tlm %u val %u\n", id, value); + } + } #endif // defined _PUS } diff --git a/Svc/TlmChan/TlmTypes.hpp b/Svc/TlmChan/TlmTypes.hpp deleted file mode 100644 index 646dd2ef96b..00000000000 --- a/Svc/TlmChan/TlmTypes.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef TLMTYPES_HPP -#define TLMTYPES_HPP - -struct S_PO_PARAM { - uint32_t BD_Cycles; -}; - -#endif \ No newline at end of file From 2229bb363f8f50ee717df0fafb0bb23c27895726 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 21 Jan 2021 17:19:32 +0100 Subject: [PATCH 19/29] Improve fatal messages for visibility --- Fw/Types/Assert.cpp | 4 ++-- Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp | 2 +- Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Fw/Types/Assert.cpp b/Fw/Types/Assert.cpp index 7b2e169120a..5a997954b8d 100644 --- a/Fw/Types/Assert.cpp +++ b/Fw/Types/Assert.cpp @@ -12,9 +12,9 @@ #else #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT -#define fileIdFs "Assert file ID 0x%08X:%d " +#define fileIdFs "============= Assert file ID 0x%08X:%d =============" #else -#define fileIdFs "Assert file \"%s\":%d " +#define fileIdFs "============= Assert file \"%s\":%d =============" #endif namespace Fw { diff --git a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp index 1120d8a07f8..7611fa22d44 100644 --- a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp +++ b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp @@ -85,7 +85,7 @@ namespace Svc { arg1,arg2,arg3,arg4,arg5,arg6); } else { // Can't assert, what else can we do? Maybe somebody will see it. - Fw::Logger::logMsg("Svc::AssertFatalAdapter not registered!\n"); + Fw::Logger::logMsg("============= Svc::AssertFatalAdapter not registered! =============\n"); assert(0); } } diff --git a/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp b/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp index 0aaf2c26ff8..5cf8a46e27f 100644 --- a/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp +++ b/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp @@ -26,7 +26,7 @@ namespace Svc { const NATIVE_INT_TYPE portNum, FwEventIdType Id) { // for **nix, delay then exit with error code - Fw::Logger::logMsg("FATAL %d handled.\n",(U32)Id,0,0,0,0,0); + Fw::Logger::logMsg("============= FATAL event 0x%x handled ============= \n",(U32)Id,0,0,0,0,0); (void)Os::Task::delay(1000); Fw::Logger::logMsg("Exiting.\n",0,0,0,0,0,0); (void)raise( SIGSEGV ); From 421edfce2333d9e5d8c1bd0aa5ddf6170da85ed9 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 21 Jan 2021 17:20:12 +0100 Subject: [PATCH 20/29] Avoid HLTH_PING_LATE fatal to stop code execution --- Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp b/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp index 5cf8a46e27f..af4c55ce46f 100644 --- a/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp +++ b/Svc/FatalHandler/FatalHandlerComponentLinuxImpl.cpp @@ -25,6 +25,12 @@ namespace Svc { void FatalHandlerComponentImpl::FatalReceive_handler( const NATIVE_INT_TYPE portNum, FwEventIdType Id) { + + // @todo REMOVE FOR DEBUG PURPOSE + if(Id == 0x16a) { // HLTH_PING_LATE - when EPS not connected + return; + } + // for **nix, delay then exit with error code Fw::Logger::logMsg("============= FATAL event 0x%x handled ============= \n",(U32)Id,0,0,0,0,0); (void)Os::Task::delay(1000); From bca9dde6543c6db2ea435cc45698c43c476803dd Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Fri, 22 Jan 2021 11:04:02 +0100 Subject: [PATCH 21/29] Add service ID in PUS logs --- Svc/GroundInterface/GroundInterface.cpp | 16 ++++++++-------- Svc/TlmChan/TlmChanImpl.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 60b8132b11d..67fa2e3de44 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -151,7 +151,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( U16 po_len; po_result_t po_res = PO_ERR; - // printf("[PUS] Housekeeping received : %u (0x%02X)\n", id, id); + // printf("[PUS3] Housekeeping received : %u (0x%02X)\n", id, id); PO_STACK_MUTEX.lock(); @@ -160,7 +160,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( case 0x29: // (41) PR_NumPings val.deserialize(tlmVal); PR_NumPings = tlmVal; - printf("[PUS] Housekeeping PR_NumPings received : %u \n", tlmVal); + printf("[PUS3] Housekeeping PR_NumPings received : %u \n", tlmVal); // Trigger PUS 3 Service provider to generate TM[3,25] po_triggerPus3(); break; @@ -175,7 +175,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( if(po_len > 0) { buffer.setData(po_buf); buffer.setSize(po_len); - printf("[PUS] Send report\n"); + printf("[PUS3] Send report\n"); write_out(0, buffer); } //*/ @@ -203,7 +203,7 @@ void GroundInterfaceComponentImpl::eventReport_handler( po_result_t po_res = PO_ERR; pus5_evtId_t po_pus5_eventId = PUS5_EVT_HIGH; // default value - // printf("[PUS] Event received : %u (0x%02X)\n", id, id); + // printf("[PUS5] Event received : %u (0x%02X)\n", id, id); /** ---- PUS Service 5 severity level ---- @@ -263,9 +263,9 @@ void GroundInterfaceComponentImpl::eventReport_handler( if(po_res != PO_SUCCESS) { // PO_ERR_LOWSPACE 2 No space to store input data if too small if (po_res == 2) { - printf("=== [PUS] EVT - To long frame (%u)- Not send\n", po_len); + printf("=== [PUS5] To long frame (%u)- Not send\n", po_len); } else { - printf("=== [PUS] EVT - po_pus5tm po error: %u\n", po_res); + printf("=== [PUS5] po_pus5tm po error: %u\n", po_res); } return; } @@ -275,9 +275,9 @@ void GroundInterfaceComponentImpl::eventReport_handler( if(po_res != PO_SUCCESS) { if (po_res == 2) { - printf("=== [PUS] EVT - To long frame (%u)- Not send\n", po_len); + printf("=== [PUS5] To long frame (%u)- Not send\n", po_len); } else { - printf("=== [PUS] EVT - po_frame po error: %u\n", po_res); + printf("=== [PUS5] po_frame po error: %u\n", po_res); } return; } diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index baf585cc71a..5a461b37ff4 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -158,7 +158,7 @@ namespace Svc { if(po_len > 0) { // @todo Remove - Temporary if(po_len > FW_COM_BUFFER_MAX_SIZE) { - printf("=== [PUS] TLM - To long frame (%u)- Not send\n", po_len); + printf("=== [PUS3] TLM - To long frame (%u)- Not send\n", po_len); return; } FW_ASSERT(po_len <= FW_COM_BUFFER_MAX_SIZE); From c58b5b136ab23566c06e75cb699c4db1fd36249d Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Fri, 22 Jan 2021 17:54:01 +0100 Subject: [PATCH 22/29] Change log format to hex --- Svc/ActiveTextLogger/ActiveTextLoggerImpl.cpp | 4 ++-- Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp | 2 +- Svc/TlmChan/TlmChanImpl.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Svc/ActiveTextLogger/ActiveTextLoggerImpl.cpp b/Svc/ActiveTextLogger/ActiveTextLoggerImpl.cpp index db4f26c0109..e77c5eae92c 100644 --- a/Svc/ActiveTextLogger/ActiveTextLoggerImpl.cpp +++ b/Svc/ActiveTextLogger/ActiveTextLoggerImpl.cpp @@ -94,7 +94,7 @@ namespace Svc { stat = snprintf(textStr, FW_INTERNAL_INTERFACE_STRING_MAX_SIZE, - "EVENT: (%d) (%04d-%02d-%02dT%02d:%02d:%02d.%03u) %s: %s\n", + "EVENT: (0x%x) (%04d-%02d-%02dT%02d:%02d:%02d.%03u) %s: %s\n", id, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,tm.tm_sec,timeTag.getUSeconds(), severityString,text.toChar()); @@ -103,7 +103,7 @@ namespace Svc { stat = snprintf(textStr, FW_INTERNAL_INTERFACE_STRING_MAX_SIZE, - "EVENT: (%d) (%d:%d,%d) %s: %s\n", + "EVENT: (0x%x) (%d:%d,%d) %s: %s\n", id,timeTag.getTimeBase(),timeTag.getSeconds(),timeTag.getUSeconds(),severityString,text.toChar()); } diff --git a/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp b/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp index 5fbc041dada..50634aa5723 100644 --- a/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp +++ b/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp @@ -43,7 +43,7 @@ namespace Svc { severityString = "SEVERITY ERROR"; break; } - Fw::Logger::logMsg("EVENT: (%d) (%d:%d,%d) %s: %s\n", + Fw::Logger::logMsg("EVENT: (0x%x) (%d:%d,%d) %s: %s\n", id, timeTag.getTimeBase(), timeTag.getSeconds(), timeTag.getUSeconds(), reinterpret_cast(severityString), reinterpret_cast(text.toChar())); } diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index 5a461b37ff4..436eca996a3 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -139,7 +139,7 @@ namespace Svc { // F' variables U32 tlmVal; - + // PUSOpen variables U8 po_buf[4096]; // @todo use definition U16 po_len; @@ -162,7 +162,7 @@ namespace Svc { return; } FW_ASSERT(po_len <= FW_COM_BUFFER_MAX_SIZE); - printf("TLM: (%u) Send report\n", po_len); + printf("TLM: Send report (%u)\n", po_len); Fw::ComBuffer m_comBuffer(po_buf, po_len); //!< Com buffer for sending event buffers this->PktSend_out(0,m_comBuffer,0); } From 02b05b6ec075b5b2d922814f5901154a279bb9c6 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Fri, 22 Jan 2021 19:24:33 +0100 Subject: [PATCH 23/29] Remove comment for Lib folder in .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b961cb951ac..4153d42d9e1 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,4 @@ GTestBase.* **/DefaultDict/serializable/* # Clone CHESS-mission/pusopen as "Lib" in fprime root - Due to license restriction with PUSOpen -#Lib # disable to allow VSCode to index Lib file \ No newline at end of file +Lib # disable to allow VSCode to index Lib file \ No newline at end of file From 68cefc166b78a74f4a6b52d3a83cc6bef5dc7813 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Fri, 22 Jan 2021 19:56:59 +0100 Subject: [PATCH 24/29] Test for getting frame faster --- .../PingReceiverComponentImpl.cpp | 2 +- Svc/GroundInterface/GroundInterface.cpp | 100 ++++++------------ Svc/TlmChan/TlmChanImpl.cpp | 15 ++- 3 files changed, 40 insertions(+), 77 deletions(-) diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.cpp b/Ref/PingReceiver/PingReceiverComponentImpl.cpp index a3e441e3fe2..b7d46deb2ec 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.cpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.cpp @@ -52,7 +52,7 @@ namespace Ref { U32 key ) { - //this->log_DIAGNOSTIC_PR_PingReceived(key); + this->log_DIAGNOSTIC_PR_PingReceived(key); this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); if (not this->m_inhibitPings) { PingOut_out(0,key); diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 67fa2e3de44..f7eee3e4dd8 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -14,7 +14,7 @@ #include #include #include -#include "Fw/Types/BasicTypes.hpp" +#include #include #ifdef _PUS @@ -138,48 +138,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( Fw::Time &timeTag, Fw::TlmBuffer &val ) { -#ifdef _PUS - /*/ F' variables -- Directly done in TlmChan TlmRecvHandler - Fw::Buffer buffer; - U32 tlmVal; - - Fw::TlmPacket m_tlmPacket; //!< Packet buffer for assembling tlm packets - Fw::ComBuffer m_comBuffer; //!< Com buffer for sending event buffers - - // PUSOpen variables - U8 po_buf[4096]; // @todo use definition - U16 po_len; - po_result_t po_res = PO_ERR; - - // printf("[PUS3] Housekeeping received : %u (0x%02X)\n", id, id); - - PO_STACK_MUTEX.lock(); - - // Sample - In the future serialize id and TlmBuffer - switch(id) { - case 0x29: // (41) PR_NumPings - val.deserialize(tlmVal); - PR_NumPings = tlmVal; - printf("[PUS3] Housekeeping PR_NumPings received : %u \n", tlmVal); - // Trigger PUS 3 Service provider to generate TM[3,25] - po_triggerPus3(); - break; - } - - // Retrieve created TM[3,25] byte stream from PUSopen stack and send it - po_res = po_frame(po_buf, &po_len); - - PO_STACK_MUTEX.unLock(); - - // If a report has been generated, send it - if(po_len > 0) { - buffer.setData(po_buf); - buffer.setSize(po_len); - printf("[PUS3] Send report\n"); - write_out(0, buffer); - } - //*/ -#endif // defined _PUS + // deprecated } void GroundInterfaceComponentImpl::eventReport_handler( @@ -252,8 +211,6 @@ void GroundInterfaceComponentImpl::eventReport_handler( FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); //*/ - PO_STACK_MUTEX.lock(); - // Send TM[5,x] with F' event ID = x po_res = po_pus5tm( po_pus5_eventId, // event ID PUS[5, x] @@ -261,31 +218,33 @@ void GroundInterfaceComponentImpl::eventReport_handler( GS_APID); // destination APID (GS) if(po_res != PO_SUCCESS) { - // PO_ERR_LOWSPACE 2 No space to store input data if too small - if (po_res == 2) { - printf("=== [PUS5] To long frame (%u)- Not send\n", po_len); - } else { - printf("=== [PUS5] po_pus5tm po error: %u\n", po_res); - } - return; + printf("=== [PUS5] po_pus5tm po error: %u\n", po_res); } - // Retrieve created TM[5,x] byte stream from PUSopen stack and send it - po_res = po_frame(po_buf, &po_len); + while(1) { + PO_STACK_MUTEX.lock(); - if(po_res != PO_SUCCESS) { - if (po_res == 2) { - printf("=== [PUS5] To long frame (%u)- Not send\n", po_len); - } else { - printf("=== [PUS5] po_frame po error: %u\n", po_res); - } return; - } + po_res = po_frame(po_buf, &po_len); - PO_STACK_MUTEX.unLock(); + PO_STACK_MUTEX.unLock(); + + if(po_res != PO_SUCCESS) { + if (po_res == PO_ERR_NODATA) { + return; + } else { + printf("=== [PUS] po_frame po error: %u\n", po_res); + } + return; + } + + if(po_len > 0) { + //printf("Send\n"); + buffer.setData(po_buf); + buffer.setSize(po_len); + write_out(0, buffer); + } + } - buffer.setData(po_buf); - buffer.setSize(po_len); - write_out(0, buffer); #endif // defined _PUS } @@ -408,7 +367,7 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { // Transmission buffer U8 buf[4096]; // @todo use definition U16 len; - + PO_STACK_MUTEX.lock(); // Push received data byte-by-byte into PUSopen(R) stack @@ -422,14 +381,19 @@ void GroundInterfaceComponentImpl::processPUS(Fw::Buffer& buffer) { // Forward TC[x,y] to PUS x po_triggerPus1(); + // Retrieve potentially created TM[17,x] byte stream from PUSopen(R) stack and send it po_frame(buf, &len); PO_STACK_MUTEX.unLock(); - //printf("[PUS] size buf %u\n",len); + + /*/ + printf("[PUS] size buf %u\n",len); for(int i = 0;i 0) { printf("[PUS] return data \n"); extBuff.setSize(len); diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index 436eca996a3..a67f751a23b 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -101,11 +101,10 @@ namespace Svc { } void TlmChanImpl::Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) { - - // Only write packets if connected - if (not this->isConnected_PktSend_OutputPort(0)) { - return; - } + // Only write packets if connected + if (not this->isConnected_PktSend_OutputPort(0)) { + return; + } #ifdef _GDS @@ -158,7 +157,7 @@ namespace Svc { if(po_len > 0) { // @todo Remove - Temporary if(po_len > FW_COM_BUFFER_MAX_SIZE) { - printf("=== [PUS3] TLM - To long frame (%u)- Not send\n", po_len); + printf("=== [PUS3] TLM - To long frame (%u) - Not send\n", po_len); return; } FW_ASSERT(po_len <= FW_COM_BUFFER_MAX_SIZE); @@ -166,9 +165,9 @@ namespace Svc { Fw::ComBuffer m_comBuffer(po_buf, po_len); //!< Com buffer for sending event buffers this->PktSend_out(0,m_comBuffer,0); } -#endif - +#endif } + void TlmChanImpl::TlmRecv_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { // Compute index for entry NATIVE_UINT_TYPE index = this->doHash(id); From 906c3201ac12dc01172da2f440da75720036fe10 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Fri, 22 Jan 2021 20:36:20 +0100 Subject: [PATCH 25/29] Update PUSOpen mdb path --- Svc/GroundInterface/CMakeLists.txt | 12 +++++++----- Svc/TlmChan/CMakeLists.txt | 13 +++++++++---- Svc/TlmChan/TlmChanImpl.cpp | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Svc/GroundInterface/CMakeLists.txt b/Svc/GroundInterface/CMakeLists.txt index c61846483fd..61b6b0767e1 100644 --- a/Svc/GroundInterface/CMakeLists.txt +++ b/Svc/GroundInterface/CMakeLists.txt @@ -7,18 +7,20 @@ # Note: using PROJECT_NAME as EXECUTABLE_NAME #### +SET(PUSOPEN_PATH ${FPRIME_FRAMEWORK_PATH}/Lib) +SET(MDB_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../gs/mdb) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/GroundInterfaceComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/GroundInterface.cpp" - "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database + "${MDB_PATH}/pusopen_onboard_mdb.c" # PUSOpen mission database ) set(MOD_DEPS "Utils/Types") register_fprime_module() add_definitions(-D_LINUB1804_GCC750) -include_directories(../../Lib/Includes) -find_library(PUSOPEN pusopen ../../Lib/lib) -# PUSOPEN /home/jonathan/tm/CHESS/05_FS/fprime/Lib/lib/libpusopen.a found +include_directories(${PUSOPEN_PATH}/Includes) +find_library(PUSOPEN pusopen ${PUSOPEN_PATH}/lib) target_link_libraries(Svc_GroundInterface ${PUSOPEN}) # Rules based unit testing @@ -31,7 +33,7 @@ set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestMain.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/GroundInterfaceRules.cpp" - "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database + "${MDB_PATH}/pusopen_onboard_mdb.c" # PUSOpen mission database ) # Test Includes for this UT register_fprime_ut() diff --git a/Svc/TlmChan/CMakeLists.txt b/Svc/TlmChan/CMakeLists.txt index 55997d876a0..504906ae15e 100644 --- a/Svc/TlmChan/CMakeLists.txt +++ b/Svc/TlmChan/CMakeLists.txt @@ -6,25 +6,30 @@ # # Note: using PROJECT_NAME as EXECUTABLE_NAME #### +SET(PUSOPEN_PATH ${FPRIME_FRAMEWORK_PATH}/Lib) +SET(MDB_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../gs/mdb) + set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/TlmChanComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/TlmChanImpl.cpp" - "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database + "${MDB_PATH}/pusopen_onboard_mdb.c" # PUSOpen mission database ) register_fprime_module() add_definitions(-D_LINUB1804_GCC750) -include_directories(../../Lib/Includes) -find_library(PUSOPEN pusopen ../../Lib/lib) +include_directories(${MDB_PATH}) # hk_param.h +include_directories(${PUSOPEN_PATH}/Includes) +find_library(PUSOPEN pusopen ${PUSOPEN_PATH}/lib) target_link_libraries(Svc_TlmChan ${PUSOPEN}) + ### UTs ### set(UT_SOURCE_FILES "${FPRIME_FRAMEWORK_PATH}/Svc/TlmChan/TlmChanComponentAi.xml" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TlmChanTester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/TlmChanImplTester.cpp" - "${CMAKE_CURRENT_LIST_DIR}/../../Lib/mdb/pusopen_onboard_mdb.c" # PUSOpen mission database + "${MDB_PATH}/pusopen_onboard_mdb.c" # PUSOpen mission database ) register_fprime_ut() diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index a67f751a23b..fd6d7369267 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -15,7 +15,7 @@ #include #include #include -#include "../../Lib/mdb/hk_param.h" +#include "hk_param.h" #include #include From 1f76f187987edb1b51ce80d5bce275d96672c030 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Wed, 3 Feb 2021 11:30:18 +0100 Subject: [PATCH 26/29] Fix seqgen with Python3 --- Gds/bin/helpers/run_tool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gds/bin/helpers/run_tool.sh b/Gds/bin/helpers/run_tool.sh index e7b78e8cd81..45b34bfd019 100755 --- a/Gds/bin/helpers/run_tool.sh +++ b/Gds/bin/helpers/run_tool.sh @@ -34,4 +34,4 @@ export OUTPUT_DIR="`make -f ${BUILD_ROOT}/mk/makefiles/build_vars.mk BUILD=$NATI echo "OUTPUT_DIR: ${OUTPUT_DIR}" export PYTHONPATH="${BUILD_ROOT}/Fw/Python/src:${BUILD_ROOT}/Gds/src" -python -m fprime_gds.common.tools."${TOOL}" "$@" +python3 -m fprime_gds.common.tools."${TOOL}" "$@" From 56b0eafd7a7e1d7bc668154e95ac14016e38a693 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Wed, 3 Feb 2021 11:32:12 +0100 Subject: [PATCH 27/29] Remove ping receiver log --- Ref/PingReceiver/PingReceiverComponentImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.cpp b/Ref/PingReceiver/PingReceiverComponentImpl.cpp index b7d46deb2ec..a3e441e3fe2 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.cpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.cpp @@ -52,7 +52,7 @@ namespace Ref { U32 key ) { - this->log_DIAGNOSTIC_PR_PingReceived(key); + //this->log_DIAGNOSTIC_PR_PingReceived(key); this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); if (not this->m_inhibitPings) { PingOut_out(0,key); From 14f37cd1baea8cd65009abb5f97e2a9cabbc2322 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Wed, 24 Feb 2021 10:59:03 +0100 Subject: [PATCH 28/29] Stable demo --- .../PingReceiverComponentImpl.cpp | 2 +- Svc/ActiveLogger/ActiveLoggerImpl.cpp | 3 ++- Svc/GroundInterface/GroundInterface.cpp | 20 +++++++++++-------- Svc/GroundInterface/GroundInterface.hpp | 2 +- Svc/TlmChan/TlmChanImpl.cpp | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Ref/PingReceiver/PingReceiverComponentImpl.cpp b/Ref/PingReceiver/PingReceiverComponentImpl.cpp index a3e441e3fe2..b7d46deb2ec 100644 --- a/Ref/PingReceiver/PingReceiverComponentImpl.cpp +++ b/Ref/PingReceiver/PingReceiverComponentImpl.cpp @@ -52,7 +52,7 @@ namespace Ref { U32 key ) { - //this->log_DIAGNOSTIC_PR_PingReceived(key); + this->log_DIAGNOSTIC_PR_PingReceived(key); this->tlmWrite_PR_NumPings(this->m_pingsRecvd++); if (not this->m_inhibitPings) { PingOut_out(0,key); diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index 9badea537bd..1d07f6828e1 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -64,7 +64,8 @@ namespace Svc { } void ActiveLoggerImpl::LogRecv_handler(NATIVE_INT_TYPE portNum, FwEventIdType id, Fw::Time &timeTag, Fw::LogSeverity severity, Fw::LogBuffer &args) { - + if (id != 0x2a) + return; // make sure ID is not zero. Zero is reserved for ID filter. FW_ASSERT(id != 0); diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index f7eee3e4dd8..8f63622520a 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -26,6 +26,10 @@ extern Svc::GroundInterfaceComponentImpl groundIf; extern Os::Mutex PO_STACK_MUTEX; #endif // defined _PUS +#ifndef _GDS +#define _PUS // for VSCode synthax, will cause compiler warning for redefinition +#endif + namespace Svc { const U32 GroundInterfaceComponentImpl::MAX_DATA_SIZE = 2048; @@ -138,7 +142,7 @@ void GroundInterfaceComponentImpl::hkReport_handler( Fw::Time &timeTag, Fw::TlmBuffer &val ) { - // deprecated + // deprecated (defined by F') } void GroundInterfaceComponentImpl::eventReport_handler( @@ -210,6 +214,8 @@ void GroundInterfaceComponentImpl::eventReport_handler( Fw::SerializeStatus stat = m_logPacket.serialize(m_comBuffer); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast(stat)); //*/ + + PO_STACK_MUTEX.lock(); // Send TM[5,x] with F' event ID = x po_res = po_pus5tm( @@ -221,20 +227,16 @@ void GroundInterfaceComponentImpl::eventReport_handler( printf("=== [PUS5] po_pus5tm po error: %u\n", po_res); } - while(1) { - PO_STACK_MUTEX.lock(); - + while(1) { // @todo avoid endless loop po_res = po_frame(po_buf, &po_len); - PO_STACK_MUTEX.unLock(); - if(po_res != PO_SUCCESS) { if (po_res == PO_ERR_NODATA) { - return; + break; } else { printf("=== [PUS] po_frame po error: %u\n", po_res); } - return; + break; } if(po_len > 0) { @@ -245,6 +247,8 @@ void GroundInterfaceComponentImpl::eventReport_handler( } } + PO_STACK_MUTEX.unLock(); + #endif // defined _PUS } diff --git a/Svc/GroundInterface/GroundInterface.hpp b/Svc/GroundInterface/GroundInterface.hpp index ab5e0915697..29624fce3aa 100644 --- a/Svc/GroundInterface/GroundInterface.hpp +++ b/Svc/GroundInterface/GroundInterface.hpp @@ -77,7 +77,7 @@ namespace Svc { Fw::Time &timeTag, /*!< Time Tag*/ Fw::TlmBuffer &val /*!< Buffer containing serialized telemetry value*/ ); - + //! Handler implementation for fileDownlinkBufferSendIn //! void fileDownlinkBufferSendIn_handler( diff --git a/Svc/TlmChan/TlmChanImpl.cpp b/Svc/TlmChan/TlmChanImpl.cpp index fd6d7369267..6f30417bac1 100644 --- a/Svc/TlmChan/TlmChanImpl.cpp +++ b/Svc/TlmChan/TlmChanImpl.cpp @@ -144,12 +144,12 @@ namespace Svc { U16 po_len; po_result_t po_res = PO_ERR; + PO_STACK_MUTEX.lock(); + // Trigger PUS service 3 to check is report // has to generated po_triggerPus3(); - PO_STACK_MUTEX.lock(); - po_res = po_frame(po_buf, &po_len); PO_STACK_MUTEX.unLock(); From 055393f3c92464f126d4ad6d7fa21b1e55b5c8d3 Mon Sep 17 00:00:00 2001 From: Jonathan Michel Date: Thu, 25 Feb 2021 17:05:35 +0100 Subject: [PATCH 29/29] Remove custom code for demo --- Svc/ActiveLogger/ActiveLoggerImpl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index 1d07f6828e1..7dabc91fc18 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -64,8 +64,10 @@ namespace Svc { } void ActiveLoggerImpl::LogRecv_handler(NATIVE_INT_TYPE portNum, FwEventIdType id, Fw::Time &timeTag, Fw::LogSeverity severity, Fw::LogBuffer &args) { - if (id != 0x2a) - return; + // Filter event for demo + //if (id != 0x2a) + // return; + // make sure ID is not zero. Zero is reserved for ID filter. FW_ASSERT(id != 0);