##// END OF EJS Templates
Last commit before release 0-13...
paul -
r35:ca106d3b5c2f default
parent child
Show More
@@ -0,0 +1,32
1 #ifndef FSW_SPACEWIRE_H_INCLUDED
2 #define FSW_SPACEWIRE_H_INCLUDED
3
4 #include <rtems.h>
5
6 #include <grspw.h>
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <fcntl.h>
11
12 #include "fsw_params.h"
13 #include "ccsds_types.h"
14 #include "fsw_misc.h"
15
16 extern spw_stats spacewire_stats;
17 extern spw_stats spacewire_stats_backup;
18
19 // RTEMS TASK
20 rtems_task spiq_task(rtems_task_argument argument);
21
22 int spacewire_configure_link( void );
23 int spacewire_wait_for_link(void);
24 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
25 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
26 void spacewire_compute_stats_offsets();
27
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29
30 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
31
32 #endif // FSW_SPACEWIRE_H_INCLUDED
@@ -0,0 +1,200
1 #include "fsw_spacewire.h"
2
3 char *lstates[6] = {"Error-reset",
4 "Error-wait",
5 "Ready",
6 "Started",
7 "Connecting",
8 "Run"
9 };
10
11 // RTEMS TASK
12 rtems_task spiq_task(rtems_task_argument unused)
13 {
14 rtems_event_set event_out;
15 rtems_status_code status;
16 unsigned char lfrMode;
17
18 while(true){
19 BOOT_PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
20 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
21
22 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
23
24 status = spacewire_wait_for_link();
25
26 if (status != RTEMS_SUCCESSFUL)
27 {
28 //****************
29 // STOP THE SYSTEM
30 spacewire_compute_stats_offsets();
31 stop_current_mode();
32 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
33 PRINTF("in SPIQ *** Error suspending RECV Task\n")
34 }
35 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task
36 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
37 }
38
39 //***************************
40 // RESTART THE SPACEWIRE LINK
41 spacewire_configure_link();
42
43 //*******************
44 // RESTART THE SYSTEM
45 //ioctl(fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS); // clear statistics
46 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
47 if (status != RTEMS_SUCCESSFUL) {
48 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
49 }
50 status = rtems_task_restart(Task_id[TASKID_RECV], 1);
51 if ( status != RTEMS_SUCCESSFUL) {
52 PRINTF("in SPIQ *** Error restarting RECV Task\n")
53 }
54 enter_mode(lfrMode, NULL); // enter the mode that was running before the SpaceWire interruption
55 }
56 }
57 }
58
59 int spacewire_configure_link( void )
60 {
61 rtems_status_code status;
62
63 close(fdSPW); // close the device if it is already open
64 BOOT_PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
65 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
66 if ( fdSPW<0 ) {
67 PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
68 }
69
70 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, -1) != RTEMS_SUCCESSFUL){
71 PRINTF(".")
72 fflush( stdout );
73 close( fdSPW ); // close the device
74 fdSPW = open( GRSPW_DEVICE_NAME, O_RDWR ); // open the device. the open call reset the hardware
75 if (fdSPW<0) {
76 PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
77 }
78 rtems_task_wake_after(100);
79 }
80
81 BOOT_PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
82
83 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
84 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
85
86 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
87 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
88 //
89 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
90 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
91 //
92 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
93 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
94 //
95 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
96 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
97 //
98 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
99 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
100 //
101 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
102 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
103 //
104 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
105 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
106
107 BOOT_PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
108
109 return RTEMS_SUCCESSFUL;
110 }
111
112 int spacewire_wait_for_link(void)
113 {
114 unsigned int i;
115 int linkStatus;
116 rtems_status_code status = RTEMS_UNSATISFIED;
117
118 for(i = 0; i< 10; i++){
119 PRINTF(".")
120 fflush( stdout );
121 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
122 PRINTF1("in spacewire_wait_for_link *** link status is: %s\n", lstates[linkStatus])
123 if ( linkStatus == 5) {
124 PRINTF("in spacewire_wait_for_link *** link is running\n")
125 status = RTEMS_SUCCESSFUL;
126 break;
127 }
128 rtems_task_wake_after(100);
129 }
130
131 return status;
132 }
133
134 void spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
135 {
136 unsigned int *spwptr = (unsigned int*) regAddr;
137
138 if (val == 1) {
139 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
140 }
141 if (val== 0) {
142 *spwptr = *spwptr & 0xffdfffff;
143 }
144 }
145
146 void spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
147 {
148 unsigned int *spwptr = (unsigned int*) regAddr;
149
150 if (val == 1)
151 {
152 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
153 }
154 if (val== 0)
155 {
156 *spwptr = *spwptr & 0xfffdffff;
157 }
158 }
159
160 void spacewire_compute_stats_offsets()
161 {
162 spw_stats spacewire_stats_grspw;
163 rtems_status_code status;
164
165 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
166
167 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
168 + spacewire_stats.packets_received;
169 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
170 + spacewire_stats.packets_sent;
171 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
172 + spacewire_stats.parity_err;
173 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
174 + spacewire_stats.disconnect_err;
175 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
176 + spacewire_stats.escape_err;
177 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
178 + spacewire_stats.credit_err;
179 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
180 + spacewire_stats.write_sync_err;
181 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
182 + spacewire_stats.rx_rmap_header_crc_err;
183 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
184 + spacewire_stats.rx_rmap_data_crc_err;
185 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
186 + spacewire_stats.early_ep;
187 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
188 + spacewire_stats.invalid_address;
189 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
190 + spacewire_stats.rx_eep_err;
191 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
192 + spacewire_stats.rx_truncated;
193 }
194
195 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
196 {
197 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
198 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
199 //}
200 }
@@ -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 4 15:16:59 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Oct 8 10:15:40 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=13 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DPRINT_STACK_REPORT
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=13 -DPRINT_MESSAGES_ON_CONSOLE
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 *** cpu_usage_report *** gsa *** stack_report
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 CONFIG += console verbose stack_report cpu_usage_report
4 CONFIG += console verbose
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
@@ -25,6 +25,10 contains( CONFIG, stack_report ) {
25 DEFINES += PRINT_STACK_REPORT
25 DEFINES += PRINT_STACK_REPORT
26 }
26 }
27
27
28 contains( CONFIG, boot_messages ) {
29 DEFINES += BOOT_MESSAGES
30 }
31
28 TARGET = fsw
32 TARGET = fsw
29 contains( CONFIG, gsa ) {
33 contains( CONFIG, gsa ) {
30 DEFINES += GSA
34 DEFINES += GSA
@@ -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-04T15:45:21. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-08T06:59:51. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -19,12 +19,10
19
19
20 #include "fsw_spacewire.h"
20 #include "fsw_spacewire.h"
21
21
22 extern int sched_yield( void );
22 extern rtems_name misc_name[5];
23 extern int errno;
23 extern rtems_id misc_id[5];
24 extern rtems_id Task_id[ ]; /* array of task ids */
24 extern rtems_name Task_name[20]; /* array of task names */
25 extern rtems_name Task_name[ ]; /* array of task names */
25 extern rtems_id Task_id[20]; /* array of task ids */
26 extern rtems_name misc_id[ ];
27 extern rtems_name misc_name[ ]; /* array of miscellaneous names for rtems objects */
28 extern unsigned int maxCount;
26 extern unsigned int maxCount;
29 extern int fdSPW; // grspw file descriptor
27 extern int fdSPW; // grspw file descriptor
30 extern int fdUART; // uart file descriptor
28 extern int fdUART; // uart file descriptor
@@ -45,8 +43,7 rtems_task wfrm_task(rtems_task_argument
45 int create_names( void );
43 int create_names( void );
46 int create_all_tasks( void );
44 int create_all_tasks( void );
47 int start_all_tasks( void );
45 int start_all_tasks( void );
48 //
46 rtems_status_code create_message_queues( void );
49 int create_message_queues( void );
50 //
47 //
51 void init_parameter_dump( void );
48 void init_parameter_dump( void );
52 void init_local_mode_parameters( void );
49 void init_local_mode_parameters( void );
@@ -56,4 +53,7 extern int rtems_cpu_usage_report( void
56 extern int rtems_cpu_usage_reset( void );
53 extern int rtems_cpu_usage_reset( void );
57 extern void rtems_stack_checker_report_usage( void );
54 extern void rtems_stack_checker_report_usage( void );
58
55
56 extern int sched_yield( void );
57 extern int errno;
58
59 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
59 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -31,4 +31,6 rtems_task stat_task(rtems_task_argument
31 rtems_task hous_task(rtems_task_argument argument);
31 rtems_task hous_task(rtems_task_argument argument);
32 rtems_task send_task(rtems_task_argument argument);
32 rtems_task send_task(rtems_task_argument argument);
33
33
34 rtems_id get_pkts_queue_id( void );
35
34 #endif // FSW_MISC_H_INCLUDED
36 #endif // FSW_MISC_H_INCLUDED
@@ -118,10 +118,8
118 #define TASK_PRIORITY_SPIQ 5
118 #define TASK_PRIORITY_SPIQ 5
119 #define TASK_PRIORITY_SMIQ 10
119 #define TASK_PRIORITY_SMIQ 10
120 //
120 //
121 #define TASK_PRIORITY_SEND 30
121 #define TASK_PRIORITY_RECV 20
122 //
122 #define TASK_PRIORITY_ACTN 30
123 #define TASK_PRIORITY_RECV 40
124 #define TASK_PRIORITY_ACTN 40
125 //
123 //
126 #define TASK_PRIORITY_HOUS 40
124 #define TASK_PRIORITY_HOUS 40
127 #define TASK_PRIORITY_CWF1 40
125 #define TASK_PRIORITY_CWF1 40
@@ -129,6 +127,8
129 #define TASK_PRIORITY_WFRM 40
127 #define TASK_PRIORITY_WFRM 40
130 #define TASK_PRIORITY_CWF3 40
128 #define TASK_PRIORITY_CWF3 40
131 //
129 //
130 #define TASK_PRIORITY_SEND 40
131 //
132 #define TASK_PRIORITY_AVF0 60
132 #define TASK_PRIORITY_AVF0 60
133 #define TASK_PRIORITY_BPF0 60
133 #define TASK_PRIORITY_BPF0 60
134 #define TASK_PRIORITY_MATR 100
134 #define TASK_PRIORITY_MATR 100
@@ -154,12 +154,32
154 #define PRINTF2(x,y,z) ;
154 #define PRINTF2(x,y,z) ;
155 #endif
155 #endif
156
156
157 #ifdef BOOT_MESSAGES
158 #define BOOT_PRINTF(x) printf(x);
159 #define BOOT_PRINTF1(x,y) printf(x,y);
160 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
161 #else
162 #define BOOT_PRINTF(x) ;
163 #define BOOT_PRINTF1(x,y) ;
164 #define BOOT_PRINTF2(x,y,z) ;
165 #endif
166
167 #ifdef DEBUG_MESSAGES
168 #define DEBUG_PRINTF(x) printf(x);
169 #define DEBUG_PRINTF1(x,y) printf(x,y);
170 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
171 #else
172 #define DEBUG_PRINTF(x) ;
173 #define DEBUG_PRINTF1(x,y) ;
174 #define DEBUG_PRINTF2(x,y,z) ;
175 #endif
176
157 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
177 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
158
178
159 #define NB_SAMPLES_PER_SNAPSHOT 2048
179 #define NB_SAMPLES_PER_SNAPSHOT 2048
160 #define TIME_OFFSET 2
180 #define TIME_OFFSET 2
161 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
181 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
162 #define NB_BYTES_SWF_BLK 2 * 6
182 #define NB_BYTES_SWF_BLK (2 * 6)
163 #define NB_WORDS_SWF_BLK 3
183 #define NB_WORDS_SWF_BLK 3
164
184
165 //******************
185 //******************
@@ -32,8 +32,6 extern volatile int spec_mat_f2_bis[ ];
32 extern volatile int spec_mat_f0_0_bis[ ];
32 extern volatile int spec_mat_f0_0_bis[ ];
33 extern volatile int spec_mat_f0_1_bis[ ];
33 extern volatile int spec_mat_f0_1_bis[ ];
34
34
35 extern rtems_id Task_id[ ]; /* array of task ids */
36
37 // parameters
35 // parameters
38 extern struct param_local_str param_local;
36 extern struct param_local_str param_local;
39
37
@@ -62,7 +60,7 void BP2_set(float * compressed_spec_mat
62 //
60 //
63 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
61 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
64 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
62 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
65 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
63 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
66 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
64 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
67 void fill_averaged_spectral_matrix();
65 void fill_averaged_spectral_matrix();
68 void reset_spectral_matrix_regs();
66 void reset_spectral_matrix_regs();
@@ -33,7 +33,7 void updateLFRCurrentMode();
33
33
34 //*********************
34 //*********************
35 // ACCEPTANCE FUNCTIONS
35 // ACCEPTANCE FUNCTIONS
36 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
36 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_id);
37 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
37 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
38
38
39 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
39 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
@@ -47,17 +47,17 rtems_task dumb_task( rtems_task_argumen
47
47
48 //***********
48 //***********
49 // TC ACTIONS
49 // TC ACTIONS
50 int action_reset(ccsdsTelecommandPacket_t *TC);
50 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
51 int action_load_common_par(ccsdsTelecommandPacket_t *TC);
51 int action_load_common_par(ccsdsTelecommandPacket_t *TC);
52 int action_load_normal_par(ccsdsTelecommandPacket_t *TC);
52 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
53 int action_load_burst_par(ccsdsTelecommandPacket_t *TC);
53 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
54 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC);
54 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
55 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC);
55 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
56 int action_dump_par(ccsdsTelecommandPacket_t *TC);
56 int action_dump_par(ccsdsTelecommandPacket_t *TC);
57 int action_enter_mode(ccsdsTelecommandPacket_t *TC);
57 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
58 int action_update_info(ccsdsTelecommandPacket_t *TC);
58 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
59 int action_enable_calibration(ccsdsTelecommandPacket_t *TC);
59 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
60 int action_disable_calibration(ccsdsTelecommandPacket_t *TC);
60 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
61 int action_update_time(ccsdsTelecommandPacket_t *TC);
61 int action_update_time(ccsdsTelecommandPacket_t *TC);
62
62
63 // mode transition
63 // mode transition
@@ -75,11 +75,11 int suspend_science_tasks();
75 // other functions
75 // other functions
76 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
76 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
77 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
77 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
78 void close_action(ccsdsTelecommandPacket_t *TC, int result);
78 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
79 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
79 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
80 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC);
80 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
81 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC);
81 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
82 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC);
82 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
83
83
84 #endif // TC_HANDLER_H_INCLUDED
84 #endif // TC_HANDLER_H_INCLUDED
85
85
@@ -16,7 +16,6
16
16
17 //#include <sys/ioctl.h>
17 //#include <sys/ioctl.h>
18
18
19 extern rtems_id Task_id[]; /* array of task ids */
20 extern int fdSPW;
19 extern int fdSPW;
21 extern volatile int wf_snap_f0[ ];
20 extern volatile int wf_snap_f0[ ];
22 //
21 //
@@ -48,8 +47,8 int init_header_continuous_wf_table(unsi
48 //
47 //
49 void reset_waveforms( void );
48 void reset_waveforms( void );
50
49
51 int send_waveform_SWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF);
50 int send_waveform_SWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id);
52 int send_waveform_CWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF);
51 int send_waveform_CWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id);
53
52
54 //**************
53 //**************
55 // wfp registers
54 // wfp registers
@@ -6,10 +6,10
6 #include <fsw_params.h>
6 #include <fsw_params.h>
7
7
8 // RTEMS GLOBAL VARIABLES
8 // RTEMS GLOBAL VARIABLES
9 rtems_name misc_name[5];
9 rtems_name misc_name[5];
10 rtems_name misc_id[5];
10 rtems_id misc_id[5];
11 rtems_id Task_id[20]; /* array of task ids */
11 rtems_name Task_name[20]; /* array of task names */
12 rtems_name Task_name[20]; /* array of task names */
12 rtems_id Task_id[20]; /* array of task ids */
13 unsigned int maxCount;
13 unsigned int maxCount;
14 int fdSPW = 0;
14 int fdSPW = 0;
15 int fdUART = 0;
15 int fdUART = 0;
@@ -23,7 +23,7
23 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
23 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
24 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_DRIVERS 16
25 #define CONFIGURE_MAXIMUM_PERIODS 5
25 #define CONFIGURE_MAXIMUM_PERIODS 5
26 #define CONFIGURE_MAXIMUM_TIMERS 5
26 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
27 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
27 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
28 #ifdef PRINT_STACK_REPORT
28 #ifdef PRINT_STACK_REPORT
29 #define CONFIGURE_STACK_CHECKER_ENABLED
29 #define CONFIGURE_STACK_CHECKER_ENABLED
@@ -54,11 +54,11 rtems_task Init( rtems_task_argument ign
54 rtems_status_code status;
54 rtems_status_code status;
55 rtems_isr_entry old_isr_handler;
55 rtems_isr_entry old_isr_handler;
56
56
57 PRINTF("\n\n\n\n\n")
57 BOOT_PRINTF("\n\n\n\n\n")
58 PRINTF("***************************\n")
58 BOOT_PRINTF("***************************\n")
59 PRINTF("** START Flight Software **\n")
59 BOOT_PRINTF("** START Flight Software **\n")
60 PRINTF("***************************\n")
60 BOOT_PRINTF("***************************\n")
61 PRINTF("\n\n")
61 BOOT_PRINTF("\n\n")
62
62
63 //send_console_outputs_on_apbuart_port();
63 //send_console_outputs_on_apbuart_port();
64 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
64 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
@@ -112,7 +112,7 rtems_task Init( rtems_task_argument ign
112 IRQ_SPARC_SM, spectral_matrices_isr_simu );
112 IRQ_SPARC_SM, spectral_matrices_isr_simu );
113 #endif
113 #endif
114
114
115 PRINTF("delete INIT\n")
115 BOOT_PRINTF("delete INIT\n")
116
116
117 status = rtems_task_delete(RTEMS_SELF);
117 status = rtems_task_delete(RTEMS_SELF);
118
118
@@ -182,9 +182,9 void init_local_mode_parameters( void )
182 set_local_sbm2_nb_cwf_max();
182 set_local_sbm2_nb_cwf_max();
183 set_local_nb_interrupt_f0_MAX();
183 set_local_nb_interrupt_f0_MAX();
184
184
185 PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
185 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
186 PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
186 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
187 PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
187 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
188
188
189 reset_local_sbm1_nb_cwf_sent();
189 reset_local_sbm1_nb_cwf_sent();
190 reset_local_sbm2_nb_cwf_sent();
190 reset_local_sbm2_nb_cwf_sent();
@@ -343,7 +343,7 int create_all_tasks( void )
343 // SEND
343 // SEND
344 status = rtems_task_create(
344 status = rtems_task_create(
345 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
345 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
346 RTEMS_DEFAULT_MODES,
346 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
348 );
348 );
349
349
@@ -356,96 +356,100 int start_all_tasks( void )
356
356
357 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
357 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
358 if (status!=RTEMS_SUCCESSFUL) {
358 if (status!=RTEMS_SUCCESSFUL) {
359 PRINTF("in INIT *** Error starting TASK_SPIQ\n")
359 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
360 }
361
362 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
363 if (status!=RTEMS_SUCCESSFUL) {
364 PRINTF("in INIT *** Error starting TASK_RECV\n")
365 }
366
367 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
368 if (status!=RTEMS_SUCCESSFUL) {
369 PRINTF("in INIT *** Error starting TASK_ACTN\n")
370 }
360 }
371
361
372 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
362 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
373 if (status!=RTEMS_SUCCESSFUL) {
363 if (status!=RTEMS_SUCCESSFUL) {
374 PRINTF("in INIT *** Error starting TASK_BPPR\n")
364 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
365 }
366
367 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
368 if (status!=RTEMS_SUCCESSFUL) {
369 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
370 }
371
372 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
373 if (status!=RTEMS_SUCCESSFUL) {
374 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
375 }
376
377 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
378 if (status!=RTEMS_SUCCESSFUL) {
379 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
375 }
380 }
376
381
377 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
382 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
378 if (status!=RTEMS_SUCCESSFUL) {
383 if (status!=RTEMS_SUCCESSFUL) {
379 PRINTF("in INIT *** Error starting TASK_STAT\n")
384 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
380 }
385 }
381
386
382 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
387 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
383 if (status!=RTEMS_SUCCESSFUL) {
388 if (status!=RTEMS_SUCCESSFUL) {
384 PRINTF("in INIT *** Error starting TASK_AVF0\n")
389 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
385 }
390 }
386
391
387 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
392 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
388 if (status!=RTEMS_SUCCESSFUL) {
393 if (status!=RTEMS_SUCCESSFUL) {
389 PRINTF("in INIT *** Error starting TASK_BPF0\n")
394 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
390 }
395 }
391
396
392 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
397 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
393 if (status!=RTEMS_SUCCESSFUL) {
398 if (status!=RTEMS_SUCCESSFUL) {
394 PRINTF("in INIT *** Error starting TASK_WFRM\n")
399 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
395 }
400 }
396
401
397 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
402 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
398 if (status!=RTEMS_SUCCESSFUL) {
403 if (status!=RTEMS_SUCCESSFUL) {
399 PRINTF("in INIT *** Error starting TASK_DUMB\n")
404 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
400 }
405 }
401
406
402 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
407 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
403 if (status!=RTEMS_SUCCESSFUL) {
408 if (status!=RTEMS_SUCCESSFUL) {
404 PRINTF("in INIT *** Error starting TASK_HOUS\n")
409 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
405 }
410 }
406
411
407 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
412 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
408 if (status!=RTEMS_SUCCESSFUL) {
413 if (status!=RTEMS_SUCCESSFUL) {
409 PRINTF("in INIT *** Error starting TASK_MATR\n")
414 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
410 }
415 }
411
416
412 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
417 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
413 if (status!=RTEMS_SUCCESSFUL) {
418 if (status!=RTEMS_SUCCESSFUL) {
414 PRINTF("in INIT *** Error starting TASK_CWF3\n")
419 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
415 }
420 }
416
421
417 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
422 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
418 if (status!=RTEMS_SUCCESSFUL) {
423 if (status!=RTEMS_SUCCESSFUL) {
419 PRINTF("in INIT *** Error starting TASK_CWF2\n")
424 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
420 }
425 }
421
426
422 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
427 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
423 if (status!=RTEMS_SUCCESSFUL) {
428 if (status!=RTEMS_SUCCESSFUL) {
424 PRINTF("in INIT *** Error starting TASK_CWF1\n")
429 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
425 }
426 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
427 if (status!=RTEMS_SUCCESSFUL) {
428 PRINTF("in INIT *** Error starting TASK_SEND\n")
429 }
430 }
430
431
431 return 0;
432 return 0;
432 }
433 }
433
434
434 int create_message_queues( void )
435 rtems_status_code create_message_queues( void )
435 {
436 {
436 rtems_status_code status;
437 rtems_status_code status;
438 rtems_status_code ret;
439 rtems_id queue_id;
440
441 ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_SIZE,
442 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
443 if (ret != RTEMS_SUCCESSFUL) {
444 BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret)
445 }
437
446
438 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
447 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
439 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[QUEUE_QUEU] );
448 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
440 if (status!=RTEMS_SUCCESSFUL) {
449 if (status != RTEMS_SUCCESSFUL) {
441 PRINTF("in create_message_queues *** ERR creating QUEU\n")
450 ret = status;
451 BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret)
442 }
452 }
443
453
444 status = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_SIZE,
454 return ret;
445 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[QUEUE_PKTS] );
446 if (status!=RTEMS_SUCCESSFUL) {
447 PRINTF("in create_message_queues *** ERR creating PKTS\n")
448 }
449
450 return 0;
451 }
455 }
@@ -8,9 +8,9 int configure_timer(gptimer_regs_t *gpti
8 rtems_isr_entry old_isr_handler;
8 rtems_isr_entry old_isr_handler;
9
9
10 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
10 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
11 if (status==RTEMS_SUCCESSFUL)
11 if (status!=RTEMS_SUCCESSFUL)
12 {
12 {
13 PRINTF("In configure_timer *** rtems_interrupt_catch successfullly configured\n")
13 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
14 }
14 }
15
15
16 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
16 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
@@ -125,7 +125,7 int set_apbuart_scaler_reload_register(u
125 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
125 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
126
126
127 apbuart_regs->scaler = value;
127 apbuart_regs->scaler = value;
128 PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
128 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
129
129
130 return 0;
130 return 0;
131 }
131 }
@@ -139,7 +139,7 rtems_task stat_task(rtems_task_argument
139 int j;
139 int j;
140 i = 0;
140 i = 0;
141 j = 0;
141 j = 0;
142 PRINTF("in STAT *** \n")
142 BOOT_PRINTF("in STAT *** \n")
143 while(1){
143 while(1){
144 rtems_task_wake_after(1000);
144 rtems_task_wake_after(1000);
145 PRINTF1("%d\n", j)
145 PRINTF1("%d\n", j)
@@ -159,6 +159,7 rtems_task hous_task(rtems_task_argument
159 {
159 {
160 rtems_status_code status;
160 rtems_status_code status;
161 spw_ioctl_pkt_send spw_ioctl_send;
161 spw_ioctl_pkt_send spw_ioctl_send;
162 rtems_id queue_id;
162
163
163 spw_ioctl_send.hlen = 0;
164 spw_ioctl_send.hlen = 0;
164 spw_ioctl_send.hdr = NULL;
165 spw_ioctl_send.hdr = NULL;
@@ -166,7 +167,13 rtems_task hous_task(rtems_task_argument
166 spw_ioctl_send.data = (char*) &housekeeping_packet;
167 spw_ioctl_send.data = (char*) &housekeeping_packet;
167 spw_ioctl_send.options = 0;
168 spw_ioctl_send.options = 0;
168
169
169 PRINTF("in HOUS ***\n")
170 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
171 if (status != RTEMS_SUCCESSFUL)
172 {
173 PRINTF1("in HOUS *** ERR %d\n", status)
174 }
175
176 BOOT_PRINTF("in HOUS ***\n")
170
177
171 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
178 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
172 status = rtems_rate_monotonic_create( HK_name, &HK_id );
179 status = rtems_rate_monotonic_create( HK_name, &HK_id );
@@ -195,7 +202,7 rtems_task hous_task(rtems_task_argument
195 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
202 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
196 }
203 }
197 else {
204 else {
198 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
205 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
199 }
206 }
200
207
201 while(1){ // launch the rate monotonic task
208 while(1){ // launch the rate monotonic task
@@ -215,9 +222,9 rtems_task hous_task(rtems_task_argument
215 update_spacewire_statistics();
222 update_spacewire_statistics();
216
223
217 // SEND PACKET
224 // SEND PACKET
218 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
225 status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_PKTS_SIZE);
219 if (status != RTEMS_SUCCESSFUL) {
226 if (status != RTEMS_SUCCESSFUL) {
220 PRINTF1("in HOUS *** ERR %d\n", (int) status)
227 PRINTF1("in HOUS *** ERR %d\n", status)
221 }
228 }
222 }
229 }
223 }
230 }
@@ -235,29 +242,48 rtems_task send_task( rtems_task_argumen
235 spw_ioctl_pkt_send spw_ioctl_send; // incoming spw_ioctl_pkt_send structure
242 spw_ioctl_pkt_send spw_ioctl_send; // incoming spw_ioctl_pkt_send structure
236 size_t size; // size of the incoming TC packet
243 size_t size; // size of the incoming TC packet
237 u_int32_t count;
244 u_int32_t count;
245 rtems_id queue_id;
238
246
239 PRINTF("in SEND *** \n")
247 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
248 if (status != RTEMS_SUCCESSFUL)
249 {
250 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
251 }
252
253 BOOT_PRINTF("in SEND *** \n")
240
254
241 while(1)
255 while(1)
242 {
256 {
243 status = rtems_message_queue_receive(misc_id[QUEUE_PKTS], (char*) &spw_ioctl_send, &size,
257 status = rtems_message_queue_receive( queue_id, (char*) &spw_ioctl_send, &size,
244 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
258 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
259
245 if (status!=RTEMS_SUCCESSFUL)
260 if (status!=RTEMS_SUCCESSFUL)
246 {
261 {
247 PRINTF1("in SEND *** (1) ERR = %d \n", status)
262 PRINTF1("in SEND *** (1) ERR = %d\n", status)
248 }
263 }
249 else
264 else
250 {
265 {
251 status = write_spw(&spw_ioctl_send);
266 if (spw_ioctl_send.hlen == 0)
252 if (status != RTEMS_SUCCESSFUL) {
267 {
253 PRINTF("in SEND *** TRAFFIC JAM\n")
268 status = write( fdSPW, spw_ioctl_send.data, spw_ioctl_send.dlen );
269 if (status == -1){
270 PRINTF2("in SEND *** (2.a) ERR = %d, dlen = %d\n", status, spw_ioctl_send.dlen)
271 }
272 }
273 else
274 {
275 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
276 if (status == -1){
277 PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send.dlen)
278 PRINTF1(" hlen = %d\n", spw_ioctl_send.hlen)
279 }
254 }
280 }
255 }
281 }
256
282
257 status = rtems_message_queue_get_number_pending( misc_id[QUEUE_PKTS], &count );
283 status = rtems_message_queue_get_number_pending( queue_id, &count );
258 if (status != RTEMS_SUCCESSFUL)
284 if (status != RTEMS_SUCCESSFUL)
259 {
285 {
260 PRINTF1("in SEND *** (2) ERR = %d \n", status)
286 PRINTF1("in SEND *** (3) ERR = %d\n", status)
261 }
287 }
262 else
288 else
263 {
289 {
@@ -269,8 +295,19 rtems_task send_task( rtems_task_argumen
269 }
295 }
270 }
296 }
271
297
298 rtems_id get_pkts_queue_id( void )
299 {
300 rtems_id queue_id;
301 rtems_status_code status;
302
303 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
304 if (status != RTEMS_SUCCESSFUL)
305 {
306 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
307 }
308 return queue_id;
309 }
272
310
273
311
274
312
275
313
276
@@ -96,7 +96,7 rtems_task smiq_task(rtems_task_argument
96 rtems_event_set event_out;
96 rtems_event_set event_out;
97 unsigned int nb_interrupt_f0 = 0;
97 unsigned int nb_interrupt_f0 = 0;
98
98
99 PRINTF("in SMIQ *** \n")
99 BOOT_PRINTF("in SMIQ *** \n")
100
100
101 while(1){
101 while(1){
102 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
102 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
@@ -139,7 +139,7 rtems_task spw_bppr_task(rtems_task_argu
139 //static int nb_average_f1 = 0;
139 //static int nb_average_f1 = 0;
140 //static int nb_average_f2 = 0;
140 //static int nb_average_f2 = 0;
141
141
142 printf("in BPPR ***\n");
142 BOOT_PRINTF("in BPPR ***\n");
143
143
144 while(true){ // wait for an event to begin with the processing
144 while(true){ // wait for an event to begin with the processing
145 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
145 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
@@ -175,7 +175,7 rtems_task avf0_task(rtems_task_argument
175
175
176 nb_average = 0;
176 nb_average = 0;
177
177
178 PRINTF("in AVFO *** \n")
178 BOOT_PRINTF("in AVFO *** \n")
179
179
180 while(1){
180 while(1){
181 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
181 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
@@ -204,7 +204,7 rtems_task bpf0_task(rtems_task_argument
204 {
204 {
205 rtems_event_set event_out;
205 rtems_event_set event_out;
206
206
207 PRINTF("in BPFO *** \n")
207 BOOT_PRINTF("in BPFO *** \n")
208
208
209 while(1){
209 while(1){
210 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
210 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
@@ -218,11 +218,19 rtems_task matr_task(rtems_task_argument
218 {
218 {
219 spw_ioctl_pkt_send spw_ioctl_send_ASM;
219 spw_ioctl_pkt_send spw_ioctl_send_ASM;
220 rtems_event_set event_out;
220 rtems_event_set event_out;
221 rtems_status_code status;
222 rtems_id queue_id;
221 Header_TM_LFR_SCIENCE_ASM_t headerASM;
223 Header_TM_LFR_SCIENCE_ASM_t headerASM;
222
224
223 init_header_asm( &headerASM );
225 init_header_asm( &headerASM );
224
226
225 PRINTF("in MATR *** \n")
227 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
228 if (status != RTEMS_SUCCESSFUL)
229 {
230 PRINTF1("in MATR *** ERR getting queue id, %d\n", status)
231 }
232
233 BOOT_PRINTF("in MATR *** \n")
226
234
227 fill_averaged_spectral_matrix( );
235 fill_averaged_spectral_matrix( );
228
236
@@ -235,7 +243,7 rtems_task matr_task(rtems_task_argument
235 #endif
243 #endif
236 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
244 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
237
245
238 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM);
246 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
239 }
247 }
240 }
248 }
241
249
@@ -509,7 +517,7 void init_header_asm( Header_TM_LFR_SCIE
509 }
517 }
510
518
511 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
519 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
512 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send)
520 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
513 {
521 {
514 unsigned int i;
522 unsigned int i;
515 unsigned int length = 0;
523 unsigned int length = 0;
@@ -549,19 +557,9 void send_spectral_matrix(Header_TM_LFR_
549 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
557 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
550 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
558 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
551 // SEND PACKET
559 // SEND PACKET
552 status = write_spw(spw_ioctl_send);
560 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_PKTS_SIZE);
553 if (status != RTEMS_SUCCESSFUL) {
561 if (status != RTEMS_SUCCESSFUL) {
554 while (true) {
562 printf("in send_spectral_matrix *** ERR %d\n", (int) status);
555 if (status != RTEMS_SUCCESSFUL) {
556 status = write_spw(spw_ioctl_send);
557 //PRINTF1("%d", i)
558 sched_yield();
559 }
560 else {
561 //PRINTF("\n")
562 break;
563 }
564 }
565 }
563 }
566 }
564 }
567 }
565 }
@@ -79,7 +79,7 void updateLFRCurrentMode()
79
79
80 //*********************
80 //*********************
81 // ACCEPTANCE FUNCTIONS
81 // ACCEPTANCE FUNCTIONS
82 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
82 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_id)
83 {
83 {
84 int ret = 0;
84 int ret = 0;
85 rtems_status_code status;
85 rtems_status_code status;
@@ -137,7 +137,7 int TC_acceptance(ccsdsTelecommandPacket
137 status = write( fdSPW, (char *) &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4);
137 status = write( fdSPW, (char *) &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4);
138 }
138 }
139 else { // send valid TC to the action launcher
139 else { // send valid TC to the action launcher
140 status = rtems_message_queue_send( misc_id[QUEUE_QUEU], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
140 status = rtems_message_queue_send( queue_id, TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
141 ret = -1;
141 ret = -1;
142 }
142 }
143 return ret;
143 return ret;
@@ -371,10 +371,18 rtems_task recv_task( rtems_task_argumen
371 unsigned int data_length = 0;
371 unsigned int data_length = 0;
372 ccsdsTelecommandPacket_t currentTC;
372 ccsdsTelecommandPacket_t currentTC;
373 char data[100];
373 char data[100];
374 rtems_status_code status;
375 rtems_id queue_id;
374
376
375 for(i=0; i<100; i++) data[i] = 0;
377 for(i=0; i<100; i++) data[i] = 0;
376
378
377 PRINTF("in RECV *** \n")
379 status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_id );
380 if (status != RTEMS_SUCCESSFUL)
381 {
382 PRINTF1("in RECV *** ERR getting queue id, %d\n", status)
383 }
384
385 BOOT_PRINTF("in RECV *** \n")
378
386
379 while(1)
387 while(1)
380 {
388 {
@@ -397,7 +405,7 rtems_task recv_task( rtems_task_argumen
397 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
405 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
398 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
406 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
399 // CHECK THE TC AND BUILD THE APPROPRIATE TM
407 // CHECK THE TC AND BUILD THE APPROPRIATE TM
400 data_length = TC_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
408 data_length = TC_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt, queue_id);
401 if (data_length!=-1)
409 if (data_length!=-1)
402 {
410 {
403 }
411 }
@@ -413,15 +421,29 rtems_task actn_task( rtems_task_argumen
413 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
421 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
414 size_t size; // size of the incoming TC packet
422 size_t size; // size of the incoming TC packet
415 unsigned char subtype; // subtype of the current TC packet
423 unsigned char subtype; // subtype of the current TC packet
424 rtems_id queue_rcv_id;
425 rtems_id queue_snd_id;
426
427 status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_rcv_id );
428 if (status != RTEMS_SUCCESSFUL)
429 {
430 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
431 }
432
433 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_snd_id );
434 if (status != RTEMS_SUCCESSFUL)
435 {
436 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
437 }
416
438
417 result = LFR_SUCCESSFUL;
439 result = LFR_SUCCESSFUL;
418 subtype = 0; // subtype of the current TC packet
440 subtype = 0; // subtype of the current TC packet
419
441
420 PRINTF("in ACTN *** \n")
442 BOOT_PRINTF("in ACTN *** \n")
421
443
422 while(1)
444 while(1)
423 {
445 {
424 status = rtems_message_queue_receive(misc_id[QUEUE_QUEU], (char*) &TC, &size,
446 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
425 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
447 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
426 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
448 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
427 else
449 else
@@ -430,63 +452,63 rtems_task actn_task( rtems_task_argumen
430 switch(subtype)
452 switch(subtype)
431 {
453 {
432 case TC_SUBTYPE_RESET:
454 case TC_SUBTYPE_RESET:
433 result = action_reset( &TC );
455 result = action_reset( &TC, queue_snd_id );
434 close_action( &TC, result );
456 close_action( &TC, result, queue_snd_id );
435 break;
457 break;
436 //
458 //
437 case TC_SUBTYPE_LOAD_COMM:
459 case TC_SUBTYPE_LOAD_COMM:
438 result = action_load_common_par( &TC );
460 result = action_load_common_par( &TC );
439 close_action( &TC, result );
461 close_action( &TC, result, queue_snd_id );
440 break;
462 break;
441 //
463 //
442 case TC_SUBTYPE_LOAD_NORM:
464 case TC_SUBTYPE_LOAD_NORM:
443 result = action_load_normal_par( &TC );
465 result = action_load_normal_par( &TC, queue_snd_id );
444 close_action( &TC, result );
466 close_action( &TC, result, queue_snd_id );
445 break;
467 break;
446 //
468 //
447 case TC_SUBTYPE_LOAD_BURST:
469 case TC_SUBTYPE_LOAD_BURST:
448 result = action_load_burst_par( &TC );
470 result = action_load_burst_par( &TC, queue_snd_id );
449 close_action( &TC, result );
471 close_action( &TC, result, queue_snd_id );
450 break;
472 break;
451 //
473 //
452 case TC_SUBTYPE_LOAD_SBM1:
474 case TC_SUBTYPE_LOAD_SBM1:
453 result = action_load_sbm1_par( &TC );
475 result = action_load_sbm1_par( &TC, queue_snd_id );
454 close_action( &TC, result );
476 close_action( &TC, result, queue_snd_id );
455 break;
477 break;
456 //
478 //
457 case TC_SUBTYPE_LOAD_SBM2:
479 case TC_SUBTYPE_LOAD_SBM2:
458 result = action_load_sbm2_par( &TC );
480 result = action_load_sbm2_par( &TC, queue_snd_id );
459 close_action( &TC, result );
481 close_action( &TC, result, queue_snd_id );
460 break;
482 break;
461 //
483 //
462 case TC_SUBTYPE_DUMP:
484 case TC_SUBTYPE_DUMP:
463 result = action_dump_par( &TC );
485 result = action_dump_par( &TC );
464 close_action( &TC, result );
486 close_action( &TC, result, queue_snd_id );
465 break;
487 break;
466 //
488 //
467 case TC_SUBTYPE_ENTER:
489 case TC_SUBTYPE_ENTER:
468 result = action_enter_mode( &TC );
490 result = action_enter_mode( &TC, queue_snd_id );
469 close_action( &TC, result );
491 close_action( &TC, result, queue_snd_id );
470 break;
492 break;
471 //
493 //
472 case TC_SUBTYPE_UPDT_INFO:
494 case TC_SUBTYPE_UPDT_INFO:
473 result = action_update_info( &TC );
495 result = action_update_info( &TC, queue_snd_id );
474 close_action( &TC, result );
496 close_action( &TC, result, queue_snd_id );
475 break;
497 break;
476 //
498 //
477 case TC_SUBTYPE_EN_CAL:
499 case TC_SUBTYPE_EN_CAL:
478 result = action_enable_calibration( &TC );
500 result = action_enable_calibration( &TC, queue_snd_id );
479 close_action( &TC, result );
501 close_action( &TC, result, queue_snd_id );
480 break;
502 break;
481 //
503 //
482 case TC_SUBTYPE_DIS_CAL:
504 case TC_SUBTYPE_DIS_CAL:
483 result = action_disable_calibration( &TC );
505 result = action_disable_calibration( &TC, queue_snd_id );
484 close_action( &TC, result );
506 close_action( &TC, result, queue_snd_id );
485 break;
507 break;
486 //
508 //
487 case TC_SUBTYPE_UPDT_TIME:
509 case TC_SUBTYPE_UPDT_TIME:
488 result = action_update_time( &TC );
510 result = action_update_time( &TC );
489 close_action( &TC, result );
511 close_action( &TC, result, queue_snd_id );
490 break;
512 break;
491 //
513 //
492 default:
514 default:
@@ -504,7 +526,7 rtems_task dumb_task( rtems_task_argumen
504 unsigned int fine_time = 0;
526 unsigned int fine_time = 0;
505 rtems_event_set event_out;
527 rtems_event_set event_out;
506
528
507 PRINTF("in DUMB *** \n")
529 BOOT_PRINTF("in DUMB *** \n")
508
530
509 while(1){
531 while(1){
510 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5,
532 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5,
@@ -525,9 +547,9 rtems_task dumb_task( rtems_task_argumen
525 //***********
547 //***********
526 // TC ACTIONS
548 // TC ACTIONS
527
549
528 int action_reset(ccsdsTelecommandPacket_t *TC)
550 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
529 {
551 {
530 send_tm_lfr_tc_exe_not_implemented( TC );
552 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
531 return LFR_DEFAULT;
553 return LFR_DEFAULT;
532 }
554 }
533
555
@@ -541,7 +563,7 int action_load_common_par(ccsdsTelecomm
541 return LFR_SUCCESSFUL;
563 return LFR_SUCCESSFUL;
542 }
564 }
543
565
544 int action_load_normal_par(ccsdsTelecommandPacket_t *TC)
566 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
545 {
567 {
546 int result;
568 int result;
547 unsigned int tmp;
569 unsigned int tmp;
@@ -549,7 +571,7 int action_load_normal_par(ccsdsTelecomm
549 result = LFR_SUCCESSFUL;
571 result = LFR_SUCCESSFUL;
550
572
551 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
573 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
552 send_tm_lfr_tc_exe_not_executable( TC );
574 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
553 result = LFR_DEFAULT;
575 result = LFR_DEFAULT;
554 }
576 }
555 else {
577 else {
@@ -586,7 +608,7 int action_load_normal_par(ccsdsTelecomm
586 return result;
608 return result;
587 }
609 }
588
610
589 int action_load_burst_par(ccsdsTelecommandPacket_t *TC)
611 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
590 {
612 {
591 int result;
613 int result;
592 unsigned char lfrMode;
614 unsigned char lfrMode;
@@ -595,7 +617,7 int action_load_burst_par(ccsdsTelecomma
595 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
617 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
596
618
597 if ( lfrMode == LFR_MODE_BURST ) {
619 if ( lfrMode == LFR_MODE_BURST ) {
598 send_tm_lfr_tc_exe_not_executable( TC );
620 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
599 result = LFR_DEFAULT;
621 result = LFR_DEFAULT;
600 }
622 }
601 else {
623 else {
@@ -608,7 +630,7 int action_load_burst_par(ccsdsTelecomma
608 return result;
630 return result;
609 }
631 }
610
632
611 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC)
633 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
612 {
634 {
613 int result;
635 int result;
614 unsigned char lfrMode;
636 unsigned char lfrMode;
@@ -617,7 +639,7 int action_load_sbm1_par(ccsdsTelecomman
617 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
639 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
618
640
619 if ( lfrMode == LFR_MODE_SBM1 ) {
641 if ( lfrMode == LFR_MODE_SBM1 ) {
620 send_tm_lfr_tc_exe_not_executable( TC );
642 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
621 result = LFR_DEFAULT;
643 result = LFR_DEFAULT;
622 }
644 }
623 else {
645 else {
@@ -630,7 +652,7 int action_load_sbm1_par(ccsdsTelecomman
630 return result;
652 return result;
631 }
653 }
632
654
633 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC)
655 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
634 {
656 {
635 int result;
657 int result;
636 unsigned char lfrMode;
658 unsigned char lfrMode;
@@ -639,7 +661,7 int action_load_sbm2_par(ccsdsTelecomman
639 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
661 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
640
662
641 if ( lfrMode == LFR_MODE_SBM2 ) {
663 if ( lfrMode == LFR_MODE_SBM2 ) {
642 send_tm_lfr_tc_exe_not_executable( TC );
664 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
643 result = LFR_DEFAULT;
665 result = LFR_DEFAULT;
644 }
666 }
645 else {
667 else {
@@ -671,7 +693,7 int action_dump_par(ccsdsTelecommandPack
671 return status;
693 return status;
672 }
694 }
673
695
674 int action_enter_mode(ccsdsTelecommandPacket_t *TC)
696 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
675 {
697 {
676 rtems_status_code status;
698 rtems_status_code status;
677 unsigned char requestedMode;
699 unsigned char requestedMode;
@@ -704,13 +726,13 int action_enter_mode(ccsdsTelecommandPa
704 else
726 else
705 {
727 {
706 PRINTF("ERR *** in action_enter *** transition rejected\n")
728 PRINTF("ERR *** in action_enter *** transition rejected\n")
707 send_tm_lfr_tc_exe_not_executable( TC );
729 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
708 }
730 }
709
731
710 return status;
732 return status;
711 }
733 }
712
734
713 int action_update_info(ccsdsTelecommandPacket_t *TC) {
735 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) {
714 unsigned int val;
736 unsigned int val;
715 int result;
737 int result;
716 unsigned char lfrMode;
738 unsigned char lfrMode;
@@ -719,7 +741,7 int action_update_info(ccsdsTelecommandP
719 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
741 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
720
742
721 if ( (lfrMode == LFR_MODE_STANDBY) ) {
743 if ( (lfrMode == LFR_MODE_STANDBY) ) {
722 send_tm_lfr_tc_exe_not_implemented( TC );
744 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
723 result = LFR_DEFAULT;
745 result = LFR_DEFAULT;
724 }
746 }
725 else {
747 else {
@@ -734,7 +756,7 int action_update_info(ccsdsTelecommandP
734 return result;
756 return result;
735 }
757 }
736
758
737 int action_enable_calibration(ccsdsTelecommandPacket_t *TC)
759 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
738 {
760 {
739 int result;
761 int result;
740 unsigned char lfrMode;
762 unsigned char lfrMode;
@@ -743,17 +765,17 int action_enable_calibration(ccsdsTelec
743 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
765 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
744
766
745 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
767 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
746 send_tm_lfr_tc_exe_not_executable( TC );
768 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
747 result = LFR_DEFAULT;
769 result = LFR_DEFAULT;
748 }
770 }
749 else {
771 else {
750 send_tm_lfr_tc_exe_not_implemented( TC );
772 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
751 result = LFR_DEFAULT;
773 result = LFR_DEFAULT;
752 }
774 }
753 return result;
775 return result;
754 }
776 }
755
777
756 int action_disable_calibration(ccsdsTelecommandPacket_t *TC)
778 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
757 {
779 {
758 int result;
780 int result;
759 unsigned char lfrMode;
781 unsigned char lfrMode;
@@ -762,11 +784,11 int action_disable_calibration(ccsdsTele
762 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
784 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
763
785
764 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
786 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
765 send_tm_lfr_tc_exe_not_executable( TC );
787 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
766 result = LFR_DEFAULT;
788 result = LFR_DEFAULT;
767 }
789 }
768 else {
790 else {
769 send_tm_lfr_tc_exe_not_implemented( TC );
791 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
770 result = LFR_DEFAULT;
792 result = LFR_DEFAULT;
771 }
793 }
772 return result;
794 return result;
@@ -851,14 +873,12 int transition_validation(unsigned char
851 int stop_current_mode()
873 int stop_current_mode()
852 {
874 {
853 rtems_status_code status;
875 rtems_status_code status;
854 unsigned char lfrMode;
855
876
856 status = RTEMS_SUCCESSFUL;
877 status = RTEMS_SUCCESSFUL;
857 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
858
878
859 // mask all IRQ lines related to signal processing
879 // mask all IRQ lines related to signal processing
860 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
880 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
861 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
881 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
862
882
863 #ifdef GSA
883 #ifdef GSA
864 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
884 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
@@ -866,14 +886,15 int stop_current_mode()
866 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
886 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
867 #else
887 #else
868 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
888 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
869 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
889 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
870 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
890 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
871 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
891 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
872 LEON_Mask_interrupt( IRQ_SM );
892 LEON_Mask_interrupt( IRQ_SM ); // for SM simulation
893 LEON_Clear_interrupt( IRQ_SM ); // for SM simulation
873 #endif
894 #endif
874 //**********************
895 //**********************
875 // suspend several tasks
896 // suspend several tasks
876 if (lfrMode != LFR_MODE_STANDBY) {
897 if (lfrCurrentMode != LFR_MODE_STANDBY) {
877 suspend_science_tasks();
898 suspend_science_tasks();
878 }
899 }
879
900
@@ -972,11 +993,11 int enter_normal_mode()
972 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
993 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
973 //****************
994 //****************
974 // spectral matrix
995 // spectral matrix
975 set_local_nb_interrupt_f0_MAX();
996 // set_local_nb_interrupt_f0_MAX();
976 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
997 // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
977 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
998 // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
978 spectral_matrix_regs->config = 0x01;
999 // spectral_matrix_regs->config = 0x01;
979 spectral_matrix_regs->status = 0x00;
1000 // spectral_matrix_regs->status = 0x00;
980 #endif
1001 #endif
981
1002
982 return status;
1003 return status;
@@ -985,9 +1006,6 int enter_normal_mode()
985 int enter_burst_mode()
1006 int enter_burst_mode()
986 {
1007 {
987 rtems_status_code status;
1008 rtems_status_code status;
988 unsigned char lfrMode;
989
990 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
991
1009
992 status = restart_science_tasks();
1010 status = restart_science_tasks();
993
1011
@@ -1021,9 +1039,9 int enter_sbm1_mode()
1021 reset_waveform_picker_regs();
1039 reset_waveform_picker_regs();
1022 set_wfp_burst_enable_register(LFR_MODE_SBM1);
1040 set_wfp_burst_enable_register(LFR_MODE_SBM1);
1023 // SM simulation
1041 // SM simulation
1024 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
1042 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
1025 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
1043 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
1026 LEON_Unmask_interrupt( IRQ_SM );
1044 // LEON_Unmask_interrupt( IRQ_SM );
1027 #endif
1045 #endif
1028
1046
1029 return status;
1047 return status;
@@ -1059,17 +1077,45 int restart_science_tasks()
1059 ret = RTEMS_SUCCESSFUL;
1077 ret = RTEMS_SUCCESSFUL;
1060
1078
1061 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
1079 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
1080 if (status[0] != RTEMS_SUCCESSFUL)
1081 {
1082 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
1083 }
1084
1062 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
1085 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
1086 if (status[1] != RTEMS_SUCCESSFUL)
1087 {
1088 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
1089 }
1090
1063 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
1091 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
1092 if (status[2] != RTEMS_SUCCESSFUL)
1093 {
1094 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
1095 }
1096
1064 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
1097 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
1098 if (status[3] != RTEMS_SUCCESSFUL)
1099 {
1100 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
1101 }
1102
1065 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
1103 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
1104 if (status[4] != RTEMS_SUCCESSFUL)
1105 {
1106 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
1107 }
1108
1066 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
1109 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
1110 if (status[5] != RTEMS_SUCCESSFUL)
1111 {
1112 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
1113 }
1067
1114
1068 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1115 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1069 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1116 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1070 {
1117 {
1071 ret = RTEMS_UNSATISFIED;
1118 ret = RTEMS_UNSATISFIED;
1072 PRINTF("in restart_science_tasks *** ERR\n")
1073 }
1119 }
1074
1120
1075 return ret;
1121 return ret;
@@ -1083,17 +1129,45 int suspend_science_tasks()
1083 ret = RTEMS_SUCCESSFUL;
1129 ret = RTEMS_SUCCESSFUL;
1084
1130
1085 status[0] = rtems_task_suspend( Task_id[TASKID_AVF0] );
1131 status[0] = rtems_task_suspend( Task_id[TASKID_AVF0] );
1132 if (status[0] != RTEMS_SUCCESSFUL)
1133 {
1134 PRINTF1("in suspend_science_task *** 0 ERR %d\n", status[0])
1135 }
1136
1086 status[1] = rtems_task_suspend( Task_id[TASKID_BPF0] );
1137 status[1] = rtems_task_suspend( Task_id[TASKID_BPF0] );
1138 if (status[1] != RTEMS_SUCCESSFUL)
1139 {
1140 PRINTF1("in suspend_science_task *** 1 ERR %d\n", status[1])
1141 }
1142
1087 status[2] = rtems_task_suspend( Task_id[TASKID_WFRM] );
1143 status[2] = rtems_task_suspend( Task_id[TASKID_WFRM] );
1144 if (status[2] != RTEMS_SUCCESSFUL)
1145 {
1146 PRINTF1("in suspend_science_task *** 2 ERR %d\n", status[2])
1147 }
1148
1088 status[3] = rtems_task_suspend( Task_id[TASKID_CWF3] );
1149 status[3] = rtems_task_suspend( Task_id[TASKID_CWF3] );
1150 if (status[3] != RTEMS_SUCCESSFUL)
1151 {
1152 PRINTF1("in suspend_science_task *** 3 ERR %d\n", status[3])
1153 }
1154
1089 status[4] = rtems_task_suspend( Task_id[TASKID_CWF2] );
1155 status[4] = rtems_task_suspend( Task_id[TASKID_CWF2] );
1156 if (status[4] != RTEMS_SUCCESSFUL)
1157 {
1158 PRINTF1("in suspend_science_task *** 4 ERR %d\n", status[4])
1159 }
1160
1090 status[5] = rtems_task_suspend( Task_id[TASKID_CWF1] );
1161 status[5] = rtems_task_suspend( Task_id[TASKID_CWF1] );
1162 if (status[5] != RTEMS_SUCCESSFUL)
1163 {
1164 PRINTF1("in suspend_science_task *** 5 ERR %d\n", status[5])
1165 }
1091
1166
1092 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1167 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1093 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1168 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1094 {
1169 {
1095 ret = RTEMS_UNSATISFIED;
1170 ret = RTEMS_UNSATISFIED;
1096 PRINTF("in suspend_science_tasks *** ERR\n")
1097 }
1171 }
1098
1172
1099 return ret;
1173 return ret;
@@ -1102,7 +1176,7 int suspend_science_tasks()
1102 //****************
1176 //****************
1103 // CLOSING ACTIONS
1177 // CLOSING ACTIONS
1104
1178
1105 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
1179 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1106 {
1180 {
1107 int ret;
1181 int ret;
1108 rtems_status_code status;
1182 rtems_status_code status;
@@ -1130,7 +1204,7 int send_tm_lfr_tc_exe_success(ccsdsTele
1130
1204
1131 // SEND DATA
1205 // SEND DATA
1132 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1206 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1133 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1207 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1134 if (status != RTEMS_SUCCESSFUL) {
1208 if (status != RTEMS_SUCCESSFUL) {
1135 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1209 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1136 ret = LFR_DEFAULT;
1210 ret = LFR_DEFAULT;
@@ -1139,7 +1213,7 int send_tm_lfr_tc_exe_success(ccsdsTele
1139 return ret;
1213 return ret;
1140 }
1214 }
1141
1215
1142 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC)
1216 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1143 {
1217 {
1144 int ret;
1218 int ret;
1145 rtems_status_code status;
1219 rtems_status_code status;
@@ -1173,7 +1247,7 int send_tm_lfr_tc_exe_not_executable(cc
1173
1247
1174 // SEND DATA
1248 // SEND DATA
1175 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1249 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1176 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1250 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1177 if (status != RTEMS_SUCCESSFUL) {
1251 if (status != RTEMS_SUCCESSFUL) {
1178 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1252 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1179 ret = LFR_DEFAULT;
1253 ret = LFR_DEFAULT;
@@ -1182,7 +1256,7 int send_tm_lfr_tc_exe_not_executable(cc
1182 return LFR_SUCCESSFUL;
1256 return LFR_SUCCESSFUL;
1183 }
1257 }
1184
1258
1185 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC)
1259 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1186 {
1260 {
1187 int ret;
1261 int ret;
1188 rtems_status_code status;
1262 rtems_status_code status;
@@ -1214,7 +1288,7 int send_tm_lfr_tc_exe_not_implemented(c
1214
1288
1215 // SEND DATA
1289 // SEND DATA
1216 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1290 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1217 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1291 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1218 if (status != RTEMS_SUCCESSFUL) {
1292 if (status != RTEMS_SUCCESSFUL) {
1219 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1293 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1220 ret = LFR_DEFAULT;
1294 ret = LFR_DEFAULT;
@@ -1223,7 +1297,7 int send_tm_lfr_tc_exe_not_implemented(c
1223 return LFR_SUCCESSFUL;
1297 return LFR_SUCCESSFUL;
1224 }
1298 }
1225
1299
1226 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC)
1300 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1227 {
1301 {
1228 int ret;
1302 int ret;
1229 rtems_status_code status;
1303 rtems_status_code status;
@@ -1253,7 +1327,7 int send_tm_lfr_tc_exe_error(ccsdsTeleco
1253
1327
1254 // SEND DATA
1328 // SEND DATA
1255 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1329 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1256 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1330 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1257 if (status != RTEMS_SUCCESSFUL) {
1331 if (status != RTEMS_SUCCESSFUL) {
1258 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1332 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1259 ret = LFR_DEFAULT;
1333 ret = LFR_DEFAULT;
@@ -1294,14 +1368,14 void update_last_TC_rej(ccsdsTelecommand
1294 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1368 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1295 }
1369 }
1296
1370
1297 void close_action(ccsdsTelecommandPacket_t *TC, int result)
1371 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
1298 {
1372 {
1299 unsigned int val = 0;
1373 unsigned int val = 0;
1300 if (result == LFR_SUCCESSFUL)
1374 if (result == LFR_SUCCESSFUL)
1301 {
1375 {
1302 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) )
1376 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) )
1303 {
1377 {
1304 send_tm_lfr_tc_exe_success( TC );
1378 send_tm_lfr_tc_exe_success( TC, queue_id );
1305 }
1379 }
1306 update_last_TC_exe( TC );
1380 update_last_TC_exe( TC );
1307 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
1381 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
@@ -51,12 +51,19 rtems_isr waveforms_isr( rtems_vector_nu
51 #ifdef GSA
51 #ifdef GSA
52 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
52 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
53 #else
53 #else
54 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // [0111] f2 f1 and f0 are full
54 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
55 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
55 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
56 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
56 }
57 else {
58 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
59 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
60 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
61 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
62 }
63 waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
64 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
57 }
65 }
58 }
66 }
59 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
60 #endif
67 #endif
61 break;
68 break;
62
69
@@ -196,6 +203,8 rtems_isr waveforms_simulator_isr( rtems
196 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
203 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
197 {
204 {
198 rtems_event_set event_out;
205 rtems_event_set event_out;
206 rtems_id queue_id;
207 rtems_status_code status;
199
208
200 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
209 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
201 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
210 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
@@ -203,7 +212,13 rtems_task wfrm_task(rtems_task_argument
203
212
204 init_waveforms();
213 init_waveforms();
205
214
206 PRINTF("in WFRM ***\n")
215 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
216 if (status != RTEMS_SUCCESSFUL)
217 {
218 PRINTF1("in WFRM *** ERR getting queue id, %d\n", status)
219 }
220
221 BOOT_PRINTF("in WFRM ***\n")
207
222
208 while(1){
223 while(1){
209 // wait for an RTEMS_EVENT
224 // wait for an RTEMS_EVENT
@@ -211,41 +226,41 rtems_task wfrm_task(rtems_task_argument
211 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
226 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
212 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
227 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
213
228
214 switch( event_out) {
229 if (event_out == RTEMS_EVENT_MODE_NORMAL)
215
230 {
216 case RTEMS_EVENT_MODE_NORMAL:
231 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
217 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
232 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
218 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1);
233 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
219 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2);
220 #ifdef GSA
234 #ifdef GSA
221 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
235 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
222 #endif
236 #endif
223 break;
237 }
224
238 else if (event_out == RTEMS_EVENT_MODE_SBM1)
225 case RTEMS_EVENT_MODE_SBM1:
239 {
226 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
240 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
227 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1);
241 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
228 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2);
242 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
229 #ifdef GSA
243 #ifdef GSA
230 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
244 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
231 #endif
245 #endif
232 break;
246 }
233
247 else if (event_out == RTEMS_EVENT_MODE_SBM2)
234 case RTEMS_EVENT_MODE_SBM2:
248 {
235 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
249 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
236 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1);
250 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
237 #ifdef GSA
251 #ifdef GSA
238 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
252 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
239 #endif
253 #endif
240 break;
254 }
255 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
256 {
257 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
258 }
259 else
260 {
261 PRINTF("in WFRM *** unexpected event")
262 }
241
263
242 case RTEMS_EVENT_MODE_SBM2_WFRM:
243 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2);
244 break;
245
246 default:
247 break;
248 }
249
264
250 #ifdef GSA
265 #ifdef GSA
251 // irq processed, reset the related register of the timer unit
266 // irq processed, reset the related register of the timer unit
@@ -259,10 +274,13 rtems_task wfrm_task(rtems_task_argument
259 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
274 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
260 {
275 {
261 rtems_event_set event_out;
276 rtems_event_set event_out;
277 rtems_id queue_id;
262
278
263 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
279 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
264
280
265 PRINTF("in CWF3 ***\n")
281 queue_id = get_pkts_queue_id();
282
283 BOOT_PRINTF("in CWF3 ***\n")
266
284
267 while(1){
285 while(1){
268 // wait for an RTEMS_EVENT
286 // wait for an RTEMS_EVENT
@@ -272,10 +290,10 rtems_task cwf3_task(rtems_task_argument
272 #ifdef GSA
290 #ifdef GSA
273 #else
291 #else
274 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
292 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
275 send_waveform_CWF( wf_cont_f3_bis, SID_NORM_CWF_F3, headerCWF_F3 );
293 send_waveform_CWF( wf_cont_f3_bis, SID_NORM_CWF_F3, headerCWF_F3, queue_id );
276 }
294 }
277 else {
295 else {
278 send_waveform_CWF( wf_cont_f3, SID_NORM_CWF_F3, headerCWF_F3 );
296 send_waveform_CWF( wf_cont_f3, SID_NORM_CWF_F3, headerCWF_F3, queue_id );
279 }
297 }
280 #endif
298 #endif
281 }
299 }
@@ -284,11 +302,14 rtems_task cwf3_task(rtems_task_argument
284 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
302 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
285 {
303 {
286 rtems_event_set event_out;
304 rtems_event_set event_out;
305 rtems_id queue_id;
287
306
288 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
307 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
289 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
308 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
290
309
291 PRINTF("in CWF2 ***\n")
310 queue_id = get_pkts_queue_id();
311
312 BOOT_PRINTF("in CWF2 ***\n")
292
313
293 while(1){
314 while(1){
294 // wait for an RTEMS_EVENT
315 // wait for an RTEMS_EVENT
@@ -300,10 +321,10 rtems_task cwf2_task(rtems_task_argument
300 #ifdef GSA
321 #ifdef GSA
301 #else
322 #else
302 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
323 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
303 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST );
324 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
304 }
325 }
305 else {
326 else {
306 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST );
327 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
307 }
328 }
308 #endif
329 #endif
309 }
330 }
@@ -314,13 +335,13 rtems_task cwf2_task(rtems_task_argument
314 if (doubleSendCWF2 == 1)
335 if (doubleSendCWF2 == 1)
315 {
336 {
316 doubleSendCWF2 = 0;
337 doubleSendCWF2 = 0;
317 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
338 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
318 }
339 }
319 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
340 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
320 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
341 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
321 }
342 }
322 else {
343 else {
323 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
344 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
324 }
345 }
325 param_local.local_sbm2_nb_cwf_sent ++;
346 param_local.local_sbm2_nb_cwf_sent ++;
326 #endif
347 #endif
@@ -335,10 +356,13 rtems_task cwf2_task(rtems_task_argument
335 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
356 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
336 {
357 {
337 rtems_event_set event_out;
358 rtems_event_set event_out;
359 rtems_id queue_id;
338
360
339 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
361 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
340
362
341 PRINTF("in CWF1 ***\n")
363 queue_id = get_pkts_queue_id();
364
365 BOOT_PRINTF("in CWF1 ***\n")
342
366
343 while(1){
367 while(1){
344 // wait for an RTEMS_EVENT
368 // wait for an RTEMS_EVENT
@@ -351,13 +375,13 rtems_task cwf1_task(rtems_task_argument
351 if (doubleSendCWF1 == 1)
375 if (doubleSendCWF1 == 1)
352 {
376 {
353 doubleSendCWF1 = 0;
377 doubleSendCWF1 = 0;
354 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1 );
378 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
355 }
379 }
356 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
380 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
357 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1 );
381 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
358 }
382 }
359 else {
383 else {
360 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1);
384 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
361 }
385 }
362 param_local.local_sbm1_nb_cwf_sent ++;
386 param_local.local_sbm1_nb_cwf_sent ++;
363 #endif
387 #endif
@@ -555,7 +579,8 void reset_waveforms( void )
555 }
579 }
556 }
580 }
557
581
558 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF )
582 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
583 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
559 {
584 {
560 unsigned int i;
585 unsigned int i;
561 int ret;
586 int ret;
@@ -592,7 +617,7 int send_waveform_SWF( volatile int *wav
592 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
617 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
593 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
618 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
594 // SEND PACKET
619 // SEND PACKET
595 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send_SWF, ACTION_MSG_PKTS_SIZE);
620 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_PKTS_SIZE);
596 if (status != RTEMS_SUCCESSFUL) {
621 if (status != RTEMS_SUCCESSFUL) {
597 printf("%d-%d, ERR %d\n", sid, i, (int) status);
622 printf("%d-%d, ERR %d\n", sid, i, (int) status);
598 ret = LFR_DEFAULT;
623 ret = LFR_DEFAULT;
@@ -603,7 +628,8 int send_waveform_SWF( volatile int *wav
603 return ret;
628 return ret;
604 }
629 }
605
630
606 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF)
631 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
632 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
607 {
633 {
608 unsigned int i;
634 unsigned int i;
609 int ret;
635 int ret;
@@ -646,7 +672,7 int send_waveform_CWF( volatile int *wav
646 // SEND PACKET
672 // SEND PACKET
647 if (sid == SID_NORM_CWF_F3)
673 if (sid == SID_NORM_CWF_F3)
648 {
674 {
649 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
675 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
650 if (status != RTEMS_SUCCESSFUL) {
676 if (status != RTEMS_SUCCESSFUL) {
651 printf("%d-%d, ERR %d\n", sid, i, (int) status);
677 printf("%d-%d, ERR %d\n", sid, i, (int) status);
652 ret = LFR_DEFAULT;
678 ret = LFR_DEFAULT;
@@ -655,7 +681,7 int send_waveform_CWF( volatile int *wav
655 }
681 }
656 else
682 else
657 {
683 {
658 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
684 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
659 if (status != RTEMS_SUCCESSFUL) {
685 if (status != RTEMS_SUCCESSFUL) {
660 printf("%d-%d, ERR %d\n", sid, i, (int) status);
686 printf("%d-%d, ERR %d\n", sid, i, (int) status);
661 ret = LFR_DEFAULT;
687 ret = LFR_DEFAULT;
@@ -724,6 +750,7 void set_wfp_burst_enable_register( unsi
724 // the burst bits shall be set first, before the enable bits
750 // the burst bits shall be set first, before the enable bits
725 switch(mode) {
751 switch(mode) {
726 case(LFR_MODE_NORMAL):
752 case(LFR_MODE_NORMAL):
753 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
727 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
754 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
728 break;
755 break;
729 case(LFR_MODE_BURST):
756 case(LFR_MODE_BURST):
General Comments 0
You need to be logged in to leave comments. Login now