@@ -1,1289 +1,1306 | |||||
1 | /** Functions related to the SpaceWire interface. |
|
1 | /** Functions related to the SpaceWire interface. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle SpaceWire transmissions: |
|
6 | * A group of functions to handle SpaceWire transmissions: | |
7 | * - configuration of the SpaceWire link |
|
7 | * - configuration of the SpaceWire link | |
8 | * - SpaceWire related interruption requests processing |
|
8 | * - SpaceWire related interruption requests processing | |
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task | |
10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
10 | * - reception of TeleCommands by a dedicated RTEMS task | |
11 | * |
|
11 | * | |
12 | */ |
|
12 | */ | |
13 |
|
13 | |||
14 | #include "fsw_spacewire.h" |
|
14 | #include "fsw_spacewire.h" | |
15 |
|
15 | |||
16 | rtems_name semq_name; |
|
16 | rtems_name semq_name; | |
17 | rtems_id semq_id; |
|
17 | rtems_id semq_id; | |
18 |
|
18 | |||
19 | //***************** |
|
19 | //***************** | |
20 | // waveform headers |
|
20 | // waveform headers | |
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; | |
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; |
|
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; | |
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
24 |
|
24 | |||
25 | //*********** |
|
25 | //*********** | |
26 | // RTEMS TASK |
|
26 | // RTEMS TASK | |
27 | rtems_task spiq_task(rtems_task_argument unused) |
|
27 | rtems_task spiq_task(rtems_task_argument unused) | |
28 | { |
|
28 | { | |
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. | |
30 | * |
|
30 | * | |
31 | * @param unused is the starting argument of the RTEMS task |
|
31 | * @param unused is the starting argument of the RTEMS task | |
32 | * |
|
32 | * | |
33 | */ |
|
33 | */ | |
34 |
|
34 | |||
35 | rtems_event_set event_out; |
|
35 | rtems_event_set event_out; | |
36 | rtems_status_code status; |
|
36 | rtems_status_code status; | |
37 | int linkStatus; |
|
37 | int linkStatus; | |
38 |
|
38 | |||
39 | BOOT_PRINTF("in SPIQ *** \n") |
|
39 | BOOT_PRINTF("in SPIQ *** \n") | |
40 |
|
40 | |||
41 | while(true){ |
|
41 | while(true){ | |
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") | |
44 |
|
44 | |||
45 | // [0] SUSPEND RECV AND SEND TASKS |
|
45 | // [0] SUSPEND RECV AND SEND TASKS | |
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); | |
47 | if ( status != RTEMS_SUCCESSFUL ) { |
|
47 | if ( status != RTEMS_SUCCESSFUL ) { | |
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") | |
49 | } |
|
49 | } | |
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); | |
51 | if ( status != RTEMS_SUCCESSFUL ) { |
|
51 | if ( status != RTEMS_SUCCESSFUL ) { | |
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | // [1] CHECK THE LINK |
|
55 | // [1] CHECK THE LINK | |
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) | |
57 | if ( linkStatus != 5) { |
|
57 | if ( linkStatus != 5) { | |
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) | |
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT | |
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) | |
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link | |
65 | { |
|
65 | { | |
66 | spacewire_compute_stats_offsets(); |
|
66 | spacewire_compute_stats_offsets(); | |
67 | status = spacewire_reset_link( ); |
|
67 | status = spacewire_reset_link( ); | |
68 | } |
|
68 | } | |
69 | else // [2.b] in run state, start the link |
|
69 | else // [2.b] in run state, start the link | |
70 | { |
|
70 | { | |
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link | |
72 | if ( status != RTEMS_SUCCESSFUL) |
|
72 | if ( status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) |
|
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS | |
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully | |
80 | { |
|
80 | { | |
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
82 | if ( status != RTEMS_SUCCESSFUL ) { |
|
82 | if ( status != RTEMS_SUCCESSFUL ) { | |
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") | |
84 | } |
|
84 | } | |
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
86 | if ( status != RTEMS_SUCCESSFUL ) { |
|
86 | if ( status != RTEMS_SUCCESSFUL ) { | |
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
90 | else // [3.b] the link is not in run state, go in STANDBY mode | |
91 | { |
|
91 | { | |
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); | |
93 | if ( status != RTEMS_SUCCESSFUL ) { |
|
93 | if ( status != RTEMS_SUCCESSFUL ) { | |
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
95 | } |
|
95 | } | |
96 | // wake the WTDG task up to wait for the link recovery |
|
96 | // wake the WTDG task up to wait for the link recovery | |
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); | |
98 | status = rtems_task_suspend( RTEMS_SELF ); |
|
98 | status = rtems_task_suspend( RTEMS_SELF ); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | rtems_task recv_task( rtems_task_argument unused ) |
|
103 | rtems_task recv_task( rtems_task_argument unused ) | |
104 | { |
|
104 | { | |
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
106 | * |
|
106 | * | |
107 | * @param unused is the starting argument of the RTEMS task |
|
107 | * @param unused is the starting argument of the RTEMS task | |
108 | * |
|
108 | * | |
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
110 | * 1. It reads the incoming data. |
|
110 | * 1. It reads the incoming data. | |
111 | * 2. Launches the acceptance procedure. |
|
111 | * 2. Launches the acceptance procedure. | |
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
113 | * |
|
113 | * | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | int len; |
|
116 | int len; | |
117 | ccsdsTelecommandPacket_t currentTC; |
|
117 | ccsdsTelecommandPacket_t currentTC; | |
118 | unsigned char computed_CRC[ 2 ]; |
|
118 | unsigned char computed_CRC[ 2 ]; | |
119 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
119 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
120 | unsigned char destinationID; |
|
120 | unsigned char destinationID; | |
121 | unsigned int estimatedPacketLength; |
|
121 | unsigned int estimatedPacketLength; | |
122 | unsigned int parserCode; |
|
122 | unsigned int parserCode; | |
123 | rtems_status_code status; |
|
123 | rtems_status_code status; | |
124 | rtems_id queue_recv_id; |
|
124 | rtems_id queue_recv_id; | |
125 | rtems_id queue_send_id; |
|
125 | rtems_id queue_send_id; | |
126 |
|
126 | |||
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
128 |
|
128 | |||
129 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
129 | status = get_message_queue_id_recv( &queue_recv_id ); | |
130 | if (status != RTEMS_SUCCESSFUL) |
|
130 | if (status != RTEMS_SUCCESSFUL) | |
131 | { |
|
131 | { | |
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | status = get_message_queue_id_send( &queue_send_id ); |
|
135 | status = get_message_queue_id_send( &queue_send_id ); | |
136 | if (status != RTEMS_SUCCESSFUL) |
|
136 | if (status != RTEMS_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | BOOT_PRINTF("in RECV *** \n") |
|
141 | BOOT_PRINTF("in RECV *** \n") | |
142 |
|
142 | |||
143 | while(1) |
|
143 | while(1) | |
144 | { |
|
144 | { | |
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
146 | if (len == -1){ // error during the read call |
|
146 | if (len == -1){ // error during the read call | |
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
148 | } |
|
148 | } | |
149 | else { |
|
149 | else { | |
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
151 | PRINTF("in RECV *** packet lenght too short\n") |
|
151 | PRINTF("in RECV *** packet lenght too short\n") | |
152 | } |
|
152 | } | |
153 | else { |
|
153 | else { | |
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); | |
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); | |
157 | // CHECK THE TC |
|
157 | // CHECK THE TC | |
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; | |
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
162 | || (parserCode == WRONG_SRC_ID) ) |
|
162 | || (parserCode == WRONG_SRC_ID) ) | |
163 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
163 | { // send TM_LFR_TC_EXE_CORRUPTED | |
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) | |
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
166 | && |
|
166 | && | |
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
168 | ) |
|
168 | ) | |
169 | { |
|
169 | { | |
170 | if ( parserCode == WRONG_SRC_ID ) |
|
170 | if ( parserCode == WRONG_SRC_ID ) | |
171 | { |
|
171 | { | |
172 | destinationID = SID_TC_GROUND; |
|
172 | destinationID = SID_TC_GROUND; | |
173 | } |
|
173 | } | |
174 | else |
|
174 | else | |
175 | { |
|
175 | { | |
176 | destinationID = currentTC.sourceID; |
|
176 | destinationID = currentTC.sourceID; | |
177 | } |
|
177 | } | |
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
179 | computed_CRC, currentTC_LEN_RCV, |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
180 | destinationID ); |
|
180 | destinationID ); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { // send valid TC to the action launcher |
|
184 | { // send valid TC to the action launcher | |
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); |
|
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); | |
192 |
|
192 | |||
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | rtems_task send_task( rtems_task_argument argument) |
|
196 | rtems_task send_task( rtems_task_argument argument) | |
197 | { |
|
197 | { | |
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
199 | * |
|
199 | * | |
200 | * @param unused is the starting argument of the RTEMS task |
|
200 | * @param unused is the starting argument of the RTEMS task | |
201 | * |
|
201 | * | |
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
206 | * data it contains. |
|
206 | * data it contains. | |
207 | * |
|
207 | * | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | rtems_status_code status; // RTEMS status code |
|
210 | rtems_status_code status; // RTEMS status code | |
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
212 | ring_node *incomingRingNodePtr; |
|
212 | ring_node *incomingRingNodePtr; | |
213 | int ring_node_address; |
|
213 | int ring_node_address; | |
214 | char *charPtr; |
|
214 | char *charPtr; | |
215 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
215 | spw_ioctl_pkt_send *spw_ioctl_send; | |
216 | size_t size; // size of the incoming TC packet |
|
216 | size_t size; // size of the incoming TC packet | |
217 | rtems_id queue_send_id; |
|
217 | rtems_id queue_send_id; | |
218 | unsigned int sid; |
|
218 | unsigned int sid; | |
219 |
|
219 | |||
220 | incomingRingNodePtr = NULL; |
|
220 | incomingRingNodePtr = NULL; | |
221 | ring_node_address = 0; |
|
221 | ring_node_address = 0; | |
222 | charPtr = (char *) &ring_node_address; |
|
222 | charPtr = (char *) &ring_node_address; | |
223 | sid = 0; |
|
223 | sid = 0; | |
224 |
|
224 | |||
225 | init_header_cwf( &headerCWF ); |
|
225 | init_header_cwf( &headerCWF ); | |
226 | init_header_swf( &headerSWF ); |
|
226 | init_header_swf( &headerSWF ); | |
227 | init_header_asm( &headerASM ); |
|
227 | init_header_asm( &headerASM ); | |
228 |
|
228 | |||
229 | status = get_message_queue_id_send( &queue_send_id ); |
|
229 | status = get_message_queue_id_send( &queue_send_id ); | |
230 | if (status != RTEMS_SUCCESSFUL) |
|
230 | if (status != RTEMS_SUCCESSFUL) | |
231 | { |
|
231 | { | |
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | BOOT_PRINTF("in SEND *** \n") |
|
235 | BOOT_PRINTF("in SEND *** \n") | |
236 |
|
236 | |||
237 | while(1) |
|
237 | while(1) | |
238 | { |
|
238 | { | |
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, |
|
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, | |
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
241 |
|
241 | |||
242 | if (status!=RTEMS_SUCCESSFUL) |
|
242 | if (status!=RTEMS_SUCCESSFUL) | |
243 | { |
|
243 | { | |
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
245 | } |
|
245 | } | |
246 | else |
|
246 | else | |
247 | { |
|
247 | { | |
248 | if ( size == sizeof(ring_node*) ) |
|
248 | if ( size == sizeof(ring_node*) ) | |
249 | { |
|
249 | { | |
250 | charPtr[0] = incomingData[0]; |
|
250 | charPtr[0] = incomingData[0]; | |
251 | charPtr[1] = incomingData[1]; |
|
251 | charPtr[1] = incomingData[1]; | |
252 | charPtr[2] = incomingData[2]; |
|
252 | charPtr[2] = incomingData[2]; | |
253 | charPtr[3] = incomingData[3]; |
|
253 | charPtr[3] = incomingData[3]; | |
254 | incomingRingNodePtr = (ring_node*) ring_node_address; |
|
254 | incomingRingNodePtr = (ring_node*) ring_node_address; | |
255 | sid = incomingRingNodePtr->sid; |
|
255 | sid = incomingRingNodePtr->sid; | |
256 | if ( (sid==SID_NORM_CWF_LONG_F3) |
|
256 | if ( (sid==SID_NORM_CWF_LONG_F3) | |
257 | || (sid==SID_BURST_CWF_F2 ) |
|
257 | || (sid==SID_BURST_CWF_F2 ) | |
258 | || (sid==SID_SBM1_CWF_F1 ) |
|
258 | || (sid==SID_SBM1_CWF_F1 ) | |
259 | || (sid==SID_SBM2_CWF_F2 )) |
|
259 | || (sid==SID_SBM2_CWF_F2 )) | |
260 | { |
|
260 | { | |
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); |
|
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); | |
262 | } |
|
262 | } | |
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) |
|
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) | |
264 | { |
|
264 | { | |
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); |
|
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); | |
266 | } |
|
266 | } | |
267 | else if ( (sid==SID_NORM_CWF_F3) ) |
|
267 | else if ( (sid==SID_NORM_CWF_F3) ) | |
268 | { |
|
268 | { | |
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); |
|
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); | |
270 | } |
|
270 | } | |
271 | else if (sid==SID_NORM_ASM_F0) |
|
271 | else if (sid==SID_NORM_ASM_F0) | |
272 | { |
|
272 | { | |
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); |
|
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); | |
274 | } |
|
274 | } | |
275 | else if (sid==SID_NORM_ASM_F1) |
|
275 | else if (sid==SID_NORM_ASM_F1) | |
276 | { |
|
276 | { | |
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); |
|
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); | |
278 | } |
|
278 | } | |
279 | else if (sid==SID_NORM_ASM_F2) |
|
279 | else if (sid==SID_NORM_ASM_F2) | |
280 | { |
|
280 | { | |
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); |
|
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); | |
282 | } |
|
282 | } | |
283 | else if ( sid==TM_CODE_K_DUMP ) |
|
283 | else if ( sid==TM_CODE_K_DUMP ) | |
284 | { |
|
284 | { | |
285 | spw_send_k_dump( incomingRingNodePtr ); |
|
285 | spw_send_k_dump( incomingRingNodePtr ); | |
286 | } |
|
286 | } | |
287 | else |
|
287 | else | |
288 | { |
|
288 | { | |
289 | printf("unexpected sid = %d\n", sid); |
|
289 | printf("unexpected sid = %d\n", sid); | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet |
|
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet | |
293 | { |
|
293 | { | |
294 | status = write( fdSPW, incomingData, size ); |
|
294 | status = write( fdSPW, incomingData, size ); | |
295 | if (status == -1){ |
|
295 | if (status == -1){ | |
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
297 | } |
|
297 | } | |
298 | } |
|
298 | } | |
299 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
299 | else // the incoming message is a spw_ioctl_pkt_send structure | |
300 | { |
|
300 | { | |
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
303 | if (status == -1){ |
|
303 | if (status == -1){ | |
304 | printf("size = %d, %x, %x, %x, %x, %x\n", |
|
304 | printf("size = %d, %x, %x, %x, %x, %x\n", | |
305 | size, |
|
305 | size, | |
306 | incomingData[0], |
|
306 | incomingData[0], | |
307 | incomingData[1], |
|
307 | incomingData[1], | |
308 | incomingData[2], |
|
308 | incomingData[2], | |
309 | incomingData[3], |
|
309 | incomingData[3], | |
310 | incomingData[4]); |
|
310 | incomingData[4]); | |
311 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
311 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
312 | } |
|
312 | } | |
313 | } |
|
313 | } | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); |
|
316 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); | |
317 |
|
317 | |||
318 | } |
|
318 | } | |
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
321 | rtems_task wtdg_task( rtems_task_argument argument ) | |
322 | { |
|
322 | { | |
323 | rtems_event_set event_out; |
|
323 | rtems_event_set event_out; | |
324 | rtems_status_code status; |
|
324 | rtems_status_code status; | |
325 | int linkStatus; |
|
325 | int linkStatus; | |
326 |
|
326 | |||
327 | BOOT_PRINTF("in WTDG ***\n") |
|
327 | BOOT_PRINTF("in WTDG ***\n") | |
328 |
|
328 | |||
329 | while(1) |
|
329 | while(1) | |
330 | { |
|
330 | { | |
331 | // wait for an RTEMS_EVENT |
|
331 | // wait for an RTEMS_EVENT | |
332 | rtems_event_receive( RTEMS_EVENT_0, |
|
332 | rtems_event_receive( RTEMS_EVENT_0, | |
333 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
333 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
334 | PRINTF("in WTDG *** wait for the link\n") |
|
334 | PRINTF("in WTDG *** wait for the link\n") | |
335 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
335 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
336 | while( linkStatus != 5) // wait for the link |
|
336 | while( linkStatus != 5) // wait for the link | |
337 | { |
|
337 | { | |
338 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms |
|
338 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms | |
339 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
339 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | status = spacewire_stop_and_start_link( fdSPW ); |
|
342 | status = spacewire_stop_and_start_link( fdSPW ); | |
343 |
|
343 | |||
344 | if (status != RTEMS_SUCCESSFUL) |
|
344 | if (status != RTEMS_SUCCESSFUL) | |
345 | { |
|
345 | { | |
346 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
346 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
347 | } |
|
347 | } | |
348 | else |
|
348 | else | |
349 | { |
|
349 | { | |
350 | PRINTF("in WTDG *** OK link started\n") |
|
350 | PRINTF("in WTDG *** OK link started\n") | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | // restart the SPIQ task |
|
353 | // restart the SPIQ task | |
354 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
354 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
355 | if ( status != RTEMS_SUCCESSFUL ) { |
|
355 | if ( status != RTEMS_SUCCESSFUL ) { | |
356 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
356 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | // restart RECV and SEND |
|
359 | // restart RECV and SEND | |
360 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
360 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
361 | if ( status != RTEMS_SUCCESSFUL ) { |
|
361 | if ( status != RTEMS_SUCCESSFUL ) { | |
362 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
362 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
363 | } |
|
363 | } | |
364 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
364 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
365 | if ( status != RTEMS_SUCCESSFUL ) { |
|
365 | if ( status != RTEMS_SUCCESSFUL ) { | |
366 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
366 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | //**************** |
|
371 | //**************** | |
372 | // OTHER FUNCTIONS |
|
372 | // OTHER FUNCTIONS | |
373 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
373 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] | |
374 | { |
|
374 | { | |
375 | /** This function opens the SpaceWire link. |
|
375 | /** This function opens the SpaceWire link. | |
376 | * |
|
376 | * | |
377 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
377 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
378 | * |
|
378 | * | |
379 | */ |
|
379 | */ | |
380 | rtems_status_code status; |
|
380 | rtems_status_code status; | |
381 |
|
381 | |||
382 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
382 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
383 | if ( fdSPW < 0 ) { |
|
383 | if ( fdSPW < 0 ) { | |
384 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
384 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
385 | } |
|
385 | } | |
386 | else |
|
386 | else | |
387 | { |
|
387 | { | |
388 | status = RTEMS_SUCCESSFUL; |
|
388 | status = RTEMS_SUCCESSFUL; | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | return status; |
|
391 | return status; | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | int spacewire_start_link( int fd ) |
|
394 | int spacewire_start_link( int fd ) | |
395 | { |
|
395 | { | |
396 | rtems_status_code status; |
|
396 | rtems_status_code status; | |
397 |
|
397 | |||
398 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
398 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
399 | // -1 default hardcoded driver timeout |
|
399 | // -1 default hardcoded driver timeout | |
400 |
|
400 | |||
401 | return status; |
|
401 | return status; | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | int spacewire_stop_and_start_link( int fd ) |
|
404 | int spacewire_stop_and_start_link( int fd ) | |
405 | { |
|
405 | { | |
406 | rtems_status_code status; |
|
406 | rtems_status_code status; | |
407 |
|
407 | |||
408 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
408 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
409 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
409 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
410 | // -1 default hardcoded driver timeout |
|
410 | // -1 default hardcoded driver timeout | |
411 |
|
411 | |||
412 | return status; |
|
412 | return status; | |
413 | } |
|
413 | } | |
414 |
|
414 | |||
415 | int spacewire_configure_link( int fd ) |
|
415 | int spacewire_configure_link( int fd ) | |
416 | { |
|
416 | { | |
417 | /** This function configures the SpaceWire link. |
|
417 | /** This function configures the SpaceWire link. | |
418 | * |
|
418 | * | |
419 | * @return GR-RTEMS-DRIVER directive status codes: |
|
419 | * @return GR-RTEMS-DRIVER directive status codes: | |
420 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
420 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
421 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
421 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
422 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
422 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
423 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
423 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
424 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
424 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
425 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
425 | * - 5 EIO - Error when writing to grswp hardware registers. | |
426 | * - 2 ENOENT - No such file or directory |
|
426 | * - 2 ENOENT - No such file or directory | |
427 | */ |
|
427 | */ | |
428 |
|
428 | |||
429 | rtems_status_code status; |
|
429 | rtems_status_code status; | |
430 |
|
430 | |||
431 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
431 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
432 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
432 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
433 |
|
433 | |||
434 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
434 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
435 | if (status!=RTEMS_SUCCESSFUL) { |
|
435 | if (status!=RTEMS_SUCCESSFUL) { | |
436 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
436 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
437 | } |
|
437 | } | |
438 | // |
|
438 | // | |
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
440 | if (status!=RTEMS_SUCCESSFUL) { |
|
440 | if (status!=RTEMS_SUCCESSFUL) { | |
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
442 | } |
|
442 | } | |
443 | // |
|
443 | // | |
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
445 | if (status!=RTEMS_SUCCESSFUL) { |
|
445 | if (status!=RTEMS_SUCCESSFUL) { | |
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
447 | } |
|
447 | } | |
448 | // |
|
448 | // | |
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
450 | if (status!=RTEMS_SUCCESSFUL) { |
|
450 | if (status!=RTEMS_SUCCESSFUL) { | |
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
452 | } |
|
452 | } | |
453 | // |
|
453 | // | |
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks |
|
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks | |
455 | if (status!=RTEMS_SUCCESSFUL) { |
|
455 | if (status!=RTEMS_SUCCESSFUL) { | |
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
457 | } |
|
457 | } | |
458 | // |
|
458 | // | |
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
460 | if (status!=RTEMS_SUCCESSFUL) { |
|
460 | if (status!=RTEMS_SUCCESSFUL) { | |
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
462 | } |
|
462 | } | |
463 | // |
|
463 | // | |
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
465 | if (status!=RTEMS_SUCCESSFUL) { |
|
465 | if (status!=RTEMS_SUCCESSFUL) { | |
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 | return status; |
|
469 | return status; | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 | int spacewire_reset_link( void ) |
|
472 | int spacewire_reset_link( void ) | |
473 | { |
|
473 | { | |
474 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
474 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
475 | * |
|
475 | * | |
476 | * @return RTEMS directive status code: |
|
476 | * @return RTEMS directive status code: | |
477 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
477 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
478 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
478 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
479 | * |
|
479 | * | |
480 | */ |
|
480 | */ | |
481 |
|
481 | |||
482 | rtems_status_code status_spw; |
|
482 | rtems_status_code status_spw; | |
483 | rtems_status_code status; |
|
483 | rtems_status_code status; | |
484 | int i; |
|
484 | int i; | |
485 |
|
485 | |||
486 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
486 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
487 | { |
|
487 | { | |
488 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
488 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
489 |
|
489 | |||
490 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
490 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
491 |
|
491 | |||
492 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
492 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
493 |
|
493 | |||
494 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
494 | status_spw = spacewire_stop_and_start_link( fdSPW ); | |
495 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
495 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
496 | { |
|
496 | { | |
497 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
497 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
498 | } |
|
498 | } | |
499 |
|
499 | |||
500 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
500 | if ( status_spw == RTEMS_SUCCESSFUL) | |
501 | { |
|
501 | { | |
502 | break; |
|
502 | break; | |
503 | } |
|
503 | } | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | return status_spw; |
|
506 | return status_spw; | |
507 | } |
|
507 | } | |
508 |
|
508 | |||
509 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
509 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
510 | { |
|
510 | { | |
511 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
511 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
512 | * |
|
512 | * | |
513 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
513 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
514 | * @param regAddr is the address of the GRSPW control register. |
|
514 | * @param regAddr is the address of the GRSPW control register. | |
515 | * |
|
515 | * | |
516 | * NP is the bit 20 of the GRSPW control register. |
|
516 | * NP is the bit 20 of the GRSPW control register. | |
517 | * |
|
517 | * | |
518 | */ |
|
518 | */ | |
519 |
|
519 | |||
520 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
520 | unsigned int *spwptr = (unsigned int*) regAddr; | |
521 |
|
521 | |||
522 | if (val == 1) { |
|
522 | if (val == 1) { | |
523 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
523 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
524 | } |
|
524 | } | |
525 | if (val== 0) { |
|
525 | if (val== 0) { | |
526 | *spwptr = *spwptr & 0xffdfffff; |
|
526 | *spwptr = *spwptr & 0xffdfffff; | |
527 | } |
|
527 | } | |
528 | } |
|
528 | } | |
529 |
|
529 | |||
530 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
530 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
531 | { |
|
531 | { | |
532 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
532 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
533 | * |
|
533 | * | |
534 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
534 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
535 | * @param regAddr is the address of the GRSPW control register. |
|
535 | * @param regAddr is the address of the GRSPW control register. | |
536 | * |
|
536 | * | |
537 | * RE is the bit 16 of the GRSPW control register. |
|
537 | * RE is the bit 16 of the GRSPW control register. | |
538 | * |
|
538 | * | |
539 | */ |
|
539 | */ | |
540 |
|
540 | |||
541 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
541 | unsigned int *spwptr = (unsigned int*) regAddr; | |
542 |
|
542 | |||
543 | if (val == 1) |
|
543 | if (val == 1) | |
544 | { |
|
544 | { | |
545 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
545 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
546 | } |
|
546 | } | |
547 | if (val== 0) |
|
547 | if (val== 0) | |
548 | { |
|
548 | { | |
549 | *spwptr = *spwptr & 0xfffdffff; |
|
549 | *spwptr = *spwptr & 0xfffdffff; | |
550 | } |
|
550 | } | |
551 | } |
|
551 | } | |
552 |
|
552 | |||
553 | void spacewire_compute_stats_offsets( void ) |
|
553 | void spacewire_compute_stats_offsets( void ) | |
554 | { |
|
554 | { | |
555 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
555 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
556 | * |
|
556 | * | |
557 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
557 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
558 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
558 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
559 | * during the open systel call). |
|
559 | * during the open systel call). | |
560 | * |
|
560 | * | |
561 | */ |
|
561 | */ | |
562 |
|
562 | |||
563 | spw_stats spacewire_stats_grspw; |
|
563 | spw_stats spacewire_stats_grspw; | |
564 | rtems_status_code status; |
|
564 | rtems_status_code status; | |
565 |
|
565 | |||
566 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
566 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
567 |
|
567 | |||
568 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
568 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
569 | + spacewire_stats.packets_received; |
|
569 | + spacewire_stats.packets_received; | |
570 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
570 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
571 | + spacewire_stats.packets_sent; |
|
571 | + spacewire_stats.packets_sent; | |
572 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
572 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
573 | + spacewire_stats.parity_err; |
|
573 | + spacewire_stats.parity_err; | |
574 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
574 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
575 | + spacewire_stats.disconnect_err; |
|
575 | + spacewire_stats.disconnect_err; | |
576 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
576 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
577 | + spacewire_stats.escape_err; |
|
577 | + spacewire_stats.escape_err; | |
578 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
578 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
579 | + spacewire_stats.credit_err; |
|
579 | + spacewire_stats.credit_err; | |
580 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
580 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
581 | + spacewire_stats.write_sync_err; |
|
581 | + spacewire_stats.write_sync_err; | |
582 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
582 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
583 | + spacewire_stats.rx_rmap_header_crc_err; |
|
583 | + spacewire_stats.rx_rmap_header_crc_err; | |
584 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
584 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
585 | + spacewire_stats.rx_rmap_data_crc_err; |
|
585 | + spacewire_stats.rx_rmap_data_crc_err; | |
586 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
586 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
587 | + spacewire_stats.early_ep; |
|
587 | + spacewire_stats.early_ep; | |
588 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
588 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
589 | + spacewire_stats.invalid_address; |
|
589 | + spacewire_stats.invalid_address; | |
590 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
590 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
591 | + spacewire_stats.rx_eep_err; |
|
591 | + spacewire_stats.rx_eep_err; | |
592 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
592 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
593 | + spacewire_stats.rx_truncated; |
|
593 | + spacewire_stats.rx_truncated; | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | void spacewire_update_statistics( void ) |
|
596 | void spacewire_update_statistics( void ) | |
597 | { |
|
597 | { | |
598 | rtems_status_code status; |
|
598 | rtems_status_code status; | |
599 | spw_stats spacewire_stats_grspw; |
|
599 | spw_stats spacewire_stats_grspw; | |
600 |
|
600 | |||
601 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
601 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
602 |
|
602 | |||
603 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
603 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
604 | + spacewire_stats_grspw.packets_received; |
|
604 | + spacewire_stats_grspw.packets_received; | |
605 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
605 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
606 | + spacewire_stats_grspw.packets_sent; |
|
606 | + spacewire_stats_grspw.packets_sent; | |
607 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
607 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
608 | + spacewire_stats_grspw.parity_err; |
|
608 | + spacewire_stats_grspw.parity_err; | |
609 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
609 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
610 | + spacewire_stats_grspw.disconnect_err; |
|
610 | + spacewire_stats_grspw.disconnect_err; | |
611 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
611 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
612 | + spacewire_stats_grspw.escape_err; |
|
612 | + spacewire_stats_grspw.escape_err; | |
613 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
613 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
614 | + spacewire_stats_grspw.credit_err; |
|
614 | + spacewire_stats_grspw.credit_err; | |
615 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
615 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
616 | + spacewire_stats_grspw.write_sync_err; |
|
616 | + spacewire_stats_grspw.write_sync_err; | |
617 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
617 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
618 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
618 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
619 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
619 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
620 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
620 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
621 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
621 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
622 | + spacewire_stats_grspw.early_ep; |
|
622 | + spacewire_stats_grspw.early_ep; | |
623 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
623 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
624 | + spacewire_stats_grspw.invalid_address; |
|
624 | + spacewire_stats_grspw.invalid_address; | |
625 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
625 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
626 | + spacewire_stats_grspw.rx_eep_err; |
|
626 | + spacewire_stats_grspw.rx_eep_err; | |
627 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
627 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
628 | + spacewire_stats_grspw.rx_truncated; |
|
628 | + spacewire_stats_grspw.rx_truncated; | |
629 | //spacewire_stats.tx_link_err; |
|
629 | //spacewire_stats.tx_link_err; | |
630 |
|
630 | |||
631 | //**************************** |
|
631 | //**************************** | |
632 | // DPU_SPACEWIRE_IF_STATISTICS |
|
632 | // DPU_SPACEWIRE_IF_STATISTICS | |
633 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
633 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
634 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
634 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
635 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
635 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
636 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
636 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
637 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
637 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
638 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
638 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
639 |
|
639 | |||
640 | //****************************************** |
|
640 | //****************************************** | |
641 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
641 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
642 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
642 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
643 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
643 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
644 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
644 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
645 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
645 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
646 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
646 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
647 |
|
647 | |||
648 | //********************************************* |
|
648 | //********************************************* | |
649 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
649 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
650 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
650 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
651 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
651 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
652 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
652 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
653 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
653 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
654 | } |
|
654 | } | |
655 |
|
655 | |||
656 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
656 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
657 | { |
|
657 | { | |
658 | // a valid timecode has been received, write it in the HK report |
|
658 | // a valid timecode has been received, write it in the HK report | |
659 |
unsigned int * |
|
659 | unsigned int *grspwPtr; | |
|
660 | unsigned char timecodeCtr; | |||
|
661 | unsigned char updateTimeCtr; | |||
660 |
|
662 | |||
661 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); |
|
663 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); | |
662 |
|
664 | |||
663 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [11 1111] |
|
665 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] | |
|
666 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] | |||
|
667 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] | |||
664 |
|
668 | |||
665 | // update the number of valid timecodes that have been received |
|
669 | // update the number of valid timecodes that have been received | |
666 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) |
|
670 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) | |
667 | { |
|
671 | { | |
668 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; |
|
672 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; | |
669 | } |
|
673 | } | |
670 | else |
|
674 | else | |
671 | { |
|
675 | { | |
672 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; |
|
676 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; | |
673 | } |
|
677 | } | |
|
678 | ||||
|
679 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 | |||
|
680 | if (timecodeCtr != updateTimeCtr) | |||
|
681 | { | |||
|
682 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) | |||
|
683 | { | |||
|
684 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; | |||
|
685 | } | |||
|
686 | else | |||
|
687 | { | |||
|
688 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; | |||
|
689 | } | |||
|
690 | } | |||
674 | } |
|
691 | } | |
675 |
|
692 | |||
676 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
693 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) | |
677 | { |
|
694 | { | |
678 | int linkStatus; |
|
695 | int linkStatus; | |
679 | rtems_status_code status; |
|
696 | rtems_status_code status; | |
680 |
|
697 | |||
681 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
698 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
682 |
|
699 | |||
683 | if ( linkStatus == 5) { |
|
700 | if ( linkStatus == 5) { | |
684 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
701 | PRINTF("in spacewire_reset_link *** link is running\n") | |
685 | status = RTEMS_SUCCESSFUL; |
|
702 | status = RTEMS_SUCCESSFUL; | |
686 | } |
|
703 | } | |
687 | } |
|
704 | } | |
688 |
|
705 | |||
689 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
706 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) | |
690 | { |
|
707 | { | |
691 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
708 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
692 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
709 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
693 | header->reserved = DEFAULT_RESERVED; |
|
710 | header->reserved = DEFAULT_RESERVED; | |
694 | header->userApplication = CCSDS_USER_APP; |
|
711 | header->userApplication = CCSDS_USER_APP; | |
695 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; |
|
712 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; | |
696 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; |
|
713 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; | |
697 | header->packetLength[0] = 0x00; |
|
714 | header->packetLength[0] = 0x00; | |
698 | header->packetLength[1] = 0x00; |
|
715 | header->packetLength[1] = 0x00; | |
699 | // DATA FIELD HEADER |
|
716 | // DATA FIELD HEADER | |
700 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
717 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
701 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
718 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
702 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
719 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
703 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
720 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
704 | header->time[0] = 0x00; |
|
721 | header->time[0] = 0x00; | |
705 | header->time[0] = 0x00; |
|
722 | header->time[0] = 0x00; | |
706 | header->time[0] = 0x00; |
|
723 | header->time[0] = 0x00; | |
707 | header->time[0] = 0x00; |
|
724 | header->time[0] = 0x00; | |
708 | header->time[0] = 0x00; |
|
725 | header->time[0] = 0x00; | |
709 | header->time[0] = 0x00; |
|
726 | header->time[0] = 0x00; | |
710 | // AUXILIARY DATA HEADER |
|
727 | // AUXILIARY DATA HEADER | |
711 | header->sid = 0x00; |
|
728 | header->sid = 0x00; | |
712 | header->hkBIA = DEFAULT_HKBIA; |
|
729 | header->hkBIA = DEFAULT_HKBIA; | |
713 | header->blkNr[0] = 0x00; |
|
730 | header->blkNr[0] = 0x00; | |
714 | header->blkNr[1] = 0x00; |
|
731 | header->blkNr[1] = 0x00; | |
715 | } |
|
732 | } | |
716 |
|
733 | |||
717 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
734 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) | |
718 | { |
|
735 | { | |
719 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
736 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
720 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
737 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
721 | header->reserved = DEFAULT_RESERVED; |
|
738 | header->reserved = DEFAULT_RESERVED; | |
722 | header->userApplication = CCSDS_USER_APP; |
|
739 | header->userApplication = CCSDS_USER_APP; | |
723 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
740 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
724 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
741 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
725 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
742 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
726 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
743 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
727 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
744 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
728 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
745 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
729 | // DATA FIELD HEADER |
|
746 | // DATA FIELD HEADER | |
730 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
747 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
731 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
748 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
732 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
749 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
733 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
750 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
734 | header->time[0] = 0x00; |
|
751 | header->time[0] = 0x00; | |
735 | header->time[0] = 0x00; |
|
752 | header->time[0] = 0x00; | |
736 | header->time[0] = 0x00; |
|
753 | header->time[0] = 0x00; | |
737 | header->time[0] = 0x00; |
|
754 | header->time[0] = 0x00; | |
738 | header->time[0] = 0x00; |
|
755 | header->time[0] = 0x00; | |
739 | header->time[0] = 0x00; |
|
756 | header->time[0] = 0x00; | |
740 | // AUXILIARY DATA HEADER |
|
757 | // AUXILIARY DATA HEADER | |
741 | header->sid = 0x00; |
|
758 | header->sid = 0x00; | |
742 | header->hkBIA = DEFAULT_HKBIA; |
|
759 | header->hkBIA = DEFAULT_HKBIA; | |
743 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
760 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
744 | header->pktNr = 0x00; |
|
761 | header->pktNr = 0x00; | |
745 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
762 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
746 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
763 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
747 | } |
|
764 | } | |
748 |
|
765 | |||
749 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
766 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) | |
750 | { |
|
767 | { | |
751 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
768 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
752 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
769 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
753 | header->reserved = DEFAULT_RESERVED; |
|
770 | header->reserved = DEFAULT_RESERVED; | |
754 | header->userApplication = CCSDS_USER_APP; |
|
771 | header->userApplication = CCSDS_USER_APP; | |
755 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
772 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
756 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
773 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
757 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
774 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
758 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
775 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
759 | header->packetLength[0] = 0x00; |
|
776 | header->packetLength[0] = 0x00; | |
760 | header->packetLength[1] = 0x00; |
|
777 | header->packetLength[1] = 0x00; | |
761 | // DATA FIELD HEADER |
|
778 | // DATA FIELD HEADER | |
762 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
779 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
763 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
780 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
764 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
781 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
765 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
782 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
766 | header->time[0] = 0x00; |
|
783 | header->time[0] = 0x00; | |
767 | header->time[0] = 0x00; |
|
784 | header->time[0] = 0x00; | |
768 | header->time[0] = 0x00; |
|
785 | header->time[0] = 0x00; | |
769 | header->time[0] = 0x00; |
|
786 | header->time[0] = 0x00; | |
770 | header->time[0] = 0x00; |
|
787 | header->time[0] = 0x00; | |
771 | header->time[0] = 0x00; |
|
788 | header->time[0] = 0x00; | |
772 | // AUXILIARY DATA HEADER |
|
789 | // AUXILIARY DATA HEADER | |
773 | header->sid = 0x00; |
|
790 | header->sid = 0x00; | |
774 | header->biaStatusInfo = 0x00; |
|
791 | header->biaStatusInfo = 0x00; | |
775 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
792 | header->pa_lfr_pkt_cnt_asm = 0x00; | |
776 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
793 | header->pa_lfr_pkt_nr_asm = 0x00; | |
777 | header->pa_lfr_asm_blk_nr[0] = 0x00; |
|
794 | header->pa_lfr_asm_blk_nr[0] = 0x00; | |
778 | header->pa_lfr_asm_blk_nr[1] = 0x00; |
|
795 | header->pa_lfr_asm_blk_nr[1] = 0x00; | |
779 | } |
|
796 | } | |
780 |
|
797 | |||
781 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, |
|
798 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, | |
782 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
799 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
783 | { |
|
800 | { | |
784 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
801 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
785 | * |
|
802 | * | |
786 | * @param waveform points to the buffer containing the data that will be send. |
|
803 | * @param waveform points to the buffer containing the data that will be send. | |
787 | * @param sid is the source identifier of the data that will be sent. |
|
804 | * @param sid is the source identifier of the data that will be sent. | |
788 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
805 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
789 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
806 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
790 | * contain information to setup the transmission of the data packets. |
|
807 | * contain information to setup the transmission of the data packets. | |
791 | * |
|
808 | * | |
792 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
809 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
793 | * |
|
810 | * | |
794 | */ |
|
811 | */ | |
795 |
|
812 | |||
796 | unsigned int i; |
|
813 | unsigned int i; | |
797 | int ret; |
|
814 | int ret; | |
798 | unsigned int coarseTime; |
|
815 | unsigned int coarseTime; | |
799 | unsigned int fineTime; |
|
816 | unsigned int fineTime; | |
800 | rtems_status_code status; |
|
817 | rtems_status_code status; | |
801 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
818 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
802 | int *dataPtr; |
|
819 | int *dataPtr; | |
803 | unsigned char sid; |
|
820 | unsigned char sid; | |
804 |
|
821 | |||
805 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
822 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
806 | spw_ioctl_send_CWF.options = 0; |
|
823 | spw_ioctl_send_CWF.options = 0; | |
807 |
|
824 | |||
808 | ret = LFR_DEFAULT; |
|
825 | ret = LFR_DEFAULT; | |
809 | sid = (unsigned char) ring_node_to_send->sid; |
|
826 | sid = (unsigned char) ring_node_to_send->sid; | |
810 |
|
827 | |||
811 | coarseTime = ring_node_to_send->coarseTime; |
|
828 | coarseTime = ring_node_to_send->coarseTime; | |
812 | fineTime = ring_node_to_send->fineTime; |
|
829 | fineTime = ring_node_to_send->fineTime; | |
813 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
830 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
814 |
|
831 | |||
815 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
832 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
816 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
833 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
817 | header->hkBIA = pa_bia_status_info; |
|
834 | header->hkBIA = pa_bia_status_info; | |
818 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
835 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
819 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
836 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
820 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
837 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
821 |
|
838 | |||
822 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
839 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |
823 | { |
|
840 | { | |
824 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
841 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; | |
825 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
842 | spw_ioctl_send_CWF.hdr = (char*) header; | |
826 | // BUILD THE DATA |
|
843 | // BUILD THE DATA | |
827 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
844 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
828 |
|
845 | |||
829 | // SET PACKET SEQUENCE CONTROL |
|
846 | // SET PACKET SEQUENCE CONTROL | |
830 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
847 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
831 |
|
848 | |||
832 | // SET SID |
|
849 | // SET SID | |
833 | header->sid = sid; |
|
850 | header->sid = sid; | |
834 |
|
851 | |||
835 | // SET PACKET TIME |
|
852 | // SET PACKET TIME | |
836 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); |
|
853 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); | |
837 | // |
|
854 | // | |
838 | header->time[0] = header->acquisitionTime[0]; |
|
855 | header->time[0] = header->acquisitionTime[0]; | |
839 | header->time[1] = header->acquisitionTime[1]; |
|
856 | header->time[1] = header->acquisitionTime[1]; | |
840 | header->time[2] = header->acquisitionTime[2]; |
|
857 | header->time[2] = header->acquisitionTime[2]; | |
841 | header->time[3] = header->acquisitionTime[3]; |
|
858 | header->time[3] = header->acquisitionTime[3]; | |
842 | header->time[4] = header->acquisitionTime[4]; |
|
859 | header->time[4] = header->acquisitionTime[4]; | |
843 | header->time[5] = header->acquisitionTime[5]; |
|
860 | header->time[5] = header->acquisitionTime[5]; | |
844 |
|
861 | |||
845 | // SET PACKET ID |
|
862 | // SET PACKET ID | |
846 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
863 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
847 | { |
|
864 | { | |
848 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
865 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); | |
849 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
866 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); | |
850 | } |
|
867 | } | |
851 | else |
|
868 | else | |
852 | { |
|
869 | { | |
853 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
870 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
854 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
871 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
855 | } |
|
872 | } | |
856 |
|
873 | |||
857 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
874 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
858 | if (status != RTEMS_SUCCESSFUL) { |
|
875 | if (status != RTEMS_SUCCESSFUL) { | |
859 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
876 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
860 | ret = LFR_DEFAULT; |
|
877 | ret = LFR_DEFAULT; | |
861 | } |
|
878 | } | |
862 | } |
|
879 | } | |
863 |
|
880 | |||
864 | return ret; |
|
881 | return ret; | |
865 | } |
|
882 | } | |
866 |
|
883 | |||
867 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, |
|
884 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, | |
868 | Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
885 | Header_TM_LFR_SCIENCE_SWF_t *header ) | |
869 | { |
|
886 | { | |
870 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
887 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
871 | * |
|
888 | * | |
872 | * @param waveform points to the buffer containing the data that will be send. |
|
889 | * @param waveform points to the buffer containing the data that will be send. | |
873 | * @param sid is the source identifier of the data that will be sent. |
|
890 | * @param sid is the source identifier of the data that will be sent. | |
874 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
891 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
875 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
892 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
876 | * contain information to setup the transmission of the data packets. |
|
893 | * contain information to setup the transmission of the data packets. | |
877 | * |
|
894 | * | |
878 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
895 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
879 | * |
|
896 | * | |
880 | */ |
|
897 | */ | |
881 |
|
898 | |||
882 | unsigned int i; |
|
899 | unsigned int i; | |
883 | int ret; |
|
900 | int ret; | |
884 | unsigned int coarseTime; |
|
901 | unsigned int coarseTime; | |
885 | unsigned int fineTime; |
|
902 | unsigned int fineTime; | |
886 | rtems_status_code status; |
|
903 | rtems_status_code status; | |
887 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
904 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
888 | int *dataPtr; |
|
905 | int *dataPtr; | |
889 | unsigned char sid; |
|
906 | unsigned char sid; | |
890 |
|
907 | |||
891 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; |
|
908 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; | |
892 | spw_ioctl_send_SWF.options = 0; |
|
909 | spw_ioctl_send_SWF.options = 0; | |
893 |
|
910 | |||
894 | ret = LFR_DEFAULT; |
|
911 | ret = LFR_DEFAULT; | |
895 |
|
912 | |||
896 | coarseTime = ring_node_to_send->coarseTime; |
|
913 | coarseTime = ring_node_to_send->coarseTime; | |
897 | fineTime = ring_node_to_send->fineTime; |
|
914 | fineTime = ring_node_to_send->fineTime; | |
898 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
915 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
899 | sid = ring_node_to_send->sid; |
|
916 | sid = ring_node_to_send->sid; | |
900 |
|
917 | |||
901 | header->hkBIA = pa_bia_status_info; |
|
918 | header->hkBIA = pa_bia_status_info; | |
902 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
919 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
903 |
|
920 | |||
904 | for (i=0; i<7; i++) // send waveform |
|
921 | for (i=0; i<7; i++) // send waveform | |
905 | { |
|
922 | { | |
906 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
923 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; | |
907 | spw_ioctl_send_SWF.hdr = (char*) header; |
|
924 | spw_ioctl_send_SWF.hdr = (char*) header; | |
908 |
|
925 | |||
909 | // SET PACKET SEQUENCE CONTROL |
|
926 | // SET PACKET SEQUENCE CONTROL | |
910 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
927 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
911 |
|
928 | |||
912 | // SET PACKET LENGTH AND BLKNR |
|
929 | // SET PACKET LENGTH AND BLKNR | |
913 | if (i == 6) |
|
930 | if (i == 6) | |
914 | { |
|
931 | { | |
915 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
932 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
916 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
933 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
917 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
934 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
918 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
935 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
919 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
936 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
920 | } |
|
937 | } | |
921 | else |
|
938 | else | |
922 | { |
|
939 | { | |
923 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
940 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
924 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
941 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
925 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
942 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
926 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
943 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
927 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
944 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
928 | } |
|
945 | } | |
929 |
|
946 | |||
930 | // SET PACKET TIME |
|
947 | // SET PACKET TIME | |
931 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); |
|
948 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); | |
932 | // |
|
949 | // | |
933 | header->time[0] = header->acquisitionTime[0]; |
|
950 | header->time[0] = header->acquisitionTime[0]; | |
934 | header->time[1] = header->acquisitionTime[1]; |
|
951 | header->time[1] = header->acquisitionTime[1]; | |
935 | header->time[2] = header->acquisitionTime[2]; |
|
952 | header->time[2] = header->acquisitionTime[2]; | |
936 | header->time[3] = header->acquisitionTime[3]; |
|
953 | header->time[3] = header->acquisitionTime[3]; | |
937 | header->time[4] = header->acquisitionTime[4]; |
|
954 | header->time[4] = header->acquisitionTime[4]; | |
938 | header->time[5] = header->acquisitionTime[5]; |
|
955 | header->time[5] = header->acquisitionTime[5]; | |
939 |
|
956 | |||
940 | // SET SID |
|
957 | // SET SID | |
941 | header->sid = sid; |
|
958 | header->sid = sid; | |
942 |
|
959 | |||
943 | // SET PKTNR |
|
960 | // SET PKTNR | |
944 | header->pktNr = i+1; // PKT_NR |
|
961 | header->pktNr = i+1; // PKT_NR | |
945 |
|
962 | |||
946 | // SEND PACKET |
|
963 | // SEND PACKET | |
947 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); |
|
964 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); | |
948 | if (status != RTEMS_SUCCESSFUL) { |
|
965 | if (status != RTEMS_SUCCESSFUL) { | |
949 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
966 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
950 | ret = LFR_DEFAULT; |
|
967 | ret = LFR_DEFAULT; | |
951 | } |
|
968 | } | |
952 | } |
|
969 | } | |
953 |
|
970 | |||
954 | return ret; |
|
971 | return ret; | |
955 | } |
|
972 | } | |
956 |
|
973 | |||
957 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, |
|
974 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, | |
958 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
975 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
959 | { |
|
976 | { | |
960 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
977 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
961 | * |
|
978 | * | |
962 | * @param waveform points to the buffer containing the data that will be send. |
|
979 | * @param waveform points to the buffer containing the data that will be send. | |
963 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
980 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
964 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
981 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
965 | * contain information to setup the transmission of the data packets. |
|
982 | * contain information to setup the transmission of the data packets. | |
966 | * |
|
983 | * | |
967 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
984 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
968 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
985 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
969 | * |
|
986 | * | |
970 | */ |
|
987 | */ | |
971 |
|
988 | |||
972 | unsigned int i; |
|
989 | unsigned int i; | |
973 | int ret; |
|
990 | int ret; | |
974 | unsigned int coarseTime; |
|
991 | unsigned int coarseTime; | |
975 | unsigned int fineTime; |
|
992 | unsigned int fineTime; | |
976 | rtems_status_code status; |
|
993 | rtems_status_code status; | |
977 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
994 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
978 | char *dataPtr; |
|
995 | char *dataPtr; | |
979 | unsigned char sid; |
|
996 | unsigned char sid; | |
980 |
|
997 | |||
981 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
998 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
982 | spw_ioctl_send_CWF.options = 0; |
|
999 | spw_ioctl_send_CWF.options = 0; | |
983 |
|
1000 | |||
984 | ret = LFR_DEFAULT; |
|
1001 | ret = LFR_DEFAULT; | |
985 | sid = ring_node_to_send->sid; |
|
1002 | sid = ring_node_to_send->sid; | |
986 |
|
1003 | |||
987 | coarseTime = ring_node_to_send->coarseTime; |
|
1004 | coarseTime = ring_node_to_send->coarseTime; | |
988 | fineTime = ring_node_to_send->fineTime; |
|
1005 | fineTime = ring_node_to_send->fineTime; | |
989 | dataPtr = (char*) ring_node_to_send->buffer_address; |
|
1006 | dataPtr = (char*) ring_node_to_send->buffer_address; | |
990 |
|
1007 | |||
991 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
1008 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
992 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
1009 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
993 | header->hkBIA = pa_bia_status_info; |
|
1010 | header->hkBIA = pa_bia_status_info; | |
994 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1011 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
995 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
1012 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
996 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
1013 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
997 |
|
1014 | |||
998 | //********************* |
|
1015 | //********************* | |
999 | // SEND CWF3_light DATA |
|
1016 | // SEND CWF3_light DATA | |
1000 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
1017 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | |
1001 | { |
|
1018 | { | |
1002 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
1019 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
1003 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
1020 | spw_ioctl_send_CWF.hdr = (char*) header; | |
1004 | // BUILD THE DATA |
|
1021 | // BUILD THE DATA | |
1005 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
1022 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1006 |
|
1023 | |||
1007 | // SET PACKET SEQUENCE COUNTER |
|
1024 | // SET PACKET SEQUENCE COUNTER | |
1008 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1025 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1009 |
|
1026 | |||
1010 | // SET SID |
|
1027 | // SET SID | |
1011 | header->sid = sid; |
|
1028 | header->sid = sid; | |
1012 |
|
1029 | |||
1013 | // SET PACKET TIME |
|
1030 | // SET PACKET TIME | |
1014 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); |
|
1031 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); | |
1015 | // |
|
1032 | // | |
1016 | header->time[0] = header->acquisitionTime[0]; |
|
1033 | header->time[0] = header->acquisitionTime[0]; | |
1017 | header->time[1] = header->acquisitionTime[1]; |
|
1034 | header->time[1] = header->acquisitionTime[1]; | |
1018 | header->time[2] = header->acquisitionTime[2]; |
|
1035 | header->time[2] = header->acquisitionTime[2]; | |
1019 | header->time[3] = header->acquisitionTime[3]; |
|
1036 | header->time[3] = header->acquisitionTime[3]; | |
1020 | header->time[4] = header->acquisitionTime[4]; |
|
1037 | header->time[4] = header->acquisitionTime[4]; | |
1021 | header->time[5] = header->acquisitionTime[5]; |
|
1038 | header->time[5] = header->acquisitionTime[5]; | |
1022 |
|
1039 | |||
1023 | // SET PACKET ID |
|
1040 | // SET PACKET ID | |
1024 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
1041 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
1025 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
1042 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
1026 |
|
1043 | |||
1027 | // SEND PACKET |
|
1044 | // SEND PACKET | |
1028 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
1045 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
1029 | if (status != RTEMS_SUCCESSFUL) { |
|
1046 | if (status != RTEMS_SUCCESSFUL) { | |
1030 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
1047 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
1031 | ret = LFR_DEFAULT; |
|
1048 | ret = LFR_DEFAULT; | |
1032 | } |
|
1049 | } | |
1033 | } |
|
1050 | } | |
1034 |
|
1051 | |||
1035 | return ret; |
|
1052 | return ret; | |
1036 | } |
|
1053 | } | |
1037 |
|
1054 | |||
1038 | void spw_send_asm_f0( ring_node *ring_node_to_send, |
|
1055 | void spw_send_asm_f0( ring_node *ring_node_to_send, | |
1039 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1056 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1040 | { |
|
1057 | { | |
1041 | unsigned int i; |
|
1058 | unsigned int i; | |
1042 | unsigned int length = 0; |
|
1059 | unsigned int length = 0; | |
1043 | rtems_status_code status; |
|
1060 | rtems_status_code status; | |
1044 | unsigned int sid; |
|
1061 | unsigned int sid; | |
1045 | float *spectral_matrix; |
|
1062 | float *spectral_matrix; | |
1046 | int coarseTime; |
|
1063 | int coarseTime; | |
1047 | int fineTime; |
|
1064 | int fineTime; | |
1048 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1065 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1049 |
|
1066 | |||
1050 | sid = ring_node_to_send->sid; |
|
1067 | sid = ring_node_to_send->sid; | |
1051 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1068 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1052 | coarseTime = ring_node_to_send->coarseTime; |
|
1069 | coarseTime = ring_node_to_send->coarseTime; | |
1053 | fineTime = ring_node_to_send->fineTime; |
|
1070 | fineTime = ring_node_to_send->fineTime; | |
1054 |
|
1071 | |||
1055 | header->biaStatusInfo = pa_bia_status_info; |
|
1072 | header->biaStatusInfo = pa_bia_status_info; | |
1056 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1073 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1057 |
|
1074 | |||
1058 | for (i=0; i<3; i++) |
|
1075 | for (i=0; i<3; i++) | |
1059 | { |
|
1076 | { | |
1060 | if ((i==0) || (i==1)) |
|
1077 | if ((i==0) || (i==1)) | |
1061 | { |
|
1078 | { | |
1062 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; |
|
1079 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; | |
1063 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1080 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1064 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1081 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1065 | ]; |
|
1082 | ]; | |
1066 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; |
|
1083 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; | |
1067 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1084 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1068 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB |
|
1085 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB | |
1069 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB |
|
1086 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB | |
1070 | } |
|
1087 | } | |
1071 | else |
|
1088 | else | |
1072 | { |
|
1089 | { | |
1073 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; |
|
1090 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; | |
1074 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1091 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1075 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1092 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1076 | ]; |
|
1093 | ]; | |
1077 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; |
|
1094 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; | |
1078 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1095 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1079 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB |
|
1096 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB | |
1080 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB |
|
1097 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB | |
1081 | } |
|
1098 | } | |
1082 |
|
1099 | |||
1083 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1100 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1084 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1101 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1085 | spw_ioctl_send_ASM.options = 0; |
|
1102 | spw_ioctl_send_ASM.options = 0; | |
1086 |
|
1103 | |||
1087 | // (2) BUILD THE HEADER |
|
1104 | // (2) BUILD THE HEADER | |
1088 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1105 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1089 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1106 | header->packetLength[0] = (unsigned char) (length>>8); | |
1090 | header->packetLength[1] = (unsigned char) (length); |
|
1107 | header->packetLength[1] = (unsigned char) (length); | |
1091 | header->sid = (unsigned char) sid; // SID |
|
1108 | header->sid = (unsigned char) sid; // SID | |
1092 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1109 | header->pa_lfr_pkt_cnt_asm = 3; | |
1093 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1110 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1094 |
|
1111 | |||
1095 | // (3) SET PACKET TIME |
|
1112 | // (3) SET PACKET TIME | |
1096 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1113 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1097 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1114 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1098 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1115 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1099 | header->time[3] = (unsigned char) (coarseTime); |
|
1116 | header->time[3] = (unsigned char) (coarseTime); | |
1100 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1117 | header->time[4] = (unsigned char) (fineTime>>8); | |
1101 | header->time[5] = (unsigned char) (fineTime); |
|
1118 | header->time[5] = (unsigned char) (fineTime); | |
1102 | // |
|
1119 | // | |
1103 | header->acquisitionTime[0] = header->time[0]; |
|
1120 | header->acquisitionTime[0] = header->time[0]; | |
1104 | header->acquisitionTime[1] = header->time[1]; |
|
1121 | header->acquisitionTime[1] = header->time[1]; | |
1105 | header->acquisitionTime[2] = header->time[2]; |
|
1122 | header->acquisitionTime[2] = header->time[2]; | |
1106 | header->acquisitionTime[3] = header->time[3]; |
|
1123 | header->acquisitionTime[3] = header->time[3]; | |
1107 | header->acquisitionTime[4] = header->time[4]; |
|
1124 | header->acquisitionTime[4] = header->time[4]; | |
1108 | header->acquisitionTime[5] = header->time[5]; |
|
1125 | header->acquisitionTime[5] = header->time[5]; | |
1109 |
|
1126 | |||
1110 | // (4) SEND PACKET |
|
1127 | // (4) SEND PACKET | |
1111 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1128 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1112 | if (status != RTEMS_SUCCESSFUL) { |
|
1129 | if (status != RTEMS_SUCCESSFUL) { | |
1113 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
1130 | printf("in ASM_send *** ERR %d\n", (int) status); | |
1114 | } |
|
1131 | } | |
1115 | } |
|
1132 | } | |
1116 | } |
|
1133 | } | |
1117 |
|
1134 | |||
1118 | void spw_send_asm_f1( ring_node *ring_node_to_send, |
|
1135 | void spw_send_asm_f1( ring_node *ring_node_to_send, | |
1119 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1136 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1120 | { |
|
1137 | { | |
1121 | unsigned int i; |
|
1138 | unsigned int i; | |
1122 | unsigned int length = 0; |
|
1139 | unsigned int length = 0; | |
1123 | rtems_status_code status; |
|
1140 | rtems_status_code status; | |
1124 | unsigned int sid; |
|
1141 | unsigned int sid; | |
1125 | float *spectral_matrix; |
|
1142 | float *spectral_matrix; | |
1126 | int coarseTime; |
|
1143 | int coarseTime; | |
1127 | int fineTime; |
|
1144 | int fineTime; | |
1128 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1145 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1129 |
|
1146 | |||
1130 | sid = ring_node_to_send->sid; |
|
1147 | sid = ring_node_to_send->sid; | |
1131 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1148 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1132 | coarseTime = ring_node_to_send->coarseTime; |
|
1149 | coarseTime = ring_node_to_send->coarseTime; | |
1133 | fineTime = ring_node_to_send->fineTime; |
|
1150 | fineTime = ring_node_to_send->fineTime; | |
1134 |
|
1151 | |||
1135 | header->biaStatusInfo = pa_bia_status_info; |
|
1152 | header->biaStatusInfo = pa_bia_status_info; | |
1136 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1153 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1137 |
|
1154 | |||
1138 | for (i=0; i<3; i++) |
|
1155 | for (i=0; i<3; i++) | |
1139 | { |
|
1156 | { | |
1140 | if ((i==0) || (i==1)) |
|
1157 | if ((i==0) || (i==1)) | |
1141 | { |
|
1158 | { | |
1142 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; |
|
1159 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; | |
1143 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1160 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1144 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1161 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1145 | ]; |
|
1162 | ]; | |
1146 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; |
|
1163 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; | |
1147 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1164 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1148 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB |
|
1165 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB | |
1149 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB |
|
1166 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB | |
1150 | } |
|
1167 | } | |
1151 | else |
|
1168 | else | |
1152 | { |
|
1169 | { | |
1153 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; |
|
1170 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; | |
1154 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1171 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1155 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1172 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1156 | ]; |
|
1173 | ]; | |
1157 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; |
|
1174 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; | |
1158 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1175 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1159 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB |
|
1176 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB | |
1160 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB |
|
1177 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB | |
1161 | } |
|
1178 | } | |
1162 |
|
1179 | |||
1163 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1180 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1164 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1181 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1165 | spw_ioctl_send_ASM.options = 0; |
|
1182 | spw_ioctl_send_ASM.options = 0; | |
1166 |
|
1183 | |||
1167 | // (2) BUILD THE HEADER |
|
1184 | // (2) BUILD THE HEADER | |
1168 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1185 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1169 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1186 | header->packetLength[0] = (unsigned char) (length>>8); | |
1170 | header->packetLength[1] = (unsigned char) (length); |
|
1187 | header->packetLength[1] = (unsigned char) (length); | |
1171 | header->sid = (unsigned char) sid; // SID |
|
1188 | header->sid = (unsigned char) sid; // SID | |
1172 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1189 | header->pa_lfr_pkt_cnt_asm = 3; | |
1173 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1190 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1174 |
|
1191 | |||
1175 | // (3) SET PACKET TIME |
|
1192 | // (3) SET PACKET TIME | |
1176 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1193 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1177 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1194 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1178 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1195 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1179 | header->time[3] = (unsigned char) (coarseTime); |
|
1196 | header->time[3] = (unsigned char) (coarseTime); | |
1180 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1197 | header->time[4] = (unsigned char) (fineTime>>8); | |
1181 | header->time[5] = (unsigned char) (fineTime); |
|
1198 | header->time[5] = (unsigned char) (fineTime); | |
1182 | // |
|
1199 | // | |
1183 | header->acquisitionTime[0] = header->time[0]; |
|
1200 | header->acquisitionTime[0] = header->time[0]; | |
1184 | header->acquisitionTime[1] = header->time[1]; |
|
1201 | header->acquisitionTime[1] = header->time[1]; | |
1185 | header->acquisitionTime[2] = header->time[2]; |
|
1202 | header->acquisitionTime[2] = header->time[2]; | |
1186 | header->acquisitionTime[3] = header->time[3]; |
|
1203 | header->acquisitionTime[3] = header->time[3]; | |
1187 | header->acquisitionTime[4] = header->time[4]; |
|
1204 | header->acquisitionTime[4] = header->time[4]; | |
1188 | header->acquisitionTime[5] = header->time[5]; |
|
1205 | header->acquisitionTime[5] = header->time[5]; | |
1189 |
|
1206 | |||
1190 | // (4) SEND PACKET |
|
1207 | // (4) SEND PACKET | |
1191 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1208 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1192 | if (status != RTEMS_SUCCESSFUL) { |
|
1209 | if (status != RTEMS_SUCCESSFUL) { | |
1193 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
1210 | printf("in ASM_send *** ERR %d\n", (int) status); | |
1194 | } |
|
1211 | } | |
1195 | } |
|
1212 | } | |
1196 | } |
|
1213 | } | |
1197 |
|
1214 | |||
1198 | void spw_send_asm_f2( ring_node *ring_node_to_send, |
|
1215 | void spw_send_asm_f2( ring_node *ring_node_to_send, | |
1199 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1216 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1200 | { |
|
1217 | { | |
1201 | unsigned int i; |
|
1218 | unsigned int i; | |
1202 | unsigned int length = 0; |
|
1219 | unsigned int length = 0; | |
1203 | rtems_status_code status; |
|
1220 | rtems_status_code status; | |
1204 | unsigned int sid; |
|
1221 | unsigned int sid; | |
1205 | float *spectral_matrix; |
|
1222 | float *spectral_matrix; | |
1206 | int coarseTime; |
|
1223 | int coarseTime; | |
1207 | int fineTime; |
|
1224 | int fineTime; | |
1208 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1225 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1209 |
|
1226 | |||
1210 | sid = ring_node_to_send->sid; |
|
1227 | sid = ring_node_to_send->sid; | |
1211 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1228 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1212 | coarseTime = ring_node_to_send->coarseTime; |
|
1229 | coarseTime = ring_node_to_send->coarseTime; | |
1213 | fineTime = ring_node_to_send->fineTime; |
|
1230 | fineTime = ring_node_to_send->fineTime; | |
1214 |
|
1231 | |||
1215 | header->biaStatusInfo = pa_bia_status_info; |
|
1232 | header->biaStatusInfo = pa_bia_status_info; | |
1216 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1233 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1217 |
|
1234 | |||
1218 | for (i=0; i<3; i++) |
|
1235 | for (i=0; i<3; i++) | |
1219 | { |
|
1236 | { | |
1220 |
|
1237 | |||
1221 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; |
|
1238 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; | |
1222 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1239 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1223 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) |
|
1240 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) | |
1224 | ]; |
|
1241 | ]; | |
1225 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
1242 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; | |
1226 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; |
|
1243 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; | |
1227 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
1244 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB | |
1228 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
1245 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB | |
1229 |
|
1246 | |||
1230 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1247 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1231 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1248 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1232 | spw_ioctl_send_ASM.options = 0; |
|
1249 | spw_ioctl_send_ASM.options = 0; | |
1233 |
|
1250 | |||
1234 | // (2) BUILD THE HEADER |
|
1251 | // (2) BUILD THE HEADER | |
1235 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1252 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1236 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1253 | header->packetLength[0] = (unsigned char) (length>>8); | |
1237 | header->packetLength[1] = (unsigned char) (length); |
|
1254 | header->packetLength[1] = (unsigned char) (length); | |
1238 | header->sid = (unsigned char) sid; // SID |
|
1255 | header->sid = (unsigned char) sid; // SID | |
1239 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1256 | header->pa_lfr_pkt_cnt_asm = 3; | |
1240 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1257 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1241 |
|
1258 | |||
1242 | // (3) SET PACKET TIME |
|
1259 | // (3) SET PACKET TIME | |
1243 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1260 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1244 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1261 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1245 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1262 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1246 | header->time[3] = (unsigned char) (coarseTime); |
|
1263 | header->time[3] = (unsigned char) (coarseTime); | |
1247 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1264 | header->time[4] = (unsigned char) (fineTime>>8); | |
1248 | header->time[5] = (unsigned char) (fineTime); |
|
1265 | header->time[5] = (unsigned char) (fineTime); | |
1249 | // |
|
1266 | // | |
1250 | header->acquisitionTime[0] = header->time[0]; |
|
1267 | header->acquisitionTime[0] = header->time[0]; | |
1251 | header->acquisitionTime[1] = header->time[1]; |
|
1268 | header->acquisitionTime[1] = header->time[1]; | |
1252 | header->acquisitionTime[2] = header->time[2]; |
|
1269 | header->acquisitionTime[2] = header->time[2]; | |
1253 | header->acquisitionTime[3] = header->time[3]; |
|
1270 | header->acquisitionTime[3] = header->time[3]; | |
1254 | header->acquisitionTime[4] = header->time[4]; |
|
1271 | header->acquisitionTime[4] = header->time[4]; | |
1255 | header->acquisitionTime[5] = header->time[5]; |
|
1272 | header->acquisitionTime[5] = header->time[5]; | |
1256 |
|
1273 | |||
1257 | // (4) SEND PACKET |
|
1274 | // (4) SEND PACKET | |
1258 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1275 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1259 | if (status != RTEMS_SUCCESSFUL) { |
|
1276 | if (status != RTEMS_SUCCESSFUL) { | |
1260 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
1277 | printf("in ASM_send *** ERR %d\n", (int) status); | |
1261 | } |
|
1278 | } | |
1262 | } |
|
1279 | } | |
1263 | } |
|
1280 | } | |
1264 |
|
1281 | |||
1265 | void spw_send_k_dump( ring_node *ring_node_to_send ) |
|
1282 | void spw_send_k_dump( ring_node *ring_node_to_send ) | |
1266 | { |
|
1283 | { | |
1267 | rtems_status_code status; |
|
1284 | rtems_status_code status; | |
1268 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; |
|
1285 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; | |
1269 | unsigned int packetLength; |
|
1286 | unsigned int packetLength; | |
1270 | unsigned int size; |
|
1287 | unsigned int size; | |
1271 |
|
1288 | |||
1272 | printf("spw_send_k_dump\n"); |
|
1289 | printf("spw_send_k_dump\n"); | |
1273 |
|
1290 | |||
1274 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; |
|
1291 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; | |
1275 |
|
1292 | |||
1276 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; |
|
1293 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; | |
1277 |
|
1294 | |||
1278 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
1295 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
1279 |
|
1296 | |||
1280 | printf("packetLength %d, size %d\n", packetLength, size ); |
|
1297 | printf("packetLength %d, size %d\n", packetLength, size ); | |
1281 |
|
1298 | |||
1282 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); |
|
1299 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); | |
1283 |
|
1300 | |||
1284 | if (status == -1){ |
|
1301 | if (status == -1){ | |
1285 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
1302 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
1286 | } |
|
1303 | } | |
1287 |
|
1304 | |||
1288 | ring_node_to_send->status = 0x00; |
|
1305 | ring_node_to_send->status = 0x00; | |
1289 | } |
|
1306 | } |
General Comments 0
You need to be logged in to leave comments.
Login now