##// END OF EJS Templates
fsw-0-2 delivery to LESIA...
paul@pc-solar1.lab-lpp.local -
r16:059e0f45d09b default
parent child
Show More
@@ -2,16 +2,16
2 2 <CodeBlocks_layout_file>
3 3 <ActiveTarget name="Debug" />
4 4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="3">
5 <Cursor position="417" topLine="3" />
5 <Cursor position="384" topLine="87" />
6 6 </File>
7 7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="6">
8 <Cursor position="1629" topLine="27" />
8 <Cursor position="1133" topLine="22" />
9 9 </File>
10 10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
11 <Cursor position="114" topLine="0" />
11 <Cursor position="545" topLine="0" />
12 12 </File>
13 13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="2">
14 <Cursor position="481" topLine="0" />
14 <Cursor position="1157" topLine="0" />
15 15 </File>
16 16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
17 17 <Cursor position="628" topLine="7" />
@@ -26,21 +26,21
26 26 <Cursor position="341" topLine="0" />
27 27 </File>
28 28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="5">
29 <Cursor position="99" topLine="0" />
29 <Cursor position="184" topLine="0" />
30 30 </File>
31 31 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
32 <Cursor position="12524" topLine="55" />
32 <Cursor position="12072" topLine="91" />
33 33 </File>
34 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="2">
35 <Cursor position="2621" topLine="0" />
34 <File name="../src/fsw_misc.c" open="1" top="1" tabpos="2">
35 <Cursor position="4309" topLine="44" />
36 36 </File>
37 37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="0">
38 <Cursor position="1792" topLine="43" />
38 <Cursor position="20570" topLine="67" />
39 39 </File>
40 <File name="../src/tc_handler.c" open="1" top="1" tabpos="2">
41 <Cursor position="13883" topLine="80" />
40 <File name="../src/tc_handler.c" open="0" top="0" tabpos="2">
41 <Cursor position="15292" topLine="0" />
42 42 </File>
43 43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="4">
44 <Cursor position="4576" topLine="83" />
44 <Cursor position="2540" topLine="42" />
45 45 </File>
46 46 </CodeBlocks_layout_file>
1 NO CONTENT: modified file, binary diff hidden
@@ -15,5 +15,6 int configure_timer(gptimer_regs_t *gpti
15 15 void print_statistics(spw_stats *stats);
16 16 int send_console_outputs_on_serial_port();
17 17 rtems_task stat_task(rtems_task_argument argument);
18 rtems_task hous_task(rtems_task_argument argument);
18 19
19 20 #endif // FSW_MISC_H_INCLUDED
@@ -33,15 +33,18
33 33 #define IRQ_TIME2 13
34 34 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
35 35
36 //*****
37 // TIME
36 38 #define CLKDIV_SM_SIMULATOR 9999
37 39 #define CLKDIV_WF_SIMULATOR 9999999
38 40 #define TIMER_SM_SIMULATOR 1
39 41 #define TIMER_WF_SIMULATOR 2
42 #define HK_PERIOD 100 // 100 * 10ms => 1sec
40 43
41 44 //******
42 45 // RTEMS
43 46 #define TASKID_RECV 1
44 #define TASKID_ACTN 1
47 #define TASKID_ACTN 2
45 48 #define TASKID_SPIQ 3
46 49 #define TASKID_SMIQ 4
47 50 #define TASKID_STAT 5
@@ -49,9 +52,13
49 52 #define TASKID_BPF0 7
50 53 #define TASKID_WFRM 8
51 54 #define TASKID_DUMB 9
55 #define TASKID_HOUS 10
52 56
53 57 #define ACTION_MSG_QUEUE_COUNT 10
54 58
59 // LENGTH (BYTES)
60 #define LENGTH_TM_LFR_HK 126
61
55 62 //*******
56 63 // MACROS
57 64 //#define PRINT_TASK_STATISTICS
@@ -1,11 +1,12
1 1 #include <fsw_processing.h>
2 2 #include <rtems.h>
3 #include <ccsds_types.h>
3 4
4 5 // RTEMS GLOBAL VARIABLES
5 6 rtems_name misc_name[5];
6 7 rtems_name misc_id[5];
7 rtems_id Task_id[10]; /* array of task ids */
8 rtems_name Task_name[10]; /* array of task names */
8 rtems_id Task_id[15]; /* array of task ids */
9 rtems_name Task_name[15]; /* array of task names */
9 10 int fdSPW;
10 11 int fdUART;
11 12
@@ -38,8 +39,11 struct param_sbm1_str param_sbm1;
38 39 struct param_sbm2_str param_sbm2;
39 40 unsigned char param_common[2];
40 41
42 // HK PACKETS
43 TMHeader_t housekeeping_header;
44 char housekeeping_data[LENGTH_TM_LFR_HK - 10 + 1];
45
41 46 // BASIC PARAMETERS GLOBAL VARIABLES
42 47 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
43
44 48 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
45 49
@@ -15,7 +15,7
15 15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17 17
18 #define CONFIGURE_MAXIMUM_TASKS 10
18 #define CONFIGURE_MAXIMUM_TASKS 15
19 19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
@@ -70,6 +70,7 rtems_task Init( rtems_task_argument ign
70 70 grspw_timecode_callback = &timecode_irq_handler;
71 71
72 72 configure_spw_link();
73
73 74 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
74 75 IRQ_SPARC_SM, spectral_matrices_isr );
75 76 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
@@ -104,13 +105,18 rtems_task spiq_task(rtems_task_argument
104 105 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
105 106 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
106 107
107 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
108 PRINTF("In SPIQ *** Error suspending RECV Task\n")
108 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) // suspend RECV task
109 PRINTF("In SPIQ *** Error suspending RECV Task\n")
110 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) // suspend HOUS task
111 PRINTF("In SPIQ *** Error suspending HOUS Task\n")
109 112
110 113 configure_spw_link();
111 114
112 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
113 PRINTF("In SPIQ *** Error resume RECV Task\n")
115 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
116 PRINTF("In SPIQ *** Error resume RECV Task\n")
117 if (rtems_task_restart(Task_id[TASKID_HOUS], 1)!=RTEMS_SUCCESSFUL) // restart HOUS task
118 PRINTF("In SPIQ *** Error resume HOUS Task\n")
119
114 120 }
115 121 }
116 122
@@ -140,69 +146,76 int create_all_tasks()
140 146 {
141 147 rtems_status_code status;
142 148
143 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
144 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
145 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
146 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
147 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
148 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
149 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
150 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
151 Task_name[9] = rtems_build_name( 'D', 'U', 'M', 'B' );
149 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
150 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
151 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
152 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
153 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
154 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
155 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
156 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
157 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
158 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
152 159
153 160 // RECV
154 161 status = rtems_task_create(
155 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
162 Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
156 163 RTEMS_DEFAULT_MODES,
157 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
164 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
158 165 );
159 166 // ACTN
160 167 status = rtems_task_create(
161 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
168 Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
162 169 RTEMS_DEFAULT_MODES,
163 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
170 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
164 171 );
165 172 // SPIQ
166 173 status = rtems_task_create(
167 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
174 Task_name[TASKID_SPIQ], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
168 175 RTEMS_DEFAULT_MODES,
169 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
176 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
170 177 );
171 178 // SMIQ
172 179 status = rtems_task_create(
173 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
180 Task_name[TASKID_SMIQ], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
174 181 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
175 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
182 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
176 183 );
177 184 // STAT
178 185 status = rtems_task_create(
179 Task_name[5], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
186 Task_name[TASKID_STAT], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
180 187 RTEMS_DEFAULT_MODES,
181 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
188 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
182 189 );
183 190 // AVF0
184 191 status = rtems_task_create(
185 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
192 Task_name[TASKID_AVF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
186 193 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
187 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
194 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
188 195 );
189 196 // BPF0
190 197 status = rtems_task_create(
191 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
198 Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
192 199 RTEMS_DEFAULT_MODES,
193 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
200 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
194 201 );
195 202 // WFRM
196 203 status = rtems_task_create(
197 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
204 Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
198 205 RTEMS_DEFAULT_MODES,
199 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
206 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
200 207 );
201 208 // DUMB
202 209 status = rtems_task_create(
203 Task_name[9], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
210 Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
204 211 RTEMS_DEFAULT_MODES,
205 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[9]
212 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
213 );
214 // HOUS
215 status = rtems_task_create(
216 Task_name[TASKID_HOUS], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
217 RTEMS_DEFAULT_MODES,
218 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
206 219 );
207 220
208 221 return 0;
@@ -212,33 +225,36 int start_all_tasks()
212 225 {
213 226 rtems_status_code status;
214 227
215 status = rtems_task_start( Task_id[3], spiq_task, 1 );
228 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
216 229 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
217 230
218 status = rtems_task_start( Task_id[1], recv_task, 1 );
231 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
219 232 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
220 233
221 status = rtems_task_start( Task_id[2], actn_task, 1 );
234 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
222 235 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
223 236
224 status = rtems_task_start( Task_id[4], smiq_task, 1 );
237 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
225 238 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
226 239
227 status = rtems_task_start( Task_id[5], stat_task, 1 );
240 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
228 241 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
229 242
230 status = rtems_task_start( Task_id[6], avf0_task, 1 );
243 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
231 244 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
232 245
233 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
246 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
234 247 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
235 248
236 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
249 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
237 250 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
238 251
239 status = rtems_task_start( Task_id[9], dumb_task, 1 );
252 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
240 253 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_DUMB\n")
241 254
255 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
256 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_HOUS\n")
257
242 258 return 0;
243 259 }
244 260
@@ -269,7 +285,7 int configure_spw_link()
269 285 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
270 286 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
271 287 //
272 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
288 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
273 289 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
274 290 //
275 291 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
@@ -3,6 +3,8
3 3
4 4 extern rtems_id Task_id[]; /* array of task ids */
5 5 extern int fdSPW;
6 extern TMHeader_t housekeeping_header;
7 extern char housekeeping_data[];
6 8
7 9 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
8 10 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
@@ -71,5 +73,66 rtems_task stat_task(rtems_task_argument
71 73 else i++;
72 74 }
73 75 }
76
77 rtems_task hous_task(rtems_task_argument argument)
78 {
79 rtems_status_code status;
74 80
81 spw_ioctl_pkt_send spw_ioctl_send;
82
83 rtems_name name;
84 rtems_id period;
85 name = rtems_build_name( 'H', 'O', 'U', 'S' );
86 status = rtems_rate_monotonic_create( name, &period );
87 if( status != RTEMS_SUCCESSFUL ) {
88 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
89 exit( 1 );
90 }
75 91
92 // filling the structure for the spacewire transmission
93 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
94 spw_ioctl_send.hdr = (char*) &housekeeping_header;
95 spw_ioctl_send.dlen = LENGTH_TM_LFR_HK - 10 + 1;
96 spw_ioctl_send.data = housekeeping_data;
97
98 housekeeping_header.targetLogicalAddress = CCSDS_DESTINATION_ID;
99 housekeeping_header.protocolIdentifier = 0x02;
100 housekeeping_header.reserved = 0x00;
101 housekeeping_header.userApplication = 0x00;
102 housekeeping_header.packetID[0] = 0x0c;
103 housekeeping_header.packetID[1] = 0xc4;
104 housekeeping_header.packetSequenceControl[0] = 0xc0;
105 housekeeping_header.packetSequenceControl[1] = 0x00;
106 housekeeping_header.packetLength[0] = 0x00;
107 housekeeping_header.packetLength[1] = 0x77;
108 housekeeping_header.dataFieldHeader[0] = 0x10;
109 housekeeping_header.dataFieldHeader[1] = 0x03;
110 housekeeping_header.dataFieldHeader[2] = 0x19;
111 housekeeping_header.dataFieldHeader[3] = 0x00;
112
113 printf("In HOUS ***\n");
114
115 while(1){ // launch the rate monotonic task
116 if ( rtems_rate_monotonic_period( period, HK_PERIOD ) == RTEMS_TIMEOUT ){
117 printf( "ERR *** in hous_task *** RTEMS_TIMEOUT\n" );
118 break;
119 }
120 housekeeping_header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
121 housekeeping_header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
122 housekeeping_header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
123 housekeeping_header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
124 housekeeping_header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
125 housekeeping_header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
126 status = write_spw(&spw_ioctl_send);
127 }
128
129 status = rtems_rate_monotonic_delete( period );
130 if ( status != RTEMS_SUCCESSFUL ) {
131 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
132 exit( 1 );
133 }
134 status = rtems_task_delete( RTEMS_SELF ); // should not return
135 printf( "rtems_task_delete returned with status of %d.\n", status );
136 exit( 1 );
137 }
138
General Comments 0
You need to be logged in to leave comments. Login now