##// END OF EJS Templates
Ignore doc files...
paul -
r46:72fea9e87fcb default
parent child
Show More
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Oct 18 15:44:51 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 24 15:59:05 2013
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,7 +10,7
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=16 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=16 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,7 +1,7
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 CONFIG += console verbose
4 CONFIG += console verbose cpu_usage_report
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.0, 2013-10-18T15:44:56. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-24T06:53:47. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -119,6 +119,20
119 #define FAIL_DETECTED 42003 // 0xa4 0x13
119 #define FAIL_DETECTED 42003 // 0xa4 0x13
120 #define CORRUPTED 42005 // 0xa4 0x15
120 #define CORRUPTED 42005 // 0xa4 0x15
121
121
122 #define SID_TC_DEFAULT 0 // the default SID for TC sent to the LFR
123 #define SID_TC_GROUND 0
124 #define SID_TC_MISSION_TIMELINE 110
125 #define SID_TC_TC_SEQUENCES 111
126 #define SID_TC_RECOVERY_ACTION_CMD 112
127 #define SID_TC_BACKUP_MISSION_TIMELINE 113
128 #define SID_TC_DIRECT_CMD 120
129 #define SID_TC_SPARE_GRD_SRC1 121
130 #define SID_TC_SPARE_GRD_SRC2 122
131 #define SID_TC_OBCP 15
132 #define SID_TC_SYSTEM_CONTROL 14
133 #define SID_TC_AOCS 11
134 #define SID_TC_RPW_INTERNAL 254
135
122 // TM SID
136 // TM SID
123 #define SID_HK 1
137 #define SID_HK 1
124 #define SID_PARAMETER_DUMP 10
138 #define SID_PARAMETER_DUMP 10
@@ -30,14 +30,13 extern unsigned short sequenceCounters[S
30 rtems_task Init( rtems_task_argument argument);
30 rtems_task Init( rtems_task_argument argument);
31
31
32 // OTHER functions
32 // OTHER functions
33 int create_names( void );
33 void create_names( void );
34 rtems_status_code create_message_queues( void );
34 int create_all_tasks( void );
35 int create_all_tasks( void );
35 int start_all_tasks( void );
36 int start_all_tasks( void );
36 rtems_status_code create_message_queues( void );
37 int start_recv_send_tasks( void );
37 //
38 //
38 void init_parameter_dump( void );
39 void init_local_mode_parameters( void );
39 void init_local_mode_parameters( void );
40 void init_housekeeping_parameters( void );
41
40
42 extern int rtems_cpu_usage_report( void );
41 extern int rtems_cpu_usage_report( void );
43 extern int rtems_cpu_usage_reset( void );
42 extern int rtems_cpu_usage_reset( void );
@@ -8,7 +8,7
8 #include "fsw_params.h"
8 #include "fsw_params.h"
9 #include "fsw_spacewire.h"
9 #include "fsw_spacewire.h"
10
10
11 rtems_name HK_name; // name of the HK rate monotonic
11 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
12 rtems_id HK_id; // id of the HK rate monotonic period
12 rtems_id HK_id; // id of the HK rate monotonic period
13
13
14 extern rtems_name misc_name[5];
14 extern rtems_name misc_name[5];
@@ -30,4 +30,6 rtems_task stat_task( rtems_task_argumen
30 rtems_task hous_task( rtems_task_argument argument );
30 rtems_task hous_task( rtems_task_argument argument );
31 rtems_task dumb_task( rtems_task_argument unused );
31 rtems_task dumb_task( rtems_task_argument unused );
32
32
33 void init_housekeeping_parameters( void );
34
33 #endif // FSW_MISC_H_INCLUDED
35 #endif // FSW_MISC_H_INCLUDED
@@ -35,11 +35,11
35 #define DEFAULT_SY_LFR_COMMON0 0x00
35 #define DEFAULT_SY_LFR_COMMON0 0x00
36 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
36 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
37 // NORM
37 // NORM
38 #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample
38 #define SY_LFR_N_SWF_L 2048 // nb sample
39 #define DEFAULT_SY_LFR_N_SWF_P 16 // sec
39 #define SY_LFR_N_SWF_P 300 // sec
40 #define DEFAULT_SY_LFR_N_ASM_P 16 // sec
40 #define SY_LFR_N_ASM_P 3600 // sec
41 #define DEFAULT_SY_LFR_N_BP_P0 4 // sec
41 #define SY_LFR_N_BP_P0 4 // sec
42 #define DEFAULT_SY_LFR_N_BP_P1 20 // sec
42 #define SY_LFR_N_BP_P1 20 // sec
43 #define MIN_DELTA_SNAPSHOT 16 // sec
43 #define MIN_DELTA_SNAPSHOT 16 // sec
44 // BURST
44 // BURST
45 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
45 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
@@ -52,8 +52,13
52 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
52 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
53 // ADDITIONAL PARAMETERS
53 // ADDITIONAL PARAMETERS
54 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
54 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
55 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
55 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
56 // STATUS WORD
57 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
58 #define DEFAULT_STATUS_WORD_BYTE1 0x00
56 //
59 //
60 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
61 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
57 //****************************
62 //****************************
58
63
59 //*****************************
64 //*****************************
@@ -117,11 +122,13
117 #define TASKID_CWF2 13
122 #define TASKID_CWF2 13
118 #define TASKID_CWF1 14
123 #define TASKID_CWF1 14
119 #define TASKID_SEND 15
124 #define TASKID_SEND 15
125 #define TASKID_WTDG 16
120
126
121 #define TASK_PRIORITY_SPIQ 5
127 #define TASK_PRIORITY_SPIQ 5
122 #define TASK_PRIORITY_SMIQ 10
128 #define TASK_PRIORITY_SMIQ 10
123 //
129 //
124 #define TASK_PRIORITY_RECV 20
130 #define TASK_PRIORITY_WTDG 20
131 //
125 #define TASK_PRIORITY_ACTN 30
132 #define TASK_PRIORITY_ACTN 30
126 //
133 //
127 #define TASK_PRIORITY_HOUS 40
134 #define TASK_PRIORITY_HOUS 40
@@ -129,8 +136,9
129 #define TASK_PRIORITY_CWF2 40
136 #define TASK_PRIORITY_CWF2 40
130 #define TASK_PRIORITY_WFRM 40
137 #define TASK_PRIORITY_WFRM 40
131 #define TASK_PRIORITY_CWF3 40
138 #define TASK_PRIORITY_CWF3 40
139 #define TASK_PRIORITY_SEND 40
132 //
140 //
133 #define TASK_PRIORITY_SEND 40
141 #define TASK_PRIORITY_RECV 50 // this priority prevents the blocking of of other tasks in case of link deconnexion
134 //
142 //
135 #define TASK_PRIORITY_AVF0 60
143 #define TASK_PRIORITY_AVF0 60
136 #define TASK_PRIORITY_BPF0 60
144 #define TASK_PRIORITY_BPF0 60
@@ -140,7 +148,7
140
148
141 #define ACTION_MSG_QUEUE_COUNT 10
149 #define ACTION_MSG_QUEUE_COUNT 10
142 #define ACTION_MSG_PKTS_COUNT 50
150 #define ACTION_MSG_PKTS_COUNT 50
143 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
151 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
144 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
152 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
145
153
146 #define QUEUE_RECV 0
154 #define QUEUE_RECV 0
@@ -3,8 +3,10
3
3
4 #define NB_BINS_PER_SM 128
4 #define NB_BINS_PER_SM 128
5 #define NB_VALUES_PER_SM 25
5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM (NB_BINS_PER_SM * NB_VALUES_PER_SM)
6 //#define TOTAL_SIZE_SM (NB_BINS_PER_SM * NB_VALUES_PER_SM)
7 #define SM_HEADER 4
7 //#define SM_HEADER 4
8 #define TOTAL_SIZE_SM 0
9 #define SM_HEADER 0
8
10
9 #define NB_BINS_COMPRESSED_SM_F0 11
11 #define NB_BINS_COMPRESSED_SM_F0 11
10 #define NB_BINS_COMPRESSED_SM_F1 13
12 #define NB_BINS_COMPRESSED_SM_F1 13
@@ -21,15 +21,19 extern rtems_id Task_id[20];
21 rtems_task spiq_task( rtems_task_argument argument );
21 rtems_task spiq_task( rtems_task_argument argument );
22 rtems_task recv_task( rtems_task_argument unused );
22 rtems_task recv_task( rtems_task_argument unused );
23 rtems_task send_task( rtems_task_argument argument );
23 rtems_task send_task( rtems_task_argument argument );
24 rtems_task wtdg_task( rtems_task_argument argument );
24
25
25 int spacewire_configure_link( void );
26 int spacewire_open_link( void );
26 int spacewire_wait_for_link( void );
27 int spacewire_start_link( int fd );
28 int spacewire_configure_link(int fd );
29 int spacewire_reset_link( void );
27 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
30 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
28 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
31 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
29 void spacewire_compute_stats_offsets( void );
32 void spacewire_compute_stats_offsets( void );
30 void spacewire_update_statistics( void );
33 void spacewire_update_statistics( void );
31
34
32 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
35 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
36 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data );
33
37
34 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
38 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
35
39
@@ -15,6 +15,7 void GetCRCAsTwoBytes(unsigned char* dat
15 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC);
15 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC);
16 int tc_check_type( unsigned char packetType );
16 int tc_check_type( unsigned char packetType );
17 int tc_check_subtype( unsigned char packetType );
17 int tc_check_subtype( unsigned char packetType );
18 int tc_check_sid( unsigned char sid );
18 int tc_check_length( unsigned char packetType, unsigned int length );
19 int tc_check_length( unsigned char packetType, unsigned int length );
19 int tc_check_crc(ccsdsTelecommandPacket_t * TCPacket, unsigned int length , unsigned char *computed_CRC);
20 int tc_check_crc(ccsdsTelecommandPacket_t * TCPacket, unsigned int length , unsigned char *computed_CRC);
20
21
@@ -26,4 +26,6 int set_sy_lfr_n_asm_p( ccsdsTelecommand
26 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
26 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
27 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
27 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
28
28
29 void init_parameter_dump( void );
30
29 #endif // TC_LOAD_DUMP_PARAMETERS_H
31 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -31,7 +31,9 extern Packet_TM_LFR_PARAMETER_DUMP_t pa
31 extern struct param_local_str param_local;
31 extern struct param_local_str param_local;
32
32
33 extern rtems_name misc_name[5];
33 extern rtems_name misc_name[5];
34 extern rtems_name Task_name[20]; /* array of task ids */
34 extern rtems_id Task_id[20]; /* array of task ids */
35 extern rtems_id Task_id[20]; /* array of task ids */
36
35 extern unsigned char lfrCurrentMode;
37 extern unsigned char lfrCurrentMode;
36
38
37 rtems_isr waveforms_isr( rtems_vector_number vector );
39 rtems_isr waveforms_isr( rtems_vector_number vector );
@@ -72,6 +72,7 rtems_task Init( rtems_task_argument ign
72
72
73
73
74 rtems_status_code status;
74 rtems_status_code status;
75 rtems_status_code status_spw;
75 rtems_isr_entry old_isr_handler;
76 rtems_isr_entry old_isr_handler;
76
77
77 BOOT_PRINTF("\n\n\n\n\n")
78 BOOT_PRINTF("\n\n\n\n\n")
@@ -87,32 +88,67 rtems_task Init( rtems_task_argument ign
87 init_local_mode_parameters();
88 init_local_mode_parameters();
88 init_housekeeping_parameters();
89 init_housekeeping_parameters();
89
90
90 create_names(); // create all names
91 create_names(); // create all names
92 status = create_message_queues(); // create message queues
93 if (status != RTEMS_SUCCESSFUL)
94 {
95 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
96 }
91
97
92 create_message_queues();
98 status = create_all_tasks(); // create all tasks
93
94 status = create_all_tasks(); // create all tasks
95 if (status != RTEMS_SUCCESSFUL)
99 if (status != RTEMS_SUCCESSFUL)
96 {
100 {
97 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
101 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
98 }
102 }
99
103
104 // **************************
105 // <SPACEWIRE INITIALIZATION>
106 grspw_timecode_callback = &timecode_irq_handler;
107
108 status_spw = spacewire_open_link(); // (1) open the link
109 if ( status_spw != RTEMS_SUCCESSFUL )
110 {
111 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
112 }
113
114 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
115 {
116 status_spw = spacewire_configure_link( fdSPW );
117 if ( status_spw != RTEMS_SUCCESSFUL )
118 {
119 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
120 }
121 }
122
123 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
124 {
125 status_spw = spacewire_start_link( fdSPW );
126 if ( status_spw != RTEMS_SUCCESSFUL )
127 {
128 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
129 }
130 }
131 // </SPACEWIRE INITIALIZATION>
132 // ***************************
133
100 status = start_all_tasks(); // start all tasks
134 status = start_all_tasks(); // start all tasks
101 if (status != RTEMS_SUCCESSFUL)
135 if (status != RTEMS_SUCCESSFUL)
102 {
136 {
103 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
137 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
104 }
138 }
105
139
140 status = start_recv_send_tasks();
141 if ( status != RTEMS_SUCCESSFUL )
142 {
143 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
144 }
145
106 status = stop_current_mode(); // go in STANDBY mode
146 status = stop_current_mode(); // go in STANDBY mode
107 if (status != RTEMS_SUCCESSFUL)
147 if (status != RTEMS_SUCCESSFUL)
108 {
148 {
109 PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status)
149 PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status)
110 }
150 }
111
151
112 grspw_timecode_callback = &timecode_irq_handler;
113
114 spacewire_configure_link();
115
116 #ifdef GSA
152 #ifdef GSA
117 // mask IRQ lines
153 // mask IRQ lines
118 LEON_Mask_interrupt( IRQ_SM );
154 LEON_Mask_interrupt( IRQ_SM );
@@ -143,79 +179,30 rtems_task Init( rtems_task_argument ign
143 IRQ_SPARC_SM, spectral_matrices_isr_simu );
179 IRQ_SPARC_SM, spectral_matrices_isr_simu );
144 #endif
180 #endif
145
181
182 if ( status_spw != RTEMS_SUCCESSFUL )
183 {
184 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
185 if ( status != RTEMS_SUCCESSFUL ) {
186 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
187 }
188 }
189
146 BOOT_PRINTF("delete INIT\n")
190 BOOT_PRINTF("delete INIT\n")
147
191
148 status = rtems_task_delete(RTEMS_SELF);
192 status = rtems_task_delete(RTEMS_SELF);
149
193
150 }
194 }
151
195
152 void init_parameter_dump( void )
153 {
154 /** This function initialize the parameter_dump_packet global variable with default values.
155 *
156 */
157
158 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
159 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
160 parameter_dump_packet.reserved = CCSDS_RESERVED;
161 parameter_dump_packet.userApplication = CCSDS_USER_APP;
162 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
163 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
164 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
165 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
166 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
167 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
168 // DATA FIELD HEADER
169 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
170 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
171 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
172 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
173 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
174 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
175 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
176 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
177 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
178 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
179 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
180
181 //******************
182 // COMMON PARAMETERS
183 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
184 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
185
186 //******************
187 // NORMAL PARAMETERS
188 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8);
189 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L );
190 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8);
191 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P );
192 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8);
193 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P );
194 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0;
195 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1;
196
197 //*****************
198 // BURST PARAMETERS
199 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
200 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
201
202 //****************
203 // SBM1 PARAMETERS
204 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
205 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
206
207 //****************
208 // SBM2 PARAMETERS
209 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
210 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
211 }
212
213 void init_local_mode_parameters( void )
196 void init_local_mode_parameters( void )
214 {
197 {
215 /** This function initialize the param_local global variable with default values.
198 /** This function initialize the param_local global variable with default values.
216 *
199 *
217 */
200 */
218
201
202 unsigned int i;
203 unsigned int j;
204 unsigned int k;
205
219 // LOCAL PARAMETERS
206 // LOCAL PARAMETERS
220 set_local_sbm1_nb_cwf_max();
207 set_local_sbm1_nb_cwf_max();
221 set_local_sbm2_nb_cwf_max();
208 set_local_sbm2_nb_cwf_max();
@@ -227,32 +214,7 void init_local_mode_parameters( void )
227
214
228 reset_local_sbm1_nb_cwf_sent();
215 reset_local_sbm1_nb_cwf_sent();
229 reset_local_sbm2_nb_cwf_sent();
216 reset_local_sbm2_nb_cwf_sent();
230 }
231
217
232 void init_housekeeping_parameters( void )
233 {
234 /** This function initialize the housekeeping_packet global variable with default values.
235 *
236 */
237
238 unsigned int i = 0;
239 unsigned int j = 0;
240 unsigned int k = 0;
241 char *parameters;
242
243 parameters = (char*) &housekeeping_packet.lfr_status_word;
244 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
245 {
246 parameters[i] = 0x00;
247 }
248 // init status word
249 housekeeping_packet.lfr_status_word[0] = 0x00;
250 housekeeping_packet.lfr_status_word[1] = 0x00;
251 // init software version
252 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
253 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
254 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
255 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
256 // init sequence counters
218 // init sequence counters
257 for (i = 0; i<SEQ_CNT_NB_PID; i++)
219 for (i = 0; i<SEQ_CNT_NB_PID; i++)
258 {
220 {
@@ -264,10 +226,9 void init_housekeeping_parameters( void
264 }
226 }
265 }
227 }
266 }
228 }
267 updateLFRCurrentMode();
268 }
229 }
269
230
270 int create_names( void ) // create all names for tasks and queues
231 void create_names( void ) // create all names for tasks and queues
271 {
232 {
272 /** This function creates all RTEMS names used in the software for tasks and queues.
233 /** This function creates all RTEMS names used in the software for tasks and queues.
273 *
234 *
@@ -292,14 +253,13 int create_names( void ) // create all n
292 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
253 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
293 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
254 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
294 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
255 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
295
256 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
296 // rate monotonic period name
297 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
298
257
299 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', 'U', 'E', 'U' );
258 // rate monotonic period names
300 misc_name[QUEUE_SEND] = rtems_build_name( 'P', 'K', 'T', 'S' );
259 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
301
260
302 return RTEMS_SUCCESSFUL;
261 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
262 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
303 }
263 }
304
264
305 int create_all_tasks( void ) // create all tasks which run in the software
265 int create_all_tasks( void ) // create all tasks which run in the software
@@ -439,11 +399,39 int create_all_tasks( void ) // create a
439 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
399 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
440 );
400 );
441 }
401 }
402 if (status == RTEMS_SUCCESSFUL) // WTDG
403 {
404 status = rtems_task_create(
405 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
406 RTEMS_DEFAULT_MODES,
407 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
408 );
409 }
442
410
443 return status;
411 return status;
444 }
412 }
445
413
446 int start_all_tasks( void )
414 int start_recv_send_tasks( void )
415 {
416 rtems_status_code status;
417
418 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
419 if (status!=RTEMS_SUCCESSFUL) {
420 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
421 }
422
423 if (status == RTEMS_SUCCESSFUL) // SEND
424 {
425 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
426 if (status!=RTEMS_SUCCESSFUL) {
427 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
428 }
429 }
430
431 return status;
432 }
433
434 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
447 {
435 {
448 /** This function starts all RTEMS tasks used in the software.
436 /** This function starts all RTEMS tasks used in the software.
449 *
437 *
@@ -464,6 +452,14 int start_all_tasks( void )
464 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
452 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
465 }
453 }
466
454
455 if (status == RTEMS_SUCCESSFUL) // WTDG
456 {
457 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
458 if (status!=RTEMS_SUCCESSFUL) {
459 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
460 }
461 }
462
467 if (status == RTEMS_SUCCESSFUL) // SMIQ
463 if (status == RTEMS_SUCCESSFUL) // SMIQ
468 {
464 {
469 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
465 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
@@ -472,22 +468,6 int start_all_tasks( void )
472 }
468 }
473 }
469 }
474
470
475 if (status == RTEMS_SUCCESSFUL) // RECV
476 {
477 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
478 if (status!=RTEMS_SUCCESSFUL) {
479 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
480 }
481 }
482
483 if (status == RTEMS_SUCCESSFUL) // SEND
484 {
485 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
486 if (status!=RTEMS_SUCCESSFUL) {
487 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
488 }
489 }
490
491 if (status == RTEMS_SUCCESSFUL) // ACTN
471 if (status == RTEMS_SUCCESSFUL) // ACTN
492 {
472 {
493 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
473 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
@@ -575,31 +555,41 int start_all_tasks( void )
575 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
555 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
576 }
556 }
577 }
557 }
578
579 return status;
558 return status;
580 }
559 }
581
560
582 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
561 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
583 {
562 {
584 rtems_status_code status;
563 rtems_status_code status_recv;
564 rtems_status_code status_send;
585 rtems_status_code ret;
565 rtems_status_code ret;
586 rtems_id queue_id;
566 rtems_id queue_id;
587
567
588 // create the queue for handling valid TCs
568 // create the queue for handling valid TCs
589 status = rtems_message_queue_create( misc_name[QUEUE_RECV], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
569 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
570 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
590 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
571 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
591 if (status != RTEMS_SUCCESSFUL) {
572 if ( status_recv != RTEMS_SUCCESSFUL ) {
592 ret = status;
573 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
593 BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret)
594 }
574 }
595
575
596 // create the queue for handling TM packet sending
576 // create the queue for handling TM packet sending
597 ret = rtems_message_queue_create( misc_name[QUEUE_SEND], ACTION_MSG_PKTS_COUNT,
577 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
598 ACTION_MSG_PKTS_MAX_SIZE,
578 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
599 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
579 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
600 if (ret != RTEMS_SUCCESSFUL) {
580 if ( status_send != RTEMS_SUCCESSFUL ) {
601 BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret)
581 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
582 }
583
584 if ( status_recv != RTEMS_SUCCESSFUL )
585 {
586 ret = status_recv;
587 }
588 else
589 {
590 ret = status_send;
602 }
591 }
603
592
604 return ret;
593 return ret;
605 }
594 }
595
@@ -156,15 +156,8 rtems_task stat_task(rtems_task_argument
156 rtems_task hous_task(rtems_task_argument argument)
156 rtems_task hous_task(rtems_task_argument argument)
157 {
157 {
158 rtems_status_code status;
158 rtems_status_code status;
159 spw_ioctl_pkt_send spw_ioctl_send;
160 rtems_id queue_id;
159 rtems_id queue_id;
161
160
162 spw_ioctl_send.hlen = 0;
163 spw_ioctl_send.hdr = NULL;
164 spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
165 spw_ioctl_send.data = (char*) &housekeeping_packet;
166 spw_ioctl_send.options = 0;
167
168 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
161 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
169 if (status != RTEMS_SUCCESSFUL)
162 if (status != RTEMS_SUCCESSFUL)
170 {
163 {
@@ -173,8 +166,8 rtems_task hous_task(rtems_task_argument
173
166
174 BOOT_PRINTF("in HOUS ***\n")
167 BOOT_PRINTF("in HOUS ***\n")
175
168
176 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
169 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
177 status = rtems_rate_monotonic_create( HK_name, &HK_id );
170 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
178 if( status != RTEMS_SUCCESSFUL ) {
171 if( status != RTEMS_SUCCESSFUL ) {
179 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
172 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
180 }
173 }
@@ -220,7 +213,8 rtems_task hous_task(rtems_task_argument
220 spacewire_update_statistics();
213 spacewire_update_statistics();
221
214
222 // SEND PACKET
215 // SEND PACKET
223 status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
216 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
217 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
224 if (status != RTEMS_SUCCESSFUL) {
218 if (status != RTEMS_SUCCESSFUL) {
225 PRINTF1("in HOUS *** ERR %d\n", status)
219 PRINTF1("in HOUS *** ERR %d\n", status)
226 }
220 }
@@ -268,7 +262,32 rtems_task dumb_task( rtems_task_argumen
268 }
262 }
269 }
263 }
270
264
265 //*****************************
266 // init housekeeping parameters
271
267
268 void init_housekeeping_parameters( void )
269 {
270 /** This function initialize the housekeeping_packet global variable with default values.
271 *
272 */
273
274 unsigned int i = 0;
275 char *parameters;
272
276
277 parameters = (char*) &housekeeping_packet.lfr_status_word;
278 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
279 {
280 parameters[i] = 0x00;
281 }
282 // init status word
283 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
284 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
285 // init software version
286 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
287 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
288 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
289 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
273
290
291 updateLFRCurrentMode();
292 }
274
293
@@ -25,7 +25,7 char *lstates[6] = {"Error-reset",
25 // RTEMS TASK
25 // RTEMS TASK
26 rtems_task spiq_task(rtems_task_argument unused)
26 rtems_task spiq_task(rtems_task_argument unused)
27 {
27 {
28 /** This RTEMS task is dedicated to the handling of interruption requests raised by the SpaceWire driver.
28 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
29 *
29 *
30 * @param unused is the starting argument of the RTEMS task
30 * @param unused is the starting argument of the RTEMS task
31 *
31 *
@@ -33,45 +33,58 rtems_task spiq_task(rtems_task_argument
33
33
34 rtems_event_set event_out;
34 rtems_event_set event_out;
35 rtems_status_code status;
35 rtems_status_code status;
36 unsigned char lfrMode;
36 int linkStatus;
37
38 BOOT_PRINTF("in SPIQ *** \n")
37
39
38 while(true){
40 while(true){
39 BOOT_PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
40 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
41 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
41
42
42 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
43 // CHECK THE LINK
43
44 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
44 status = spacewire_wait_for_link();
45 if ( linkStatus != 5) {
45
46 rtems_task_suspend( Task_id[ TASKID_RECV ] );
46 if (status != RTEMS_SUCCESSFUL)
47 rtems_task_suspend( Task_id[ TASKID_SEND ] );
47 {
48 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
48 //****************
49 rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
49 // STOP THE SYSTEM
50 }
50 spacewire_compute_stats_offsets();
51 stop_current_mode();
52 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
53 PRINTF("in SPIQ *** Error suspending RECV Task\n")
54 }
55 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task
56 PRINTF("in SPIQ *** Error suspending HOUS Task\n")