##// END OF EJS Templates
TM_LFR_TC_EXE packet sending reworked...
paul -
r37:ce861ac72296 default
parent child
Show More
@@ -0,0 +1,6
1 #ifndef TM_BYTE_POSITIONS_H
2 #define TM_BYTE_POSITIONS_H
3
4 #define BYTE_POS_CP_LFR_MODE 11
5
6 #endif // TM_BYTE_POSITIONS_H
@@ -1,6 +1,6
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 10 08:47:12 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 10 15:46:11 2013
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
1 NO CONTENT: modified file, binary diff hidden
@@ -58,5 +58,6 HEADERS += \
58 58 ../header/fsw_init.h \
59 59 ../header/ccsds_types.h \
60 60 ../header/fsw_params_processing.h \
61 ../header/fsw_spacewire.h
61 ../header/fsw_spacewire.h \
62 ../header/tm_byte_positions.h
62 63
@@ -235,6 +235,131 struct Packet_TM_LFR_TC_EXE_str
235 235 };
236 236 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
237 237
238 struct Packet_TM_LFR_TC_EXE_SUCCESS_str
239 {
240 volatile unsigned char targetLogicalAddress;
241 volatile unsigned char protocolIdentifier;
242 volatile unsigned char reserved;
243 volatile unsigned char userApplication;
244 // PACKET HEADER
245 volatile unsigned char packetID[2];
246 volatile unsigned char packetSequenceControl[2];
247 volatile unsigned char packetLength[2];
248 // DATA FIELD HEADER
249 volatile unsigned char spare1_pusVersion_spare2;
250 volatile unsigned char serviceType;
251 volatile unsigned char serviceSubType;
252 volatile unsigned char destinationID;
253 volatile unsigned char time[6];
254 //
255 volatile unsigned char telecommand_pkt_id[2];
256 volatile unsigned char pkt_seq_control[2];
257 };
258 typedef struct Packet_TM_LFR_TC_EXE_SUCCESS_str Packet_TM_LFR_TC_EXE_SUCCESS_t;
259
260 struct Packet_TM_LFR_TC_EXE_INCONSISTENT_str
261 {
262 volatile unsigned char targetLogicalAddress;
263 volatile unsigned char protocolIdentifier;
264 volatile unsigned char reserved;
265 volatile unsigned char userApplication;
266 // PACKET HEADER
267 volatile unsigned char packetID[2];
268 volatile unsigned char packetSequenceControl[2];
269 volatile unsigned char packetLength[2];
270 // DATA FIELD HEADER
271 volatile unsigned char spare1_pusVersion_spare2;
272 volatile unsigned char serviceType;
273 volatile unsigned char serviceSubType;
274 volatile unsigned char destinationID;
275 volatile unsigned char time[6];
276 //
277 volatile unsigned char tc_failure_code[2];
278 volatile unsigned char telecommand_pkt_id[2];
279 volatile unsigned char pkt_seq_control[2];
280 volatile unsigned char tc_service;
281 volatile unsigned char tc_subtype;
282 volatile unsigned char byte_position;
283 volatile unsigned char rcv_value;
284 };
285 typedef struct Packet_TM_LFR_TC_EXE_INCONSISTENT_str Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
286
287 struct Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_str
288 {
289 volatile unsigned char targetLogicalAddress;
290 volatile unsigned char protocolIdentifier;
291 volatile unsigned char reserved;
292 volatile unsigned char userApplication;
293 // PACKET HEADER
294 volatile unsigned char packetID[2];
295 volatile unsigned char packetSequenceControl[2];
296 volatile unsigned char packetLength[2];
297 // DATA FIELD HEADER
298 volatile unsigned char spare1_pusVersion_spare2;
299 volatile unsigned char serviceType;
300 volatile unsigned char serviceSubType;
301 volatile unsigned char destinationID;
302 volatile unsigned char time[6];
303 //
304 volatile unsigned char tc_failure_code[2];
305 volatile unsigned char telecommand_pkt_id[2];
306 volatile unsigned char pkt_seq_control[2];
307 volatile unsigned char tc_service;
308 volatile unsigned char tc_subtype;
309 volatile unsigned char lfr_status_word[2];
310 };
311 typedef struct Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_str Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
312
313 struct Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_str
314 {
315 volatile unsigned char targetLogicalAddress;
316 volatile unsigned char protocolIdentifier;
317 volatile unsigned char reserved;
318 volatile unsigned char userApplication;
319 // PACKET HEADER
320 volatile unsigned char packetID[2];
321 volatile unsigned char packetSequenceControl[2];
322 volatile unsigned char packetLength[2];
323 // DATA FIELD HEADER
324 volatile unsigned char spare1_pusVersion_spare2;
325 volatile unsigned char serviceType;
326 volatile unsigned char serviceSubType;
327 volatile unsigned char destinationID;
328 volatile unsigned char time[6];
329 //
330 volatile unsigned char tc_failure_code[2];
331 volatile unsigned char telecommand_pkt_id[2];
332 volatile unsigned char pkt_seq_control[2];
333 volatile unsigned char tc_service;
334 volatile unsigned char tc_subtype;
335 };
336 typedef struct Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_str Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
337
338 struct Packet_TM_LFR_TC_EXE_ERROR_str
339 {
340 volatile unsigned char targetLogicalAddress;
341 volatile unsigned char protocolIdentifier;
342 volatile unsigned char reserved;
343 volatile unsigned char userApplication;
344 // PACKET HEADER
345 volatile unsigned char packetID[2];
346 volatile unsigned char packetSequenceControl[2];
347 volatile unsigned char packetLength[2];
348 // DATA FIELD HEADER
349 volatile unsigned char spare1_pusVersion_spare2;
350 volatile unsigned char serviceType;
351 volatile unsigned char serviceSubType;
352 volatile unsigned char destinationID;
353 volatile unsigned char time[6];
354 //
355 volatile unsigned char tc_failure_code[2];
356 volatile unsigned char telecommand_pkt_id[2];
357 volatile unsigned char pkt_seq_control[2];
358 volatile unsigned char tc_service;
359 volatile unsigned char tc_subtype;
360 };
361 typedef struct Packet_TM_LFR_TC_EXE_ERROR_str Packet_TM_LFR_TC_EXE_ERROR_t;
362
238 363 struct Packet_TM_LFR_TC_EXE_CORRUPTED_str
239 364 {
240 365 volatile unsigned char targetLogicalAddress;
@@ -11,6 +11,7
11 11
12 12 #include "fsw_params.h"
13 13 #include "fsw_misc.h"
14 #include "tm_byte_positions.h"
14 15 #include "fsw_processing.h"
15 16 #include "tc_handler.h"
16 17 #include "wf_handler.h"
@@ -1,7 +1,8
1 1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3 3
4 #include <fsw_params_processing.h>
4 #include "fsw_params_processing.h"
5 #include "ccsds_types.h"
5 6
6 7 #define GRSPW_DEVICE_NAME "/dev/grspw0"
7 8 #define UART_DEVICE_NAME "/dev/console"
@@ -137,7 +138,8
137 138
138 139 #define ACTION_MSG_QUEUE_COUNT 10
139 140 #define ACTION_MSG_PKTS_COUNT 50
140 #define ACTION_MSG_PKTS_SIZE 24 // hlen *hdr dlen *data sent options
141 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
142 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
141 143
142 144 #define QUEUE_QUEU 0
143 145 #define QUEUE_PKTS 1
@@ -36,9 +36,6 void updateLFRCurrentMode();
36 36 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_id);
37 37 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
38 38
39 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
40 TMHeader_t *TMHeader, unsigned char tc_sid);
41
42 39 //***********
43 40 // RTEMS TASK
44 41 rtems_task recv_task( rtems_task_argument unused );
@@ -76,7 +73,9 int suspend_science_tasks();
76 73 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
77 74 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
78 75 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
76 //
79 77 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
78 int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char byte_position, unsigned char rcv_value);
80 79 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
81 80 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
82 81 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
@@ -438,14 +438,15 rtems_status_code create_message_queues(
438 438 rtems_status_code ret;
439 439 rtems_id queue_id;
440 440
441 ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_SIZE,
442 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
441 ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT,
442 ACTION_MSG_PKTS_MAX_SIZE,
443 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
443 444 if (ret != RTEMS_SUCCESSFUL) {
444 445 BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret)
445 446 }
446 447
447 448 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
448 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
449 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
449 450 if (status != RTEMS_SUCCESSFUL) {
450 451 ret = status;
451 452 BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret)
@@ -222,7 +222,7 rtems_task hous_task(rtems_task_argument
222 222 update_spacewire_statistics();
223 223
224 224 // SEND PACKET
225 status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_PKTS_SIZE);
225 status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
226 226 if (status != RTEMS_SUCCESSFUL) {
227 227 PRINTF1("in HOUS *** ERR %d\n", status)
228 228 }
@@ -238,8 +238,9 rtems_task hous_task(rtems_task_argument
238 238
239 239 rtems_task send_task( rtems_task_argument argument)
240 240 {
241 rtems_status_code status; // RTEMS status code
242 spw_ioctl_pkt_send spw_ioctl_send; // incoming spw_ioctl_pkt_send structure
241 rtems_status_code status; // RTEMS status code
242 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
243 spw_ioctl_pkt_send *spw_ioctl_send;
243 244 size_t size; // size of the incoming TC packet
244 245 u_int32_t count;
245 246 rtems_id queue_id;
@@ -254,7 +255,7 rtems_task send_task( rtems_task_argumen
254 255
255 256 while(1)
256 257 {
257 status = rtems_message_queue_receive( queue_id, (char*) &spw_ioctl_send, &size,
258 status = rtems_message_queue_receive( queue_id, incomingData, &size,
258 259 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
259 260
260 261 if (status!=RTEMS_SUCCESSFUL)
@@ -263,19 +264,30 rtems_task send_task( rtems_task_argumen
263 264 }
264 265 else
265 266 {
266 if (spw_ioctl_send.hlen == 0)
267 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
267 268 {
268 status = write( fdSPW, spw_ioctl_send.data, spw_ioctl_send.dlen );
269 status = write( fdSPW, incomingData, size );
269 270 if (status == -1){
270 PRINTF2("in SEND *** (2.a) ERR = %d, dlen = %d\n", status, spw_ioctl_send.dlen)
271 PRINTF2("in SEND *** (2.a) ERR = %d, size = %d\n", status, size)
271 272 }
272 273 }
273 else
274 else // the incoming message is a spw_ioctl_pkt_send structure
274 275 {
275 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
276 if (status == -1){
277 PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send.dlen)
278 PRINTF1(" hlen = %d\n", spw_ioctl_send.hlen)
276 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
277 if (spw_ioctl_send->hlen == 0)
278 {
279 status = write( fdSPW, spw_ioctl_send->data, spw_ioctl_send->dlen );
280 if (status == -1){
281 PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen)
282 }
283 }
284 else
285 {
286 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
287 if (status == -1){
288 PRINTF2("in SEND *** (2.c) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen)
289 PRINTF1(" hlen = %d\n", spw_ioctl_send->hlen)
290 }
279 291 }
280 292 }
281 293 }
@@ -557,7 +557,7 void send_spectral_matrix(Header_TM_LFR_
557 557 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
558 558 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
559 559 // SEND PACKET
560 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_PKTS_SIZE);
560 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
561 561 if (status != RTEMS_SUCCESSFUL) {
562 562 printf("in send_spectral_matrix *** ERR %d\n", (int) status);
563 563 }
@@ -302,66 +302,6 unsigned char TC_parser(ccsdsTelecommand
302 302 return ret;
303 303 }
304 304
305 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
306 TMHeader_t *TMHeader, unsigned char tc_sid)
307 {
308 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
309 TMHeader->protocolIdentifier = CCSDS_PROTOCOLE_ID;
310 TMHeader->reserved = 0x00;
311 TMHeader->userApplication = 0x00;
312 TMHeader->packetID[0] = 0x0c;
313 TMHeader->packetSequenceControl[0] = 0xc0;
314 TMHeader->packetSequenceControl[1] = 0x00;
315 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
316 TMHeader->packetLength[1] = (unsigned char) packetLength;
317 TMHeader->spare1_pusVersion_spare2 = 0x10;
318 TMHeader->destinationID = TM_DESTINATION_ID_GROUND; // default destination id
319 switch (tm_type){
320 case(TM_LFR_TC_EXE_OK):
321 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
322 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
323 TMHeader->serviceSubType = TM_SUBTYPE_EXE_OK; // subtype
324 TMHeader->destinationID = tc_sid; // destination id
325 break;
326 case(TM_LFR_TC_EXE_ERR):
327 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
328 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
329 TMHeader->serviceSubType = TM_SUBTYPE_EXE_NOK; // subtype
330 TMHeader->destinationID = tc_sid;
331 break;
332 case(TM_LFR_HK):
333 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_HK;
334 TMHeader->serviceType = TM_TYPE_HK; // type
335 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
336 break;
337 case(TM_LFR_SCI):
338 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL_BURST;
339 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
340 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
341 break;
342 case(TM_LFR_SCI_SBM):
343 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_SBM1_SBM2;
344 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
345 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
346 break;
347 case(TM_LFR_PAR_DUMP):
348 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
349 TMHeader->serviceType = TM_TYPE_HK; // type
350 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
351 break;
352 default:
353 return 0;
354 }
355 TMHeader->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
356 TMHeader->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
357 TMHeader->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
358 TMHeader->time[3] = (unsigned char) (time_management_regs->coarse_time);
359 TMHeader->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
360 TMHeader->time[5] = (unsigned char) (time_management_regs->fine_time);
361
362 return LFR_SUCCESSFUL;
363 }
364
365 305 //***********
366 306 // RTEMS TASK
367 307 rtems_task recv_task( rtems_task_argument unused )
@@ -700,33 +640,43 int action_enter_mode(ccsdsTelecommandPa
700 640
701 641 requestedMode = TC->dataAndCRC[1];
702 642
703 printf("try to enter mode %d\n", requestedMode);
704
705 #ifdef PRINT_TASK_STATISTICS
706 if (requestedMode != LFR_MODE_STANDBY)
643 if ( (requestedMode != LFR_MODE_STANDBY)
644 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
645 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
707 646 {
708 rtems_cpu_usage_reset();
709 maxCount = 0;
710 }
711 #endif
712
713 status = transition_validation(requestedMode);
714
715 if ( status == LFR_SUCCESSFUL ) {
716 if ( lfrCurrentMode != LFR_MODE_STANDBY)
717 {
718 status = stop_current_mode();
719 }
720 if (status != RTEMS_SUCCESSFUL)
721 {
722 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
723 }
724 status = enter_mode(requestedMode, TC);
647 status = RTEMS_UNSATISFIED;
648 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
725 649 }
726 650 else
727 651 {
728 PRINTF("ERR *** in action_enter *** transition rejected\n")
729 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
652 printf("try to enter mode %d\n", requestedMode);
653
654 #ifdef PRINT_TASK_STATISTICS
655 if (requestedMode != LFR_MODE_STANDBY)
656 {
657 rtems_cpu_usage_reset();
658 maxCount = 0;
659 }
660 #endif
661
662 status = transition_validation(requestedMode);
663
664 if ( status == LFR_SUCCESSFUL ) {
665 if ( lfrCurrentMode != LFR_MODE_STANDBY)
666 {
667 status = stop_current_mode();
668 }
669 if (status != RTEMS_SUCCESSFUL)
670 {
671 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
672 }
673 status = enter_mode(requestedMode, TC);
674 }
675 else
676 {
677 PRINTF("ERR *** in action_enter *** transition rejected\n")
678 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
679 }
730 680 }
731 681
732 682 return status;
@@ -1180,74 +1130,156 int send_tm_lfr_tc_exe_success(ccsdsTele
1180 1130 {
1181 1131 int ret;
1182 1132 rtems_status_code status;
1183 TMHeader_t TM_header;
1184 char data[4];
1185 spw_ioctl_pkt_send spw_ioctl_send;
1133 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
1134 unsigned char messageSize;
1186 1135
1187 1136 ret = LFR_SUCCESSFUL;
1188 1137
1189 TM_build_header( TM_LFR_TC_EXE_OK, PACKET_LENGTH_TC_EXE_SUCCESS,
1190 &TM_header,
1191 TC->sourceID); // TC source ID
1138 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1139 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1140 TM.reserved = DEFAULT_RESERVED;
1141 TM.userApplication = CCSDS_USER_APP;
1142 // PACKET HEADER
1143 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1144 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1145 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1146 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1147 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
1148 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
1149 // DATA FIELD HEADER
1150 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1151 TM.serviceType = TM_TYPE_TC_EXE;
1152 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
1153 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1154 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1155 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1156 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1157 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1158 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1159 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1160 //
1161 TM.telecommand_pkt_id[0] = TC->packetID[0];
1162 TM.telecommand_pkt_id[1] = TC->packetID[1];
1163 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1164 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1192 1165
1193 data[0] = TC->packetID[0];
1194 data[1] = TC->packetID[1];
1195 data[2] = TC->packetSequenceControl[0];
1196 data[3] = TC->packetSequenceControl[1];
1197
1198 // filling the structure for the spacewire transmission
1199 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1200 spw_ioctl_send.hdr = (char*) &TM_header;
1201 spw_ioctl_send.dlen = 4;
1202 spw_ioctl_send.data = data;
1203 spw_ioctl_send.options = 0;
1166 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1204 1167
1205 1168 // SEND DATA
1206 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1169 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1207 1170 if (status != RTEMS_SUCCESSFUL) {
1208 1171 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1209 1172 ret = LFR_DEFAULT;
1210 1173 }
1211 1174
1212 return ret;
1175 return LFR_SUCCESSFUL;
1176 }
1177
1178 int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
1179 unsigned char byte_position, unsigned char rcv_value)
1180 {
1181 int ret;
1182 rtems_status_code status;
1183 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
1184 unsigned char messageSize;
1185
1186 ret = LFR_SUCCESSFUL;
1187
1188 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1189 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1190 TM.reserved = DEFAULT_RESERVED;
1191 TM.userApplication = CCSDS_USER_APP;
1192 // PACKET HEADER
1193 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1194 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1195 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1196 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1197 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
1198 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
1199 // DATA FIELD HEADER
1200 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1201 TM.serviceType = TM_TYPE_TC_EXE;
1202 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1203 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1204 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1205 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1206 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1207 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1208 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1209 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1210 //
1211 TM.tc_failure_code[0] = (char) (FAILURE_CODE_INCONSISTENT >> 8);
1212 TM.tc_failure_code[1] = (char) (FAILURE_CODE_INCONSISTENT );
1213 TM.telecommand_pkt_id[0] = TC->packetID[0];
1214 TM.telecommand_pkt_id[1] = TC->packetID[1];
1215 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1216 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1217 TM.tc_service = TC->serviceType; // type of the rejected TC
1218 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1219 TM.byte_position = byte_position;
1220 TM.rcv_value = rcv_value;
1221
1222 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1223
1224 // SEND DATA
1225 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1226 if (status != RTEMS_SUCCESSFUL) {
1227 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
1228 ret = LFR_DEFAULT;
1229 }
1230
1231 return LFR_SUCCESSFUL;
1213 1232 }
1214 1233
1215 1234 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1216 1235 {
1217 1236 int ret;
1218 1237 rtems_status_code status;
1219 TMHeader_t TM_header;
1220 char data[10];
1221 spw_ioctl_pkt_send spw_ioctl_send;
1238 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
1239 unsigned char messageSize;
1222 1240
1223 1241 ret = LFR_SUCCESSFUL;
1224 1242
1225 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE,
1226 &TM_header,
1227 TC->sourceID); // TC source ID
1243 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1244 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1245 TM.reserved = DEFAULT_RESERVED;
1246 TM.userApplication = CCSDS_USER_APP;
1247 // PACKET HEADER
1248 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1249 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1250 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1251 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1252 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
1253 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
1254 // DATA FIELD HEADER
1255 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1256 TM.serviceType = TM_TYPE_TC_EXE;
1257 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1258 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1259 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1260 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1261 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1262 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1263 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1264 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1265 //
1266 TM.tc_failure_code[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8);
1267 TM.tc_failure_code[1] = (char) (FAILURE_CODE_NOT_EXECUTABLE );
1268 TM.telecommand_pkt_id[0] = TC->packetID[0];
1269 TM.telecommand_pkt_id[1] = TC->packetID[1];
1270 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1271 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1272 TM.tc_service = TC->serviceType; // type of the rejected TC
1273 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1274 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
1275 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
1228 1276
1229 data[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8);
1230 data[1] = (char) FAILURE_CODE_NOT_EXECUTABLE;
1231 data[2] = TC->packetID[0];
1232 data[3] = TC->packetID[1];
1233 data[4] = TC->packetSequenceControl[0];
1234 data[5] = TC->packetSequenceControl[1];
1235 data[6] = TC->serviceType; // type of the rejected TC
1236 data[7] = TC->serviceSubType; // subtype of the rejected TC
1237 data[8] = housekeeping_packet.lfr_status_word[0];
1238 data[6] = housekeeping_packet.lfr_status_word[1];
1239
1240 // filling the structure for the spacewire transmission
1241 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1242 spw_ioctl_send.hdr = (char*) &TM_header;
1243 spw_ioctl_send.dlen = 10;
1244 spw_ioctl_send.data = data;
1245 spw_ioctl_send.options = 0;
1277 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1246 1278
1247 1279 // SEND DATA
1248 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1280 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1249 1281 if (status != RTEMS_SUCCESSFUL) {
1250 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1282 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
1251 1283 ret = LFR_DEFAULT;
1252 1284 }
1253 1285
@@ -1258,34 +1290,47 int send_tm_lfr_tc_exe_not_implemented(c
1258 1290 {
1259 1291 int ret;
1260 1292 rtems_status_code status;
1261 TMHeader_t TM_header;
1262 char data[8];
1263 spw_ioctl_pkt_send spw_ioctl_send;
1293 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
1294 unsigned char messageSize;
1264 1295
1265 1296 ret = LFR_SUCCESSFUL;
1266 1297
1267 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED,
1268 &TM_header,
1269 TC->sourceID); // TC source ID
1298 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1299 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1300 TM.reserved = DEFAULT_RESERVED;
1301 TM.userApplication = CCSDS_USER_APP;
1302 // PACKET HEADER
1303 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1304 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1305 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1306 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1307 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
1308 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
1309 // DATA FIELD HEADER
1310 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1311 TM.serviceType = TM_TYPE_TC_EXE;
1312 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1313 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1314 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1315 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1316 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1317 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1318 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1319 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1320 //
1321 TM.tc_failure_code[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
1322 TM.tc_failure_code[1] = (char) (FAILURE_CODE_NOT_IMPLEMENTED );
1323 TM.telecommand_pkt_id[0] = TC->packetID[0];
1324 TM.telecommand_pkt_id[1] = TC->packetID[1];
1325 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1326 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1327 TM.tc_service = TC->serviceType; // type of the rejected TC
1328 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1270 1329
1271 data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
1272 data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED;
1273 data[2] = TC->packetID[0];
1274 data[3] = TC->packetID[1];
1275 data[4] = TC->packetSequenceControl[0];
1276 data[5] = TC->packetSequenceControl[1];
1277 data[6] = TC->serviceType; // type of the rejected TC
1278 data[7] = TC->serviceSubType; // subtype of the rejected TC
1279
1280 // filling the structure for the spacewire transmission
1281 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1282 spw_ioctl_send.hdr = (char*) &TM_header;
1283 spw_ioctl_send.dlen = 8;
1284 spw_ioctl_send.data = data;
1285 spw_ioctl_send.options = 0;
1330 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1286 1331
1287 1332 // SEND DATA
1288 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1333 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1289 1334 if (status != RTEMS_SUCCESSFUL) {
1290 1335 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1291 1336 ret = LFR_DEFAULT;
@@ -1298,32 +1343,47 int send_tm_lfr_tc_exe_error(ccsdsTeleco
1298 1343 {
1299 1344 int ret;
1300 1345 rtems_status_code status;
1301 TMHeader_t TM_header;
1302 char data[8];
1303 spw_ioctl_pkt_send spw_ioctl_send;
1346 Packet_TM_LFR_TC_EXE_ERROR_t TM;
1347 unsigned char messageSize;
1304 1348
1305 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_ERROR,
1306 &TM_header,
1307 TC->sourceID); // TC source ID
1349 ret = LFR_SUCCESSFUL;
1308 1350
1309 data[0] = (char) (FAILURE_CODE_ERROR >> 8);
1310 data[1] = (char) FAILURE_CODE_ERROR;
1311 data[2] = TC->packetID[0];
1312 data[3] = TC->packetID[1];
1313 data[4] = TC->packetSequenceControl[0];
1314 data[5] = TC->packetSequenceControl[1];
1315 data[6] = TC->serviceType; // type of the rejected TC
1316 data[7] = TC->serviceSubType; // subtype of the rejected TC
1351 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1352 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1353 TM.reserved = DEFAULT_RESERVED;
1354 TM.userApplication = CCSDS_USER_APP;
1355 // PACKET HEADER
1356 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1357 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1358 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1359 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1360 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
1361 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
1362 // DATA FIELD HEADER
1363 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1364 TM.serviceType = TM_TYPE_TC_EXE;
1365 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1366 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1367 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1368 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1369 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1370 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1371 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1372 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1373 //
1374 TM.tc_failure_code[0] = (char) (FAILURE_CODE_ERROR >> 8);
1375 TM.tc_failure_code[1] = (char) (FAILURE_CODE_ERROR );
1376 TM.telecommand_pkt_id[0] = TC->packetID[0];
1377 TM.telecommand_pkt_id[1] = TC->packetID[1];
1378 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1379 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1380 TM.tc_service = TC->serviceType; // type of the rejected TC
1381 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1317 1382
1318 // filling the structure for the spacewire transmission
1319 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1320 spw_ioctl_send.hdr = (char*) &TM_header;
1321 spw_ioctl_send.dlen = 8;
1322 spw_ioctl_send.data = data;
1323 spw_ioctl_send.options = 0;
1383 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1324 1384
1325 1385 // SEND DATA
1326 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1386 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1327 1387 if (status != RTEMS_SUCCESSFUL) {
1328 1388 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1329 1389 ret = LFR_DEFAULT;
@@ -315,19 +315,21 rtems_task cwf2_task(rtems_task_argument
315 315 // wait for an RTEMS_EVENT
316 316 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
317 317 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
318
318 319 if (event_out == RTEMS_EVENT_MODE_BURST)
319 320 {
320 321 // F2
321 322 #ifdef GSA
322 323 #else
323 324 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
324 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
325 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
325 326 }
326 327 else {
327 328 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
328 329 }
329 330 #endif
330 331 }
332
331 333 else if (event_out == RTEMS_EVENT_MODE_SBM2)
332 334 {
333 335 #ifdef GSA
@@ -494,7 +496,7 int init_header_continuous_wf_table( uns
494 496 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
495 497 headerCWF[ i ].reserved = DEFAULT_RESERVED;
496 498 headerCWF[ i ].userApplication = CCSDS_USER_APP;
497 if (SID_SBM1_CWF_F1 || SID_SBM2_CWF_F2)
499 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
498 500 {
499 501 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
500 502 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
@@ -617,7 +619,7 int send_waveform_SWF( volatile int *wav
617 619 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
618 620 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
619 621 // SEND PACKET
620 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_PKTS_SIZE);
622 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
621 623 if (status != RTEMS_SUCCESSFUL) {
622 624 printf("%d-%d, ERR %d\n", sid, i, (int) status);
623 625 ret = LFR_DEFAULT;
General Comments 0
You need to be logged in to leave comments. Login now