# HG changeset patch # User Alexis Jeandet # Date 2018-08-31 13:09:14 # Node ID bd1252670981361939ed2a1c3febc94247019956 # Parent c56e87012e2b445043a3e686a34e8c00b28e1514 Removed all remaining unused macros and fixed bug There was two numbers to set the FSW number of tasks NB_OF_TASKS and CONFIGURE_MAXIMUM_TASKS while CONFIGURE_MAXIMUM_TASKS = NB_OF_TASKS + 1 diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,2 +1,2 @@ 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters -0adeb6c86feb96a126ce48641604949b87c70481 header/lfr_common_headers +042275d1388a0f360073a0d85bf50d128f4b8cfc header/lfr_common_headers diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,7 +64,7 @@ option(FSW_debug_tch "?" OFF) set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) -set(SW_VERSION_N4 "19" CACHE STRING "Choose N4 FSW Version." FORCE) +set(SW_VERSION_N4 "20" CACHE STRING "Choose N4 FSW Version." FORCE) if(FSW_verbose) add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) @@ -94,6 +94,8 @@ if(FSW_debug_tch) add_definitions(-DDEBUG_TCH) endif() + + add_definitions(-DMSB_FIRST_TCH) add_definitions(-DSWVERSION=-1-0) @@ -102,6 +104,7 @@ add_definitions(-DSW_VERSION_N2=${SW_VER add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) + add_executable(fsw ${SOURCES}) if(fix-b2bst) diff --git a/src/fsw_globals.c b/src/fsw_globals.c --- a/src/fsw_globals.c +++ b/src/fsw_globals.c @@ -22,13 +22,13 @@ #include "fsw_params.h" #include "fsw_params_wf_handler.h" -#define NB_OF_TASKS 20 + #define NB_OF_MISC_NAMES 5 // RTEMS GLOBAL VARIABLES rtems_name misc_name[NB_OF_MISC_NAMES] = {0}; -rtems_name Task_name[NB_OF_TASKS] = {0}; /* array of task names */ -rtems_id Task_id[NB_OF_TASKS] = {0}; /* array of task ids */ +rtems_name Task_name[CONFIGURE_MAXIMUM_TASKS-1] = {0}; /* array of task names */ +rtems_id Task_id[CONFIGURE_MAXIMUM_TASKS-1] = {0}; /* array of task ids */ rtems_name timecode_timer_name = 0; rtems_id timecode_timer_id = RTEMS_ID_NONE; rtems_name name_hk_rate_monotonic = 0; // name of the HK rate monotonic diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -24,43 +24,26 @@ /* configuration information */ -#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_MAXIMUM_TASKS 23 // number of tasks concurrently active including INIT -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) -#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 -#define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 -#define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) -#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) -#define CONFIGURE_MAXIMUM_DRIVERS 16 -#define CONFIGURE_MAXIMUM_PERIODS 6 // [hous] [load] [avgv] -#define CONFIGURE_MAXIMUM_TIMERS 6 // [spiq] [link] [spacewire_reset_link] -#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 -#ifdef PRINT_STACK_REPORT - #define CONFIGURE_STACK_CHECKER_ENABLED -#endif +#include #include /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ #ifdef RTEMS_DRVMGR_STARTUP -#ifdef LEON3 -/* Add Timer and UART Driver */ + #ifdef LEON3 + /* Add Timer and UART Driver */ -#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER -#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER -#endif + #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER + #endif -#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART -#endif + #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART + #endif -#endif -#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ - -#include + #endif + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ + #include #endif #include "fsw_init.h" @@ -790,7 +773,7 @@ int start_all_tasks( void ) // start all return status; } -rtems_status_code create_message_queues( void ) // create the two message queues used in the software +rtems_status_code create_message_queues( void ) // create the five message queues used in the software { rtems_status_code status_recv; rtems_status_code status_send; @@ -950,6 +933,11 @@ rtems_status_code get_message_queue_id_p return status; } +/** + * @brief update_queue_max_count returns max(fifo_size_max, pending_messages + 1) + * @param queue_id + * @param fifo_size_max + */ void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) { u_int32_t count; @@ -974,6 +962,20 @@ void update_queue_max_count( rtems_id qu } } +/** + * @brief init_ring initializes given ring buffer + * @param ring array of nodes to initialize + * @param nbNodes number of node in the ring buffer + * @param buffer memory space given to the ring buffer + * @param bufferSize size of the whole ring buffer memory space + * + * @details This function creates a circular buffer from a given number of nodes and a given memory space. It first sets all nodes attributes to thier defaults values + * and associates a portion of the given memory space with each node. Then it connects each nodes to build a circular buffer. + * + * Each node capacity will be bufferSize/nbNodes. + * + * https://en.wikipedia.org/wiki/Circular_buffer + */ void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) { unsigned char i; diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -281,11 +281,11 @@ rtems_task send_task( rtems_task_argumen { spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); } - else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) + else if ( (sid==SID_NORM_SWF_F0) || (sid==SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) { spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); } - else if ( (sid==SID_NORM_CWF_F3) ) + else if (sid==SID_NORM_CWF_F3) { spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); } @@ -301,7 +301,7 @@ rtems_task send_task( rtems_task_argumen { spw_send_asm_f2( incomingRingNodePtr, &headerASM ); } - else if ( sid==TM_CODE_K_DUMP ) + else if (sid==TM_CODE_K_DUMP) { spw_send_k_dump( incomingRingNodePtr ); } @@ -620,23 +620,6 @@ void spacewire_read_statistics( void ) // clear the counters status = ioctl( fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS ); -// typedef struct { -// unsigned int tx_link_err; // NOT IN HK -// unsigned int rx_rmap_header_crc_err; // NOT IN HK -// unsigned int rx_rmap_data_crc_err; // NOT IN HK -// unsigned int rx_eep_err; -// unsigned int rx_truncated; -// unsigned int parity_err; -// unsigned int escape_err; -// unsigned int credit_err; -// unsigned int write_sync_err; -// unsigned int disconnect_err; -// unsigned int early_ep; -// unsigned int invalid_address; -// unsigned int packets_sent; -// unsigned int packets_received; -// } spw_stats; - // rx_eep_err grspw_stats.rx_eep_err = grspw_stats.rx_eep_err + current.rx_eep_err; // rx_truncated @@ -685,23 +668,6 @@ void spacewire_get_last_error( void ) coarseTime = time_management_regs->coarse_time; fineTime = time_management_regs->fine_time; - // typedef struct { - // unsigned int tx_link_err; // NOT IN HK - // unsigned int rx_rmap_header_crc_err; // NOT IN HK - // unsigned int rx_rmap_data_crc_err; // NOT IN HK - // unsigned int rx_eep_err; - // unsigned int rx_truncated; - // unsigned int parity_err; - // unsigned int escape_err; - // unsigned int credit_err; - // unsigned int write_sync_err; - // unsigned int disconnect_err; - // unsigned int early_ep; - // unsigned int invalid_address; - // unsigned int packets_sent; - // unsigned int packets_received; - // } spw_stats; - // tx_link_err *** no code associated to this field // rx_rmap_header_crc_err *** LE *** in HK if (previous.rx_rmap_header_crc_err != current.rx_rmap_header_crc_err) @@ -1539,6 +1505,11 @@ void spw_send_asm_f1( ring_node *ring_no } } +/** + * @brief spw_send_asm_f2 Sends an ASM packet at F2 over spacewire + * @param ring_node_to_send node pointing to the actual buffer to send + * @param header + */ void spw_send_asm_f2( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ) { @@ -1606,6 +1577,10 @@ void spw_send_asm_f2( ring_node *ring_no } } +/** + * @brief spw_send_k_dump Sends k coefficients dump packet over spacewire + * @param ring_node_to_send node pointing to the actual buffer to send + */ void spw_send_k_dump( ring_node *ring_node_to_send ) { rtems_status_code status; diff --git a/src/tc_load_dump_parameters.c b/src/tc_load_dump_parameters.c --- a/src/tc_load_dump_parameters.c +++ b/src/tc_load_dump_parameters.c @@ -445,7 +445,6 @@ int action_dump_kcoefficients(ccsdsTelec { kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; bin = freq; -// printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); for ( coeff=0; coeff