##// END OF EJS Templates
Message queue implemented for valid TC processing...
paul@pc-solar1.lab-lpp.local -
r9:515486994c1d default
parent child
Show More
@@ -10,7 +10,7
10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
11 <Option object_output="obj/Debug/" />
11 <Option object_output="obj/Debug/" />
12 <Option type="1" />
12 <Option type="1" />
13 <Option compiler="sparcrtems446" />
13 <Option compiler="sparcrtemsgcc446" />
14 <Compiler>
14 <Compiler>
15 <Add option="-fexpensive-optimizations" />
15 <Add option="-fexpensive-optimizations" />
16 <Add option="-O3" />
16 <Add option="-O3" />
@@ -71,7 +71,7 1359377846 /opt/DEV_PLE/header/TC_handle
71 <stdio.h>
71 <stdio.h>
72 <ccsds_types.h>
72 <ccsds_types.h>
73
73
74 1359372295 /opt/DEV_PLE/header/ccsds_types.h
74 1359640245 /opt/DEV_PLE/header/ccsds_types.h
75
75
76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
77 <drvmgr/ambapp_bus.h>
77 <drvmgr/ambapp_bus.h>
@@ -142,12 +142,12 1359464346 /opt/DEV_PLE/header/fsw_main.
142 <wf_handler.h>
142 <wf_handler.h>
143 <grlib_regs.h>
143 <grlib_regs.h>
144
144
145 1359464984 /opt/DEV_PLE/header/fsw_params.h
145 1359616894 /opt/DEV_PLE/header/fsw_params.h
146
146
147 1359464293 /opt/DEV_PLE/header/fsw_misc.h
147 1359614518 /opt/DEV_PLE/header/fsw_misc.h
148 <rtems.h>
148 <rtems.h>
149 <stdio.h>
149 <stdio.h>
150 <fsw_main.h>
150 <fsw_init.h>
151 <fsw_params.h>
151 <fsw_params.h>
152 <grlib_regs.h>
152 <grlib_regs.h>
153 <grspw.h>
153 <grspw.h>
@@ -155,38 +155,72 1359464293 /opt/DEV_PLE/header/fsw_misc.
155
155
156 1359440704 /opt/DEV_PLE/header/grlib_regs.h
156 1359440704 /opt/DEV_PLE/header/grlib_regs.h
157
157
158 1359465021 /opt/DEV_PLE/header/fsw_processing.h
158 1359614517 /opt/DEV_PLE/header/fsw_processing.h
159 <rtems.h>
159 <rtems.h>
160 <grlib_regs.h>
160 <grlib_regs.h>
161 <fsw_params.h>
161 <fsw_params.h>
162
162
163 1359377846 /opt/DEV_PLE/header/tc_handler.h
163 1359643450 /opt/DEV_PLE/header/tc_handler.h
164 <rtems.h>
164 <stdio.h>
165 <stdio.h>
166 <unistd.h>
167 <sys/ioctl.h>
165 <ccsds_types.h>
168 <ccsds_types.h>
169 <grspw.h>
170 <fsw_init.h>
166
171
167 1359464293 /opt/DEV_PLE/header/wf_handler.h
172 1359614518 /opt/DEV_PLE/header/wf_handler.h
168 <rtems.h>
173 <rtems.h>
169 <fsw_params.h>
174 <fsw_params.h>
170 <grspw.h>
175 <grspw.h>
171 <grlib_regs.h>
176 <grlib_regs.h>
172 <ccsds_types.h>
177 <ccsds_types.h>
173 <stdio.h>
178 <stdio.h>
174 <fsw_main.h>
179 <fsw_init.h>
175
180
176 1359365823 /opt/DEV_PLE/src/fsw_config.c
181 1359365823 /opt/DEV_PLE/src/fsw_config.c
177 <drvmgr/ambapp_bus.h>
182 <drvmgr/ambapp_bus.h>
178
183
179 1359464327 source:/opt/DEV_PLE/src/fsw_misc.c
184 1359614518 source:/opt/DEV_PLE/src/fsw_misc.c
180 <fsw_misc.h>
185 <fsw_misc.h>
181 <fsw_params.h>
186 <fsw_params.h>
182
187
183 1359464327 source:/opt/DEV_PLE/src/tc_handler.c
188 1359643720 source:/opt/DEV_PLE/src/tc_handler.c
184 <tc_handler.h>
189 <tc_handler.h>
185 <fsw_params.h>
190 <fsw_params.h>
186
191
187 1359464346 source:/opt/DEV_PLE/src/wf_handler.c
192 1359614518 source:/opt/DEV_PLE/src/wf_handler.c
188 <wf_handler.h>
193 <wf_handler.h>
189
194
190 1359465021 source:/opt/DEV_PLE/src/fsw_globals.c
195 1359615705 source:/opt/DEV_PLE/src/fsw_globals.c
191 <fsw_processing.h>
196 <fsw_processing.h>
197 <rtems.h>
192
198
199 1359622160 source:/opt/DEV_PLE/src/fsw_init.c
200 <rtems.h>
201 <bsp.h>
202 <rtems/confdefs.h>
203 <drvmgr/drvmgr_confdefs.h>
204 <fsw_init.h>
205 <fsw_config.c>
206
207 1359615705 /opt/DEV_PLE/header/fsw_init.h
208 <errno.h>
209 <fcntl.h>
210 <stdio.h>
211 <stdlib.h>
212 <grspw.h>
213 <apbuart.h>
214 <fsw_params.h>
215 <fsw_misc.h>
216 <fsw_processing.h>
217 <tc_handler.h>
218 <wf_handler.h>
219 <grlib_regs.h>
220
221 1359614518 source:/opt/DEV_PLE/src/fsw_processing.c
222 <fsw_processing.h>
223 <math.h>
224 <stdio.h>
225 <leon.h>
226
@@ -25,8 +25,13
25 <File name="../src/fsw_globals.c" open="1" top="0" tabpos="4">
25 <File name="../src/fsw_globals.c" open="1" top="0" tabpos="4">
26 <Cursor position="46" topLine="0" />
26 <Cursor position="46" topLine="0" />
27 </File>
27 </File>
28 <<<<<<< local
29 <File name="../src/fsw_init.c" open="1" top="1" tabpos="0">
30 <Cursor position="1703" topLine="36" />
31 =======
28 <File name="../src/fsw_init.c" open="1" top="1" tabpos="2">
32 <File name="../src/fsw_init.c" open="1" top="1" tabpos="2">
29 <Cursor position="3361" topLine="60" />
33 <Cursor position="3361" topLine="60" />
34 >>>>>>> other
30 </File>
35 </File>
31 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
36 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
32 <Cursor position="20" topLine="0" />
37 <Cursor position="20" topLine="0" />
@@ -34,8 +39,13
34 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2">
39 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2">
35 <Cursor position="1175" topLine="46" />
40 <Cursor position="1175" topLine="46" />
36 </File>
41 </File>
42 <<<<<<< local
43 <File name="../src/tc_handler.c" open="0" top="0" tabpos="3">
44 <Cursor position="2672" topLine="26" />
45 =======
37 <File name="../src/tc_handler.c" open="1" top="0" tabpos="1">
46 <File name="../src/tc_handler.c" open="1" top="0" tabpos="1">
38 <Cursor position="11070" topLine="270" />
47 <Cursor position="11070" topLine="270" />
48 >>>>>>> other
39 </File>
49 </File>
40 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
50 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
41 <Cursor position="3936" topLine="62" />
51 <Cursor position="3936" topLine="62" />
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -4,7 +4,7
4 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
4 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
5 #define CCSDS_TM_PKT_MAX_SIZE 4412
5 #define CCSDS_TM_PKT_MAX_SIZE 4412
6 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
6 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
7 #define CCSDS_TC_PKT_MAX_SIZE 248
7 #define CCSDS_TC_PKT_MAX_SIZE 50 // size of the TC_LFR_UPDATE_INFO packet
8 #define CCSDS_TC_TM_PACKET_OFFSET 7
8 #define CCSDS_TC_TM_PACKET_OFFSET 7
9 #define CCSDS_PROCESS_ID 76
9 #define CCSDS_PROCESS_ID 76
10 #define CCSDS_PACKET_CATEGORY 12
10 #define CCSDS_PACKET_CATEGORY 12
@@ -30,19 +30,20
30 #define FAIL_DETECTED 40003
30 #define FAIL_DETECTED 40003
31 #define NOT_ALLOWED 40004
31 #define NOT_ALLOWED 40004
32 #define CORRUPTED 40005
32 #define CORRUPTED 40005
33 //
33
34 #define SID_TC_RESET 3
34 // // TC SUBTYPES
35 #define SID_TC_LOAD_COMM 20
35 #define TC_SUBTYPE_RESET 3
36 #define SID_TC_LOAD_NORM 21
36 #define TC_SUBTYPE_LOAD_COMM 20
37 #define SID_TC_LOAD_BURST 24
37 #define TC_SUBTYPE_LOAD_NORM 21
38 #define SID_TC_LOAD_SBM1 27
38 #define TC_SUBTYPE_LOAD_BURST 24
39 #define SID_TC_LOAD_SBM2 28
39 #define TC_SUBTYPE_LOAD_SBM1 27
40 #define SID_TC_DUMP 30
40 #define TC_SUBTYPE_LOAD_SBM2 28
41 #define SID_TC_ENTER 40
41 #define TC_SUBTYPE_DUMP 30
42 #define SID_TC_UPDT_INFO 50
42 #define TC_SUBTYPE_ENTER 40
43 #define SID_TC_EN_CAL 60
43 #define TC_SUBTYPE_UPDT_INFO 50
44 #define SID_TC_DIS_CAL 61
44 #define TC_SUBTYPE_EN_CAL 60
45 #define SID_TC_UPDT_TIME 129
45 #define TC_SUBTYPE_DIS_CAL 61
46 #define TC_SUBTYPE_UPDT_TIME 129
46
47
47 #define SID_DEFAULT 0
48 #define SID_DEFAULT 0
48 #define SID_EXE_INC 5
49 #define SID_EXE_INC 5
@@ -55,6 +56,28
55 #define SID_NORM_SWF_F1 4
56 #define SID_NORM_SWF_F1 4
56 #define SID_NORM_SWF_F2 5
57 #define SID_NORM_SWF_F2 5
57 #define SID_NORM_CWF_F3 1
58 #define SID_NORM_CWF_F3 1
59 #define SID_BURST_CWF_F2 2
60 #define SID_SBM1_CWF_F1 24
61 #define SID_SBM2_CWF_F2 25
62 #define SID_NORM_ASM_F0 11
63 #define SID_NORM_ASM_F1 12
64 #define SID_NORM_ASM_F2 13
65 #define SID_NORM_BP1_F0 14
66 #define SID_NORM_BP1_F1 15
67 #define SID_NORM_BP1_F2 16
68 #define SID_NORM_BP2_F0 19
69 #define SID_NORM_BP2_F1 20
70 #define SID_NORM_BP2_F2 21
71 #define SID_BURST_BP1_F0 17
72 #define SID_BURST_BP2_F0 22
73 #define SID_BURST_BP1_F1 18
74 #define SID_BURST_BP2_F1 23
75 #define SID_SBM1_BP1_F0 28
76 #define SID_SBM1_BP2_F0 31
77 #define SID_SBM2_BP1_F0 29
78 #define SID_SBM2_BP2_F0 32
79 #define SID_SBM1_BP1_F1 30
80 #define SID_SBM1_BP2_F1 33
58
81
59 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
82 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
60 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
83 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
@@ -18,14 +18,18
18
18
19 extern int sched_yield();
19 extern int sched_yield();
20 extern int errno;
20 extern int errno;
21 extern rtems_name misc_names[ ];
21 extern rtems_id Task_id[ ]; /* array of task ids */
22 extern rtems_name Task_name[ ]; /* array of task names */
23 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
24 extern int fdSPW; // grspw file descriptor
25 extern int fdUART; // uart file descriptor
22
26
23 // RTEMS TASKS
27 // RTEMS TASKS
24 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
28 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
25 rtems_task spw_recv_task(rtems_task_argument argument);
29 rtems_task recv_task(rtems_task_argument argument);
26 rtems_task spw_spiq_task(rtems_task_argument argument);
30 rtems_task spiq_task(rtems_task_argument argument);
27 rtems_task spw_stat_task(rtems_task_argument argument);
31 rtems_task stat_task(rtems_task_argument argument);
28 rtems_task spw_wfrm_task(rtems_task_argument argument);
32 rtems_task wfrm_task(rtems_task_argument argument);
29 int create_all_tasks();
33 int create_all_tasks();
30 int start_all_tasks();
34 int start_all_tasks();
31 int create_message_queue();
35 int create_message_queue();
@@ -14,6 +14,6 int configure_timer(gptimer_regs_t *gpti
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
15 void print_statistics(spw_stats *stats);
15 void print_statistics(spw_stats *stats);
16 int send_console_outputs_on_serial_port();
16 int send_console_outputs_on_serial_port();
17 rtems_task spw_stat_task(rtems_task_argument argument);
17 rtems_task stat_task(rtems_task_argument argument);
18
18
19 #endif // FSW_MISC_H_INCLUDED
19 #endif // FSW_MISC_H_INCLUDED
@@ -4,6 +4,8
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 #define UART_DEVICE_NAME "/dev/console"
5 #define UART_DEVICE_NAME "/dev/console"
6
6
7 //*****************************
8 // APB REGISTERS BASE ADDRESSES
7 #define REGS_ADDR_APBUART 0x80000100
9 #define REGS_ADDR_APBUART 0x80000100
8 #define REGS_ADDR_GPTIMER 0x80000300
10 #define REGS_ADDR_GPTIMER 0x80000300
9 #define REGS_ADDR_GRSPW 0x80000500
11 #define REGS_ADDR_GRSPW 0x80000500
@@ -21,7 +23,10
21 #define TIMER_SM_SIMULATOR 1
23 #define TIMER_SM_SIMULATOR 1
22 #define TIMER_WF_SIMULATOR 2
24 #define TIMER_WF_SIMULATOR 2
23
25
26 //******
27 // RTEMS
24 #define TASKID_RECV 1
28 #define TASKID_RECV 1
29 #define TASKID_ACTN 1
25 #define TASKID_SPIQ 3
30 #define TASKID_SPIQ 3
26 #define TASKID_SMIQ 4
31 #define TASKID_SMIQ 4
27 #define TASKID_STAT 5
32 #define TASKID_STAT 5
@@ -29,6 +34,10
29 #define TASKID_BPF0 7
34 #define TASKID_BPF0 7
30 #define TASKID_WFRM 8
35 #define TASKID_WFRM 8
31
36
37 #define ACTION_MSG_QUEUE_COUNT 10
38
39 //*******
40 // MACROS
32 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
41 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
33 #ifdef PRINT_MESSAGES_ON_CONSOLE
42 #ifdef PRINT_MESSAGES_ON_CONSOLE
34 #define PRINTF(x) printf(x);
43 #define PRINTF(x) printf(x);
@@ -30,9 +30,9 typedef struct BP1_str BP1_t;
30 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
30 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
31 // RTEMS TASKS
31 // RTEMS TASKS
32 rtems_task spw_bppr_task(rtems_task_argument argument);
32 rtems_task spw_bppr_task(rtems_task_argument argument);
33 rtems_task spw_avf0_task(rtems_task_argument argument);
33 rtems_task avf0_task(rtems_task_argument argument);
34 rtems_task spw_bpf0_task(rtems_task_argument argument);
34 rtems_task bpf0_task(rtems_task_argument argument);
35 rtems_task spw_smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
35 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
36 //
36 //
37 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
37 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
38 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat);
38 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat);
@@ -7,8 +7,11
7 #include <sys/ioctl.h> // for the ioctl call
7 #include <sys/ioctl.h> // for the ioctl call
8 #include <ccsds_types.h>
8 #include <ccsds_types.h>
9 #include <grspw.h>
9 #include <grspw.h>
10 #include <fsw_init.h>
10
11
11 extern int fdSPW;
12 extern int fdSPW;
13 extern rtems_name misc_name[ ];
14 extern rtems_name misc_id[ ];
12 extern rtems_id Task_id[ ]; /* array of task ids */
15 extern rtems_id Task_id[ ]; /* array of task ids */
13
16
14 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
17 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
@@ -25,16 +28,21 void GetCRCAsTwoBytes(unsigned char* dat
25
28
26 //*********************
29 //*********************
27 // ACCEPTANCE FUNCTIONS
30 // ACCEPTANCE FUNCTIONS
28 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
31 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
29
32
30 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
33 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
31 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
34 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
32 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
35 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
33 unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV,
36 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
34 TMHeader_t *TM_Header, unsigned int *hlen, char *data);
35
37
36 //***********
38 //***********
37 // RTEMS TASK
39 // RTEMS TASK
38 rtems_task spw_recv_task( rtems_task_argument unused );
40 rtems_task recv_task( rtems_task_argument unused );
41 rtems_task actn_task( rtems_task_argument unused );
42 int create_message_queue();
43
44 //***********
45 // TC ACTIONS
46 int default_action(ccsdsTelecommandPacket_t *TC);
39
47
40 #endif // TC_HANDLER_H_INCLUDED
48 #endif // TC_HANDLER_H_INCLUDED
@@ -15,6 +15,6 extern rtems_id Task_id[]; /* ar
15 extern int fdSPW;
15 extern int fdSPW;
16
16
17 rtems_isr waveforms_isr( rtems_vector_number vector );
17 rtems_isr waveforms_isr( rtems_vector_number vector );
18 rtems_task spw_wfrm_task(rtems_task_argument argument);
18 rtems_task wfrm_task(rtems_task_argument argument);
19
19
20 #endif // WF_HANDLER_H_INCLUDED
20 #endif // WF_HANDLER_H_INCLUDED
@@ -2,7 +2,12
2 #include <rtems.h>
2 #include <rtems.h>
3
3
4 // RTEMS GLOBAL VARIABLES
4 // RTEMS GLOBAL VARIABLES
5 rtems_name misc_names[5];
5 rtems_name misc_name[5];
6 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 */
9 int fdSPW;
10 int fdUART;
6
11
7 // WAVEFORMS GLOBAL VARIABLES
12 // WAVEFORMS GLOBAL VARIABLES
8 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
13 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
@@ -22,6 +22,7
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_PERIODS 1
24 #define CONFIGURE_MAXIMUM_PERIODS 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
25
26
26 #include <rtems/confdefs.h>
27 #include <rtems/confdefs.h>
27
28
@@ -41,10 +42,7
41 #endif
42 #endif
42
43
43 #include <fsw_init.h>
44 #include <fsw_init.h>
44 #include <fsw_config.c>
45 #include <fsw_config.c>
45
46 int fdSPW;
47 int fdUART;
48
46
49 char *link_status(int status);
47 char *link_status(int status);
50
48
@@ -55,9 +53,6 char *lstates[6] = {"Error-reset",
55 "Connecting",
53 "Connecting",
56 "Run"
54 "Run"
57 };
55 };
58
59 rtems_id Task_id[10]; /* array of task ids */
60 rtems_name Task_name[10]; /* array of task names */
61
56
62 rtems_task Init( rtems_task_argument ignored )
57 rtems_task Init( rtems_task_argument ignored )
63 {
58 {
@@ -85,7 +80,7 rtems_task Init( rtems_task_argument ign
85 status = rtems_task_delete(RTEMS_SELF);
80 status = rtems_task_delete(RTEMS_SELF);
86 }
81 }
87
82
88 rtems_task spw_spiq_task(rtems_task_argument unused)
83 rtems_task spiq_task(rtems_task_argument unused)
89 {
84 {
90 rtems_event_set event_out;
85 rtems_event_set event_out;
91 struct grspw_regs_str *grspw_regs;
86 struct grspw_regs_str *grspw_regs;
@@ -105,17 +100,12 rtems_task spw_spiq_task(rtems_task_argu
105 }
100 }
106 }
101 }
107
102
108 int create_message_queue()
109 {
110 misc_names[0] = rtems_build_name( 'D', 'O', 'I', 'T' );
111 return 0;
112 }
113
114 int create_all_tasks()
103 int create_all_tasks()
115 {
104 {
116 rtems_status_code status;
105 rtems_status_code status;
117
106
118 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
107 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
108 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
119 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
109 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
120 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
110 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
121 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
111 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
@@ -128,6 +118,12 int create_all_tasks()
128 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
118 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
129 RTEMS_DEFAULT_MODES,
119 RTEMS_DEFAULT_MODES,
130 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
120 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
121 );
122 // ACTN
123 status = rtems_task_create(
124 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
125 RTEMS_DEFAULT_MODES,
126 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
131 );
127 );
132 // SPIQ
128 // SPIQ
133 status = rtems_task_create(
129 status = rtems_task_create(
@@ -173,26 +169,28 int start_all_tasks()
173 {
169 {
174 rtems_status_code status;
170 rtems_status_code status;
175
171
176 status = rtems_task_start( Task_id[3], spw_spiq_task, 1 );
172 status = rtems_task_start( Task_id[3], spiq_task, 1 );
177 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
173 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
178
174
179 status = rtems_task_start( Task_id[1], spw_recv_task, 1 );
175 status = rtems_task_start( Task_id[1], recv_task, 1 );
180 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
176 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
181
177
182 //status = rtems_task_start( Task_id[4], spw_bppr_task_rate_monotonic, 1 );
178 status = rtems_task_start( Task_id[2], actn_task, 1 );
183 status = rtems_task_start( Task_id[4], spw_smiq_task, 1 );
179 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
180
181 status = rtems_task_start( Task_id[4], smiq_task, 1 );
184 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
182 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
185
183
186 status = rtems_task_start( Task_id[5], spw_stat_task, 1 );
184 status = rtems_task_start( Task_id[5], stat_task, 1 );
187 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
185 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
188
186
189 status = rtems_task_start( Task_id[6], spw_avf0_task, 1 );
187 status = rtems_task_start( Task_id[6], avf0_task, 1 );
190 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
188 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
191
189
192 status = rtems_task_start( Task_id[7], spw_bpf0_task, 1 );
190 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
193 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
191 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
194
192
195 status = rtems_task_start( Task_id[8], spw_wfrm_task, 1 );
193 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
196 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
194 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
197
195
198 return 0;
196 return 0;
@@ -53,7 +53,7 int send_console_outputs_on_serial_port(
53 return 0;
53 return 0;
54 }
54 }
55
55
56 rtems_task spw_stat_task(rtems_task_argument argument)
56 rtems_task stat_task(rtems_task_argument argument)
57 {
57 {
58 int i;
58 int i;
59 i = 0;
59 i = 0;
@@ -56,7 +56,7 rtems_isr spectral_matrices_isr( rtems_v
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
57 }
57 }
58
58
59 rtems_task spw_smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
59 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
60 {
60 {
61 rtems_event_set event_out;
61 rtems_event_set event_out;
62 gptimer_regs_t *gptimer_regs;
62 gptimer_regs_t *gptimer_regs;
@@ -68,7 +68,7 rtems_task spw_smiq_task(rtems_task_argu
68 nb_interrupt_f0 = nb_interrupt_f0 + 1;
68 nb_interrupt_f0 = nb_interrupt_f0 + 1;
69 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
69 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
70 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
70 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
71 printf("In spw_smiq_task *** Error sending event to AVF0\n");
71 printf("In smiq_task *** Error sending event to AVF0\n");
72 nb_interrupt_f0 = 0;
72 nb_interrupt_f0 = 0;
73 }
73 }
74 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
74 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
@@ -329,7 +329,7 void BP2_set(float * compressed_spec_mat
329 }
329 }
330 }
330 }
331
331
332 rtems_task spw_avf0_task(rtems_task_argument argument){
332 rtems_task avf0_task(rtems_task_argument argument){
333 int i;
333 int i;
334 static int nb_average;
334 static int nb_average;
335 rtems_event_set event_out;
335 rtems_event_set event_out;
@@ -365,7 +365,7 rtems_task spw_avf0_task(rtems_task_argu
365 }
365 }
366 }
366 }
367
367
368 rtems_task spw_bpf0_task(rtems_task_argument argument){
368 rtems_task bpf0_task(rtems_task_argument argument){
369 rtems_event_set event_out;
369 rtems_event_set event_out;
370
370
371 while(1){
371 while(1){
@@ -51,43 +51,37 void GetCRCAsTwoBytes(unsigned char* dat
51
51
52 //*********************
52 //*********************
53 // ACCEPTANCE FUNCTIONS
53 // ACCEPTANCE FUNCTIONS
54 unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV,
54 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
55 TMHeader_t *TM_Header, unsigned int *hlen, char *data)
56 {
55 {
56 rtems_status_code status;
57 spw_ioctl_pkt_send spw_ioctl_send;
58 TMHeader_t TM_header;
57 unsigned int code = 0;
59 unsigned int code = 0;
58 unsigned int data_length = 0;
59 unsigned char computed_CRC[2];
60 unsigned char computed_CRC[2];
60 unsigned char subtype = 0;
61 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
61
62
62 subtype = TC->dataFieldHeader[2];
63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, TC_LEN_RCV + 5 );
64 code = acceptTM( TC, tc_len_recv ) ;
64 code = acceptTM( TC, TC_LEN_RCV ) ;
65 //PRINTF1("in TC_checker *** %s\n", errorCCSDSMsg[code]);
66 if ( (code == 0) | (code == 1) | (code == 2)
65 if ( (code == 0) | (code == 1) | (code == 2)
67 | (code == 3) | (code == 4) | (code == 5) )
66 | (code == 3) | (code == 4) | (code == 5) )
68 { // generate TM_LFR_TC_EXE_CORRUPTED
67 { // generate TM_LFR_TC_EXE_CORRUPTED
69 // BUILD HEADER
68 // BUILD HEADER
70 TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, TM_Header);
69 TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
71 // BUILD DATA
70 // BUILD DATA
72 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
71 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
73 data_length = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
72 // PREPARE TM SENDING
74 }
73 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
75 if (subtype == SID_TC_UPDT_TIME){
74 spw_ioctl_send.hdr = (char*) &TM_header;
76 // BUILD HEADER
75 spw_ioctl_send.dlen = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
77 TM_build_header( TM_LFR_TC_EXE_OK, SID_DEFAULT, TM_LEN_EXE, 0, 0, TM_Header);
76 spw_ioctl_send.data = data;
78 // BUILD DATA
77 // SEND PACKET
79 TM_build_data( TC, data, SID_DEFAULT, computed_CRC);
78 write_spw(&spw_ioctl_send);
80 data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
81 }
79 }
82 else { // TM_LFR_TC_EXE_NOT_IMPLEMENTED
80 else { // TM_LFR_TC_EXE_NOT_IMPLEMENTED
83 // BUILD HEADER
81 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET);
84 TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, TM_Header);
82 return -1;
85 // BUILD DATA
86 TM_build_data( TC, data, SID_NOT_IMP, computed_CRC);
87 data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
88 }
83 }
89
84 return -1;
90 return data_length;
91 }
85 }
92
86
93 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
87 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
@@ -276,29 +270,22 unsigned char TM_build_data(ccsdsTelecom
276 return 1;
270 return 1;
277 }
271 }
278
272
279 unsigned char actionLauncher(unsigned int sid)
280 {
281 return 0;
282 }
283
284 //***********
273 //***********
285 // RTEMS TASK
274 // RTEMS TASK
286 rtems_task spw_recv_task( rtems_task_argument unused )
275 rtems_task recv_task( rtems_task_argument unused )
287 {
276 {
288 rtems_status_code status;
289 int len = 0;
277 int len = 0;
290 unsigned int i = 0;
278 unsigned int i = 0;
291 unsigned int data_length = 0;
279 unsigned int data_length = 0;
292 ccsdsTelecommandPacket_t currentTC;
280 ccsdsTelecommandPacket_t currentTC;
293 spw_ioctl_pkt_send spw_ioctl_send;
294 TMHeader_t TM_header;
295 char data[100];
281 char data[100];
296
282
297 for(i=0; i<100; i++) data[i] = 0;
283 for(i=0; i<100; i++) data[i] = 0;
298
284
299 PRINTF("In RECV *** \n")
285 PRINTF("In RECV *** \n")
300
286
301 while(1){
287 while(1)
288 {
302 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
289 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
303 if (len == -1){ // error during the read call
290 if (len == -1){ // error during the read call
304 PRINTF("In RECV *** last read call returned -1\n")
291 PRINTF("In RECV *** last read call returned -1\n")
@@ -313,19 +300,97 rtems_task spw_recv_task( rtems_task_arg
313 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
300 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
314 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
301 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
315 // CHECK THE TC AND BUILD THE APPROPRIATE TM
302 // CHECK THE TC AND BUILD THE APPROPRIATE TM
316 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt,
303 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
317 &TM_header, &spw_ioctl_send.hlen, data);
304 if (data_length!=-1)
318 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
305 {
319 spw_ioctl_send.hdr = (char*) &TM_header;
306 }
320 spw_ioctl_send.dlen = data_length;
321 spw_ioctl_send.data = data;
322 //printf("hlen %d, dlen %d\n", spw_ioctl_send.hlen, spw_ioctl_send.dlen);
323 // SEND PACKET
324 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
325 if (status!=RTEMS_SUCCESSFUL) printf("In TC_checker *** Error SPACEWIRE_IOCTRL_SEND\n");
326 //PRINTF1("In TC_checker *** packet of size %d sent\n", spw_ioctl_send.sent)
327 }
307 }
328 }
308 }
329 }
309 }
330
310
311 rtems_task actn_task( rtems_task_argument unused )
312 {
313 rtems_status_code status; // RTEMS status code
314 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
315 size_t size; // size of the incoming TC packet
316 unsigned char subtype = 0; // subtype of the current TC packet
331
317
318 while(1)
319 {
320 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
321 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
322 if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status)
323 else
324 {
325 subtype = TC.dataFieldHeader[2];
326 switch(subtype)
327 {
328 case TC_SUBTYPE_RESET:
329 break;
330 case TC_SUBTYPE_LOAD_COMM:
331 break;
332 case TC_SUBTYPE_LOAD_NORM:
333 break;
334 case TC_SUBTYPE_LOAD_BURST:
335 break;
336 case TC_SUBTYPE_LOAD_SBM1:
337 break;
338 case TC_SUBTYPE_LOAD_SBM2:
339 break;
340 case TC_SUBTYPE_DUMP:
341 default_action( &TC );
342 break;
343 case TC_SUBTYPE_ENTER:
344 break;
345 case TC_SUBTYPE_UPDT_INFO:
346 break;
347 case TC_SUBTYPE_EN_CAL:
348 break;
349 case TC_SUBTYPE_DIS_CAL:
350 break;
351 case TC_SUBTYPE_UPDT_TIME:
352 break;
353 default:
354 break;
355 }
356 }
357 }
358 }
359
360 int create_message_queue()
361 {
362 rtems_status_code status;
363 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
364 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
365 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
366 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
367
368 return 0;
369 }
370
371 //***********
372 // TC ACTIONS
373 int default_action(ccsdsTelecommandPacket_t *TC)
374 {
375 char data[100]; // buffer for the generic TM packet
376 TMHeader_t TM_header; // TM header
377 spw_ioctl_pkt_send spw_ioctl_send; // structure to send the TM packet if any
378 // BUILD HEADER
379 TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, &TM_header);
380 // BUILD DATA
381 TM_build_data( TC, data, SID_NOT_IMP, NULL);
382 // filling the strture for the spcawire transmission
383 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
384 spw_ioctl_send.hdr = (char*) &TM_header;
385 spw_ioctl_send.dlen = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
386 spw_ioctl_send.data = data;
387 // SEND DATA
388 write_spw(&spw_ioctl_send);
389
390 return 0;
391 }
392
393
394
395
396
@@ -6,7 +6,7 rtems_isr waveforms_isr( rtems_vector_nu
6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
7 }
7 }
8
8
9 rtems_task spw_wfrm_task(rtems_task_argument argument)
9 rtems_task wfrm_task(rtems_task_argument argument)
10 {
10 {
11 unsigned int length;
11 unsigned int length;
12 unsigned int i = 0;
12 unsigned int i = 0;
General Comments 0
You need to be logged in to leave comments. Login now