tc_handler.c
1281 lines
| 42.5 KiB
| text/x-c
|
CLexer
/ src / tc_handler.c
paul@pc-solar1.lab-lpp.local
|
r5 | #include <tc_handler.h> | ||
#include <fsw_params.h> | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | char *DumbMessages[5] = {"in DUMB *** default", // RTEMS_EVENT_0 | ||
"in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 | ||||
"in DUMB *** waveforms_isr", // RTEMS_EVENT_2 | ||||
"in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 | ||||
"in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ" // RTEMS_EVENT_4 | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | }; | ||
unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field | ||||
unsigned char currentTC_COMPUTED_CRC[2]; | ||||
unsigned int currentTC_LEN_RCV_AsUnsignedInt; | ||||
unsigned int currentTM_length; | ||||
unsigned char currentTC_processedFlag; | ||||
unsigned int lookUpTableForCRC[256]; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
paul@pc-solar1.lab-lpp.local
|
r7 | //********************** | ||
// GENERAL USE FUNCTIONS | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) | ||
{ | ||||
return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | void initLookUpTableForCRC( void ) | ||
paul@pc-solar1.lab-lpp.local
|
r5 | { | ||
paul@pc-solar1.lab-lpp.local
|
r18 | unsigned int i; | ||
unsigned int tmp; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | for (i=0; i<256; i++) | ||
{ | ||||
tmp = 0; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | if((i & 1) != 0) { | ||
tmp = tmp ^ 0x1021; | ||||
} | ||||
if((i & 2) != 0) { | ||||
tmp = tmp ^ 0x2042; | ||||
} | ||||
if((i & 4) != 0) { | ||||
tmp = tmp ^ 0x4084; | ||||
} | ||||
if((i & 8) != 0) { | ||||
tmp = tmp ^ 0x8108; | ||||
} | ||||
if((i & 16) != 0) { | ||||
tmp = tmp ^ 0x1231; | ||||
} | ||||
if((i & 32) != 0) { | ||||
tmp = tmp ^ 0x2462; | ||||
} | ||||
if((i & 64) != 0) { | ||||
tmp = tmp ^ 0x48c4; | ||||
} | ||||
if((i & 128) != 0) { | ||||
tmp = tmp ^ 0x9188; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | lookUpTableForCRC[i] = tmp; | ||
} | ||||
} | ||||
void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) | ||||
{ | ||||
unsigned int Chk; | ||||
int j; | ||||
Chk = 0xffff; // reset the syndrom to all ones | ||||
for (j=0; j<sizeOfData; j++) { | ||||
Chk = Crc_opt(data[j], Chk); | ||||
} | ||||
crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); | ||||
crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r7 | //********************* | ||
// ACCEPTANCE FUNCTIONS | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv) | ||
paul@pc-solar1.lab-lpp.local
|
r5 | { | ||
paul@pc-solar1.lab-lpp.local
|
r18 | int ret = 0; | ||
paul@pc-solar1.lab-lpp.local
|
r9 | rtems_status_code status; | ||
spw_ioctl_pkt_send spw_ioctl_send; | ||||
TMHeader_t TM_header; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | unsigned int code = 0; | ||
unsigned char computed_CRC[2]; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | char data[ PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ]; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
paul@pc-solar1.lab-lpp.local
|
r9 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 ); | ||
paul@pc-solar1.lab-lpp.local
|
r23 | code = TC_parser( TC, tc_len_recv ) ; | ||
paul@pc-solar1.lab-lpp.local
|
r20 | if ( (code == ILLEGAL_APID) | (code == WRONG_LEN_PACKET) | (code == INCOR_CHECKSUM) | ||
| (code == ILL_TYPE) | (code == ILL_SUBTYPE) | (code == WRONG_APP_DATA) ) | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | { // generate TM_LFR_TC_EXE_CORRUPTED | ||
// BUILD HEADER | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_CORRUPTED, | ||
&TM_header, TC->sourceID); // TC source ID | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | // BUILD DATA | ||
TM_build_data( TC, data, SID_EXE_CORR, computed_CRC); | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | // PREPARE TM SENDING | ||
spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | ||||
spw_ioctl_send.hdr = (char*) &TM_header; | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | spw_ioctl_send.dlen = 16; | ||
paul@pc-solar1.lab-lpp.local
|
r9 | spw_ioctl_send.data = data; | ||
// SEND PACKET | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | ||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
admin@pc-p-leroy3.LAB-LPP.LOCAL
|
r10 | else { // send valid TC to the action launcher | ||
paul@pc-solar1.lab-lpp.local
|
r11 | status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3); | ||
paul@pc-solar1.lab-lpp.local
|
r18 | ret = -1; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
paul@pc-solar1.lab-lpp.local
|
r18 | return ret; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV) | ||
paul@pc-solar1.lab-lpp.local
|
r18 | { | ||
unsigned char ret = 0; | ||||
unsigned char pid = 0; | ||||
unsigned char category = 0; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | unsigned int length = 0; | ||
unsigned char packetType = 0; | ||||
unsigned char packetSubtype = 0; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | unsigned char * CCSDSContent = NULL; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
paul@pc-solar1.lab-lpp.local
|
r18 | // APID check *** APID on 2 bytes | ||
pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | ||||
category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | ||||
length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1]; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | packetType = TMPacket->serviceType; | ||
packetSubtype = TMPacket->serviceSubType; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | if ( pid != CCSDS_PROCESS_ID ) { | ||
paul@pc-solar1.lab-lpp.local
|
r18 | ret = ILLEGAL_APID; | ||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | else if ( category != CCSDS_PACKET_CATEGORY ) { | ||
paul@pc-solar1.lab-lpp.local
|
r18 | ret = ILLEGAL_APID; | ||
} | ||||
else if (length != TC_LEN_RCV ) { // packet length check | ||||
ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | else if ( length >= CCSDS_TC_PKT_MAX_SIZE ) { | ||
paul@pc-solar1.lab-lpp.local
|
r18 | ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size | ||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | else if ( packetType == TC_TYPE_GEN ){ // service type, subtype and packet length check | ||
paul@pc-solar1.lab-lpp.local
|
r18 | switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61 | ||
case TC_SUBTYPE_RESET: | ||||
if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_LOAD_COMM: | ||||
if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_LOAD_NORM: | ||||
if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_LOAD_BURST: | ||||
if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_LOAD_SBM1: | ||||
if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_LOAD_SBM2: | ||||
if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_DUMP: | ||||
if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_ENTER: | ||||
if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_UPDT_INFO: | ||||
if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_EN_CAL: | ||||
if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
case TC_SUBTYPE_DIS_CAL: | ||||
if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
break; | ||||
default: | ||||
ret = ILL_SUBTYPE; | ||||
break; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | else if ( packetType == TC_TYPE_TIME ){ | ||
paul@pc-solar1.lab-lpp.local
|
r18 | if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) { | ||
ret = ILL_SUBTYPE; | ||||
} | ||||
else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { | ||||
ret = WRONG_LEN_PACKET; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
} | ||||
else { | ||||
ret = ILL_TYPE; | ||||
} | ||||
// source ID check // Source ID not documented in the ICD | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | // packet error control, CRC check | ||
paul@pc-solar1.lab-lpp.local
|
r20 | if ( ret == CCSDS_TM_VALID ) { | ||
CCSDSContent = (unsigned char*) TMPacket->packetID; | ||||
GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | ||||
if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { | ||||
ret = INCOR_CHECKSUM; | ||||
} | ||||
else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { | ||||
ret = INCOR_CHECKSUM; | ||||
} | ||||
else { | ||||
ret = CCSDS_TM_VALID; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | } | ||
return ret; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
admin@pc-p-leroy3.LAB-LPP.LOCAL
|
r10 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength, | ||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader_t *TMHeader, unsigned char tc_sid) | ||
paul@pc-solar1.lab-lpp.local
|
r5 | { | ||
paul@pc-solar1.lab-lpp.local
|
r18 | TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID; | ||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->protocolIdentifier = CCSDS_PROTOCOLE_ID; | ||
paul@pc-solar1.lab-lpp.local
|
r18 | TMHeader->reserved = 0x00; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | TMHeader->userApplication = 0x00; | ||
TMHeader->packetID[0] = 0x0c; | ||||
TMHeader->packetSequenceControl[0] = 0xc0; | ||||
TMHeader->packetSequenceControl[1] = 0x00; | ||||
TMHeader->packetLength[0] = (unsigned char) (packetLength>>8); | ||||
TMHeader->packetLength[1] = (unsigned char) packetLength; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->spare1_pusVersion_spare2 = 0x10; | ||
TMHeader->destinationID = CCSDS_DESTINATION_ID; // default destination id | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | switch (tm_type){ | ||
case(TM_LFR_TC_EXE_OK): | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE; | ||
TMHeader->serviceType = TM_TYPE_TC_EXE; // type | ||||
TMHeader->serviceSubType = TM_SUBTYPE_EXE_OK; // subtype | ||||
TMHeader->destinationID = tc_sid; // destination id | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
case(TM_LFR_TC_EXE_ERR): | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE; | ||
TMHeader->serviceType = TM_TYPE_TC_EXE; // type | ||||
TMHeader->serviceSubType = TM_SUBTYPE_EXE_NOK; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
case(TM_LFR_HK): | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_HK; | ||
TMHeader->serviceType = TM_TYPE_HK; // type | ||||
TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
case(TM_LFR_SCI): | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL; | ||
TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type | ||||
TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
case(TM_LFR_SCI_SBM): | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2; | ||
TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type | ||||
TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
case(TM_LFR_PAR_DUMP): | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; | ||
TMHeader->serviceType = TM_TYPE_HK; // type | ||||
TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
default: | ||||
return 0; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TMHeader->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | ||
TMHeader->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | ||||
TMHeader->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | ||||
TMHeader->time[3] = (unsigned char) (time_management_regs->coarse_time); | ||||
TMHeader->time[4] = (unsigned char) (time_management_regs->fine_time>>8); | ||||
TMHeader->time[5] = (unsigned char) (time_management_regs->fine_time); | ||||
paul@pc-solar1.lab-lpp.local
|
r17 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | return LFR_SUCCESSFUL; | ||
paul@pc-solar1.lab-lpp.local
|
r17 | } | ||
paul@pc-solar1.lab-lpp.local
|
r5 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC) | ||
{ | ||||
unsigned int packetLength; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | switch (SID){ | ||
case (SID_NOT_EXE): | ||||
break; | ||||
case (SID_NOT_IMP): | ||||
paul
|
r29 | data[0] = (unsigned char) (SID_NOT_IMP >> 8); | ||
data[1] = (unsigned char) SID_NOT_IMP; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | data[2] = TC->packetID[0]; | ||
data[3] = TC->packetID[1]; | ||||
data[4] = TC->packetSequenceControl[0]; | ||||
data[5] = TC->packetSequenceControl[1]; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | data[6] = TC->serviceType; // type | ||
data[7] = TC->serviceSubType; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | break; | ||
case (SID_EXE_ERR): | ||||
break; | ||||
case (SID_EXE_CORR): | ||||
paul
|
r29 | data[0] = (unsigned char) (SID_EXE_CORR >> 8); | ||
data[1] = (unsigned char) SID_EXE_CORR; | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | data[2] = TC->packetID[0]; | ||
data[3] = TC->packetID[1]; | ||||
data[4] = TC->packetSequenceControl[0]; | ||||
data[5] = TC->packetSequenceControl[1]; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | data[6] = TC->serviceType; // type | ||
data[7] = TC->serviceSubType; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | data[8] = currentTC_LEN_RCV[0]; | ||
data[9] = currentTC_LEN_RCV[1]; | ||||
data[10] = TC->packetLength[0]; | ||||
data[11] = TC->packetLength[1]; | ||||
data[12] = TC->dataAndCRC[packetLength]; | ||||
data[13] = TC->dataAndCRC[packetLength+1]; | ||||
data[14] = computed_CRC[0]; | ||||
data[15] = computed_CRC[1]; | ||||
break; | ||||
default: | ||||
return 0; | ||||
} | ||||
return 1; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | int create_message_queue( void ) | ||
paul@pc-solar1.lab-lpp.local
|
r17 | { | ||
rtems_status_code status; | ||||
misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' ); | ||||
status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, | ||||
RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] ); | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | if (status!=RTEMS_SUCCESSFUL) { | ||
PRINTF("in create_message_queue *** error creating message queue\n") | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r17 | |||
return 0; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r7 | //*********** | ||
// RTEMS TASK | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | rtems_task recv_task( rtems_task_argument unused ) | ||
paul@pc-solar1.lab-lpp.local
|
r18 | { | ||
paul@pc-solar1.lab-lpp.local
|
r5 | int len = 0; | ||
unsigned int i = 0; | ||||
unsigned int data_length = 0; | ||||
ccsdsTelecommandPacket_t currentTC; | ||||
char data[100]; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | for(i=0; i<100; i++) data[i] = 0; | ||
paul@pc-solar1.lab-lpp.local
|
r17 | PRINTF("in RECV *** \n") | ||
paul@pc-solar1.lab-lpp.local
|
r18 | |||
paul@pc-solar1.lab-lpp.local
|
r9 | while(1) | ||
paul@pc-solar1.lab-lpp.local
|
r18 | { | ||
len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking | ||||
if (len == -1){ // error during the read call | ||||
PRINTF("In RECV *** last read call returned -1\n") | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | //if (rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) { | ||
// PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n") | ||||
//} | ||||
//if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) { | ||||
// PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n") | ||||
//} | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
paul@pc-solar1.lab-lpp.local
|
r18 | else { | ||
paul@pc-solar1.lab-lpp.local
|
r13 | PRINTF1("Got pck of length %d\n", len+1) | ||
paul@pc-solar1.lab-lpp.local
|
r20 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | ||
PRINTF("In RECV *** packet lenght too short\n") | ||||
} | ||||
else { | ||||
currentTC_LEN_RCV[0] = 0x00; | ||||
currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field | ||||
currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | ||||
// CHECK THE TC AND BUILD THE APPROPRIATE TM | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | data_length = TC_acceptance(¤tTC, currentTC_LEN_RCV_AsUnsignedInt); | ||
paul@pc-solar1.lab-lpp.local
|
r20 | if (data_length!=-1) | ||
{ | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | } | ||
} | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | } | ||
paul@pc-solar1.lab-lpp.local
|
r9 | rtems_task actn_task( rtems_task_argument unused ) | ||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | int result; | ||
rtems_status_code status; // RTEMS status code | ||||
ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | ||||
size_t size; // size of the incoming TC packet | ||||
unsigned char subtype; // subtype of the current TC packet | ||||
result = LFR_SUCCESSFUL; | ||||
subtype = 0; // subtype of the current TC packet | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
paul@pc-solar1.lab-lpp.local
|
r17 | PRINTF("in ACTN *** \n") | ||
paul@pc-solar1.lab-lpp.local
|
r11 | |||
paul@pc-solar1.lab-lpp.local
|
r9 | while(1) | ||
{ | ||||
status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size, | ||||
RTEMS_WAIT, RTEMS_NO_TIMEOUT); | ||||
paul@pc-solar1.lab-lpp.local
|
r22 | if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | ||
paul@pc-solar1.lab-lpp.local
|
r9 | else | ||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | subtype = TC.serviceSubType; | ||
paul@pc-solar1.lab-lpp.local
|
r9 | switch(subtype) | ||
{ | ||||
case TC_SUBTYPE_RESET: | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_default( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
case TC_SUBTYPE_LOAD_COMM: | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | result = action_load_comm( &TC ); | ||
close_action( &TC, result ); | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | break; | ||
// | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_LOAD_NORM: | ||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_load_norm( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r21 | close_action( &TC, result ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_LOAD_BURST: | ||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_default( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r21 | close_action( &TC, result ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_LOAD_SBM1: | ||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_default( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r21 | close_action( &TC, result ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_LOAD_SBM2: | ||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_default( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r21 | close_action( &TC, result ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_DUMP: | ||
paul@pc-solar1.lab-lpp.local
|
r28 | result = action_dump( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r21 | close_action( &TC, result ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_ENTER: | ||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_enter( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r21 | close_action( &TC, result ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_UPDT_INFO: | ||
paul@pc-solar1.lab-lpp.local
|
r23 | result = action_updt_info( &TC ); | ||
close_action( &TC, result ); | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_EN_CAL: | ||
paul@pc-solar1.lab-lpp.local
|
r23 | result = action_enable_calibration( &TC ); | ||
close_action( &TC, result ); | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_DIS_CAL: | ||
paul@pc-solar1.lab-lpp.local
|
r23 | result = action_disable_calibration( &TC ); | ||
close_action( &TC, result ); | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | case TC_SUBTYPE_UPDT_TIME: | ||
paul@pc-solar1.lab-lpp.local
|
r11 | result = action_updt_time( &TC ); | ||
paul@pc-solar1.lab-lpp.local
|
r9 | break; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | // | ||
paul@pc-solar1.lab-lpp.local
|
r9 | default: | ||
break; | ||||
} | ||||
} | ||||
} | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r17 | rtems_task dumb_task( rtems_task_argument unused ) | ||
paul@pc-solar1.lab-lpp.local
|
r9 | { | ||
paul@pc-solar1.lab-lpp.local
|
r23 | unsigned int i; | ||
unsigned int intEventOut; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | unsigned int coarse_time = 0; | ||
unsigned int fine_time = 0; | ||||
paul@pc-solar1.lab-lpp.local
|
r17 | rtems_event_set event_out; | ||
PRINTF("in DUMB *** \n") | ||||
paul@pc-solar1.lab-lpp.local
|
r9 | |||
paul@pc-solar1.lab-lpp.local
|
r17 | while(1){ | ||
paul@pc-solar1.lab-lpp.local
|
r21 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4, | ||
RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | intEventOut = (unsigned int) event_out; | ||
PRINTF1("in DUMB *** event_out %x\n", (int) event_out) | ||||
for ( i=0; i<32; i++) | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | { | ||
paul@pc-solar1.lab-lpp.local
|
r23 | if ( ((intEventOut >> i) & 0x0001) != 0) | ||
{ | ||||
coarse_time = time_management_regs->coarse_time; | ||||
fine_time = time_management_regs->fine_time; | ||||
printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | } | ||
paul@pc-solar1.lab-lpp.local
|
r17 | } | ||
paul@pc-solar1.lab-lpp.local
|
r9 | } | ||
//*********** | ||||
// TC ACTIONS | ||||
paul@pc-solar1.lab-lpp.local
|
r15 | |||
admin@pc-p-leroy3.LAB-LPP.LOCAL
|
r10 | int action_default(ccsdsTelecommandPacket_t *TC) | ||
paul@pc-solar1.lab-lpp.local
|
r9 | { | ||
paul@pc-solar1.lab-lpp.local
|
r23 | rtems_status_code status; | ||
TMHeader_t header; | ||||
spw_ioctl_pkt_send spw_ioctl_send; | ||||
unsigned char data[10]; | ||||
paul@pc-solar1.lab-lpp.local
|
r15 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED, | ||
&header, TC->sourceID); | ||||
paul@pc-solar1.lab-lpp.local
|
r15 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4; | ||
spw_ioctl_send.hdr = (char *) &header; | ||||
spw_ioctl_send.dlen = 8; | ||||
spw_ioctl_send.data = (char *) data; | ||||
spw_ioctl_send.options = 0; | ||||
data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8); | ||||
data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED; | ||||
data[2] = TC->packetID[0]; | ||||
data[3] = TC->packetID[1]; | ||||
data[4] = TC->packetSequenceControl[0]; | ||||
data[5] = TC->packetSequenceControl[1]; | ||||
data[6] = TC->serviceType; // type | ||||
data[7] = TC->serviceSubType; // subtype | ||||
paul@pc-solar1.lab-lpp.local
|
r15 | |||
paul@pc-solar1.lab-lpp.local
|
r9 | // SEND DATA | ||
paul@pc-solar1.lab-lpp.local
|
r23 | status = write_spw(&spw_ioctl_send); | ||
if (status != RTEMS_SUCCESSFUL) | ||||
{ | ||||
PRINTF("ERR *** in action_default *** send TM packet\n") | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | } | ||
paul@pc-solar1.lab-lpp.local
|
r9 | |||
paul@pc-solar1.lab-lpp.local
|
r21 | return LFR_DEFAULT; | ||
paul@pc-solar1.lab-lpp.local
|
r9 | } | ||
admin@pc-p-leroy3.LAB-LPP.LOCAL
|
r10 | int action_enter(ccsdsTelecommandPacket_t *TC) | ||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | rtems_status_code status; | ||
unsigned char requestedMode; | ||||
requestedMode = TC->dataAndCRC[1]; | ||||
printf("try to enter mode %d\n", requestedMode); | ||||
status = transition_validation(requestedMode); | ||||
if ( status == LFR_SUCCESSFUL ) { | ||||
if ( (housekeeping_packet.lfr_status_word[0] & 0xf0) != LFR_MODE_STANDBY) | ||||
{ | ||||
status = stop_current_mode(); | ||||
} | ||||
if (status != RTEMS_SUCCESSFUL) | ||||
{ | ||||
PRINTF("ERR *** in action_enter *** stop_current_mode\n") | ||||
} | ||||
status = enter_mode(requestedMode, TC); | ||||
} | ||||
else | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | { | ||
paul@pc-solar1.lab-lpp.local
|
r23 | PRINTF("ERR *** in action_enter *** transition rejected\n") | ||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
} | ||||
return status; | ||||
} | ||||
int action_load_comm(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r28 | parameter_dump_packet.unused0 = TC->dataAndCRC[0]; | ||
parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1]; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
paul@pc-solar1.lab-lpp.local
|
r28 | set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1); | ||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
return LFR_SUCCESSFUL; | ||||
} | ||||
int action_load_norm(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
int result; | ||||
unsigned char lfrMode; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
if ( lfrMode == LFR_MODE_NORMAL ) { | ||||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
paul@pc-solar1.lab-lpp.local
|
r28 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[0]; | ||
parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[1]; | ||||
parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[2]; | ||||
parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[3]; | ||||
parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[4]; | ||||
parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[5]; | ||||
parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[6]; | ||||
parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[7]; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | result = LFR_SUCCESSFUL; | ||
} | ||||
return result; | ||||
} | ||||
int action_load_burst(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
int result; | ||||
unsigned char lfrMode; | ||||
result = LFR_DEFAULT; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
paul@pc-solar1.lab-lpp.local
|
r19 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | if ( lfrMode == LFR_MODE_BURST ) { | ||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
send_tm_lfr_tc_exe_not_implemented( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
return result; | ||||
} | ||||
int action_load_sbm1(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
int result; | ||||
unsigned char lfrMode; | ||||
result = LFR_DEFAULT; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
if ( (lfrMode == LFR_MODE_SBM1) | (lfrMode == LFR_MODE_SBM2) ) { | ||||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
send_tm_lfr_tc_exe_not_implemented( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
return result; | ||||
} | ||||
int action_load_sbm2(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
int result; | ||||
unsigned char lfrMode; | ||||
result = LFR_DEFAULT; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
if ( (lfrMode == LFR_MODE_SBM1) | (lfrMode == LFR_MODE_SBM2) ) { | ||||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
send_tm_lfr_tc_exe_not_implemented( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
return result; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r28 | int action_dump(ccsdsTelecommandPacket_t *TC) | ||
{ | ||||
int status; | ||||
// send parameter dump packet | ||||
status = write(fdSPW, (char *) ¶meter_dump_packet, | ||||
PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + 4); | ||||
if (status == -1) | ||||
{ | ||||
PRINTF1("in action_dump *** ERR sending packet, code %d", status) | ||||
status = RTEMS_UNSATISFIED; | ||||
} | ||||
else | ||||
{ | ||||
status = RTEMS_SUCCESSFUL; | ||||
} | ||||
return status; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | int action_updt_info(ccsdsTelecommandPacket_t *TC) { | ||
unsigned int val; | ||||
int result; | ||||
unsigned char lfrMode; | ||||
result = LFR_DEFAULT; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | if ( (lfrMode == LFR_MODE_STANDBY) ) { | ||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | ||||
+ housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | ||||
val++; | ||||
housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | ||||
housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | ||||
result = LFR_SUCCESSFUL; | ||||
} | ||||
return result; | ||||
} | ||||
int action_enable_calibration(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
int result; | ||||
unsigned char lfrMode; | ||||
result = LFR_DEFAULT; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { | ||||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
send_tm_lfr_tc_exe_not_implemented( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
return result; | ||||
} | ||||
int action_disable_calibration(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
int result; | ||||
unsigned char lfrMode; | ||||
result = LFR_DEFAULT; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { | ||||
send_tm_lfr_tc_exe_not_executable( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
send_tm_lfr_tc_exe_not_implemented( TC ); | ||||
result = LFR_DEFAULT; | ||||
} | ||||
return result; | ||||
} | ||||
int action_updt_time(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
unsigned int val; | ||||
paul@pc-solar1.lab-lpp.local
|
r19 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | ||
+ (TC->dataAndCRC[1] << 16) | ||||
+ (TC->dataAndCRC[2] << 8) | ||||
+ TC->dataAndCRC[3]; | ||||
val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | ||||
+ housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | ||||
val++; | ||||
housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | ||||
housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | ||||
//time_management_regs->ctrl = time_management_regs->ctrl | 1; | ||||
return LFR_SUCCESSFUL; | ||||
} | ||||
//******************* | ||||
// ENTERING THE MODES | ||||
int transition_validation(unsigned char requestedMode) | ||||
{ | ||||
int status; | ||||
unsigned char lfrMode; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
paul@pc-solar1.lab-lpp.local
|
r19 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | switch (requestedMode) | ||
{ | ||||
case LFR_MODE_STANDBY: | ||||
if ( (lfrMode == LFR_MODE_STANDBY) ) { | ||||
status = LFR_DEFAULT; | ||||
} | ||||
else | ||||
{ | ||||
status = LFR_SUCCESSFUL; | ||||
} | ||||
break; | ||||
case LFR_MODE_NORMAL: | ||||
if ( (lfrMode == LFR_MODE_NORMAL) ) { | ||||
status = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
status = LFR_SUCCESSFUL; | ||||
} | ||||
break; | ||||
case LFR_MODE_BURST: | ||||
if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | ||||
| (lfrMode == LFR_MODE_SBM2) ) { | ||||
status = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
status = LFR_SUCCESSFUL; | ||||
} | ||||
break; | ||||
case LFR_MODE_SBM1: | ||||
if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_SBM1) ) { | ||||
status = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
status = LFR_SUCCESSFUL; | ||||
} | ||||
break; | ||||
case LFR_MODE_SBM2: | ||||
if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_NORMAL) | ||||
| (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { | ||||
status = LFR_DEFAULT; | ||||
} | ||||
else { | ||||
status = LFR_SUCCESSFUL; | ||||
} | ||||
break; | ||||
default: | ||||
status = LFR_DEFAULT; | ||||
break; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r19 | |||
paul@pc-solar1.lab-lpp.local
|
r21 | return status; | ||
admin@pc-p-leroy3.LAB-LPP.LOCAL
|
r10 | } | ||
paul@pc-solar1.lab-lpp.local
|
r20 | int stop_current_mode() | ||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | rtems_status_code status; | ||
paul@pc-solar1.lab-lpp.local
|
r23 | unsigned char lfrMode; | ||
status = RTEMS_SUCCESSFUL; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode | ||||
paul@pc-solar1.lab-lpp.local
|
r22 | |||
paul@pc-solar1.lab-lpp.local
|
r20 | // mask all IRQ lines related to signal processing | ||
LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP) | ||||
LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP) | ||||
LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | ||||
// clear all pending interruptions related to signal processing | ||||
LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP) | ||||
LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP) | ||||
LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | ||||
// suspend several tasks | ||||
paul@pc-solar1.lab-lpp.local
|
r22 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | if (lfrMode != LFR_MODE_STANDBY) { | ||
status = rtems_task_suspend( Task_id[TASKID_AVF0] ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_suspend( Task_id[TASKID_BPF0] ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | ||||
} | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | } | ||
paul@pc-solar1.lab-lpp.local
|
r20 | |||
paul@pc-solar1.lab-lpp.local
|
r22 | if (status != RTEMS_SUCCESSFUL) | ||
{ | ||||
PRINTF("ERR *** in stop_current_mode *** suspending tasks\n") | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r20 | // initialize the registers | ||
waveform_picker_regs->burst_enable = 0x00; // initialize | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | return status; | ||
paul@pc-solar1.lab-lpp.local
|
r20 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC ) | ||
paul@pc-solar1.lab-lpp.local
|
r20 | { | ||
paul@pc-solar1.lab-lpp.local
|
r21 | rtems_status_code status; | ||
paul@pc-solar1.lab-lpp.local
|
r20 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | switch(mode){ | ||
case LFR_MODE_STANDBY: | ||||
status = enter_standby_mode( TC ); | ||||
break; | ||||
case LFR_MODE_NORMAL: | ||||
status = enter_normal_mode( TC ); | ||||
break; | ||||
case LFR_MODE_BURST: | ||||
status = enter_burst_mode( TC ); | ||||
break; | ||||
case LFR_MODE_SBM1: | ||||
status = enter_sbm1_mode( TC ); | ||||
break; | ||||
case LFR_MODE_SBM2: | ||||
status = enter_sbm2_mode( TC ); | ||||
break; | ||||
default: | ||||
status = RTEMS_UNSATISFIED; | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | } | ||
paul@pc-solar1.lab-lpp.local
|
r20 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | if (status == RTEMS_SUCCESSFUL) | ||
{ | ||||
housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | |||
return status; | ||||
paul@pc-solar1.lab-lpp.local
|
r20 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | int enter_standby_mode(ccsdsTelecommandPacket_t *TC) | ||
paul@pc-solar1.lab-lpp.local
|
r20 | { | ||
paul@pc-solar1.lab-lpp.local
|
r23 | return LFR_SUCCESSFUL; | ||
paul@pc-solar1.lab-lpp.local
|
r22 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | int enter_normal_mode( ccsdsTelecommandPacket_t *TC ) | ||
paul@pc-solar1.lab-lpp.local
|
r22 | { | ||
rtems_status_code status; | ||||
status = rtems_task_restart( Task_id[TASKID_AVF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_BPF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_WFRM], 0 ); | ||||
} | ||||
} | ||||
#ifdef GSA | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | LEON_Unmask_interrupt( IRQ_WF ); | ||
paul@pc-solar1.lab-lpp.local
|
r22 | #else | ||
paul@pc-solar1.lab-lpp.local
|
r23 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | ||
LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
waveform_picker_regs->burst_enable = 0x07; | ||||
waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1; | ||||
waveform_picker_regs->status = 0x00; | ||||
#endif | ||||
LEON_Unmask_interrupt( IRQ_SM ); | ||||
return status; | ||||
} | ||||
int enter_burst_mode(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
rtems_status_code status; | ||||
unsigned char lfrMode; | ||||
lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | ||||
status = rtems_task_restart( Task_id[TASKID_AVF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_BPF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_WFRM], 0 ); | ||||
} | ||||
} | ||||
#ifdef GSA | ||||
#else | ||||
LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
waveform_picker_regs->addr_data_f2 = (int) wf_snap_f2; | ||||
waveform_picker_regs->burst_enable = 0x40; // [0100 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | ||||
waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; | ||||
waveform_picker_regs->status = 0x00; | ||||
paul@pc-solar1.lab-lpp.local
|
r20 | #endif | ||
paul@pc-solar1.lab-lpp.local
|
r22 | |||
LEON_Unmask_interrupt( IRQ_SM ); | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
paul@pc-solar1.lab-lpp.local
|
r22 | return status; | ||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | int enter_sbm1_mode(ccsdsTelecommandPacket_t *TC) | ||
paul@pc-solar1.lab-lpp.local
|
r22 | { | ||
rtems_status_code status; | ||||
status = rtems_task_restart( Task_id[TASKID_AVF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_BPF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_WFRM], 0 ); | ||||
} | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | // at the beginning of the mode, the parameter local_sbm1_nb_cwf_max has a specific value | ||
paul@pc-solar1.lab-lpp.local
|
r28 | param_local.local_sbm1_nb_cwf_max = 2 * ( | ||
(parameter_dump_packet.sy_lfr_n_swf_p[0] * 256) | ||||
+ parameter_dump_packet.sy_lfr_n_swf_p[1] | ||||
)/ 4; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
#ifdef GSA | ||||
#else | ||||
LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1; | ||||
waveform_picker_regs->burst_enable = 0x20; // [0010 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | ||||
waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f3 f2 f1 f0 | ||||
waveform_picker_regs->status = 0x00; | ||||
#endif | ||||
LEON_Unmask_interrupt( IRQ_SM ); | ||||
return status; | ||||
} | ||||
int enter_sbm2_mode(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
rtems_status_code status; | ||||
status = rtems_task_restart( Task_id[TASKID_AVF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_BPF0], 0 ); | ||||
if (status == RTEMS_SUCCESSFUL) { | ||||
status = rtems_task_restart( Task_id[TASKID_WFRM], 0 ); | ||||
} | ||||
} | ||||
// at the beginning of the mode, the parameter local_sbm2_nb_cwf_max has a specific value | ||||
paul@pc-solar1.lab-lpp.local
|
r28 | param_local.local_sbm1_nb_cwf_max = ( | ||
(parameter_dump_packet.sy_lfr_n_swf_p[0] * 256) | ||||
+ parameter_dump_packet.sy_lfr_n_swf_p[1] | ||||
) / 16; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
paul@pc-solar1.lab-lpp.local
|
r22 | #ifdef GSA | ||
#else | ||||
LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | ||||
waveform_picker_regs->addr_data_f2 = (int) wf_snap_f2; | ||||
waveform_picker_regs->burst_enable = 0x40; // [0100 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | ||||
waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; | ||||
waveform_picker_regs->status = 0x00; | ||||
#endif | ||||
LEON_Unmask_interrupt( IRQ_SM ); | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
paul@pc-solar1.lab-lpp.local
|
r21 | return status; | ||
paul@pc-solar1.lab-lpp.local
|
r20 | } | ||
paul@pc-solar1.lab-lpp.local
|
r23 | //**************** | ||
// CLOSING ACTIONS | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | |||
int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | rtems_status_code status; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | TMHeader_t TM_header; | ||
char data[4]; | ||||
spw_ioctl_pkt_send spw_ioctl_send; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | TM_build_header( TM_LFR_TC_EXE_OK, PACKET_LENGTH_TC_EXE_SUCCESS, | ||
&TM_header, | ||||
TC->sourceID); // TC source ID | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | |||
data[0] = TC->packetID[0]; | ||||
data[1] = TC->packetID[1]; | ||||
data[2] = TC->packetSequenceControl[0]; | ||||
data[3] = TC->packetSequenceControl[1]; | ||||
// filling the structure for the spacewire transmission | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | ||
paul@pc-solar1.lab-lpp.local
|
r11 | spw_ioctl_send.hdr = (char*) &TM_header; | ||
paul@pc-solar1.lab-lpp.local
|
r23 | spw_ioctl_send.dlen = 4; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | spw_ioctl_send.data = data; | ||
paul@pc-solar1.lab-lpp.local
|
r23 | spw_ioctl_send.options = 0; | ||
paul@pc-solar1.lab-lpp.local
|
r11 | |||
// SEND DATA | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | ||
return LFR_SUCCESSFUL; | ||||
} | ||||
int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
rtems_status_code status; | ||||
TMHeader_t TM_header; | ||||
char data[10]; | ||||
spw_ioctl_pkt_send spw_ioctl_send; | ||||
TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE, | ||||
&TM_header, | ||||
TC->sourceID); // TC source ID | ||||
data[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8); | ||||
data[1] = (char) FAILURE_CODE_NOT_EXECUTABLE; | ||||
data[2] = TC->packetID[0]; | ||||
data[3] = TC->packetID[1]; | ||||
data[4] = TC->packetSequenceControl[0]; | ||||
data[5] = TC->packetSequenceControl[1]; | ||||
data[6] = TC->serviceType; // type of the rejected TC | ||||
data[7] = TC->serviceSubType; // subtype of the rejected TC | ||||
data[8] = housekeeping_packet.lfr_status_word[0]; | ||||
data[6] = housekeeping_packet.lfr_status_word[1]; | ||||
// filling the structure for the spacewire transmission | ||||
spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | ||||
spw_ioctl_send.hdr = (char*) &TM_header; | ||||
spw_ioctl_send.dlen = 10; | ||||
spw_ioctl_send.data = data; | ||||
spw_ioctl_send.options = 0; | ||||
paul@pc-solar1.lab-lpp.local
|
r11 | |||
paul@pc-solar1.lab-lpp.local
|
r23 | // SEND DATA | ||
status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | ||||
return LFR_SUCCESSFUL; | ||||
} | ||||
int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
rtems_status_code status; | ||||
TMHeader_t TM_header; | ||||
char data[8]; | ||||
spw_ioctl_pkt_send spw_ioctl_send; | ||||
TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED, | ||||
&TM_header, | ||||
TC->sourceID); // TC source ID | ||||
data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8); | ||||
data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED; | ||||
data[2] = TC->packetID[0]; | ||||
data[3] = TC->packetID[1]; | ||||
data[4] = TC->packetSequenceControl[0]; | ||||
data[5] = TC->packetSequenceControl[1]; | ||||
data[6] = TC->serviceType; // type of the rejected TC | ||||
data[7] = TC->serviceSubType; // subtype of the rejected TC | ||||
// filling the structure for the spacewire transmission | ||||
spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | ||||
spw_ioctl_send.hdr = (char*) &TM_header; | ||||
spw_ioctl_send.dlen = 8; | ||||
spw_ioctl_send.data = data; | ||||
spw_ioctl_send.options = 0; | ||||
// SEND DATA | ||||
status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | ||||
return LFR_SUCCESSFUL; | ||||
admin@pc-p-leroy3.LAB-LPP.LOCAL
|
r10 | } | ||
paul@pc-solar1.lab-lpp.local
|
r9 | |||
paul@pc-solar1.lab-lpp.local
|
r28 | int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC) | ||
{ | ||||
rtems_status_code status; | ||||
TMHeader_t TM_header; | ||||
char data[8]; | ||||
spw_ioctl_pkt_send spw_ioctl_send; | ||||
TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_ERROR, | ||||
&TM_header, | ||||
TC->sourceID); // TC source ID | ||||
data[0] = (char) (FAILURE_CODE_ERROR >> 8); | ||||
data[1] = (char) FAILURE_CODE_ERROR; | ||||
data[2] = TC->packetID[0]; | ||||
data[3] = TC->packetID[1]; | ||||
data[4] = TC->packetSequenceControl[0]; | ||||
data[5] = TC->packetSequenceControl[1]; | ||||
data[6] = TC->serviceType; // type of the rejected TC | ||||
data[7] = TC->serviceSubType; // subtype of the rejected TC | ||||
// filling the structure for the spacewire transmission | ||||
spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | ||||
spw_ioctl_send.hdr = (char*) &TM_header; | ||||
spw_ioctl_send.dlen = 8; | ||||
spw_ioctl_send.data = data; | ||||
spw_ioctl_send.options = 0; | ||||
// SEND DATA | ||||
status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | ||||
return LFR_SUCCESSFUL; | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r21 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) | ||
{ | ||||
housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | ||||
housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | ||||
housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | ||
paul@pc-solar1.lab-lpp.local
|
r21 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | ||
paul@pc-solar1.lab-lpp.local
|
r23 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | ||
paul@pc-solar1.lab-lpp.local
|
r21 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | ||
housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | ||||
housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | ||||
housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); | ||||
housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); | ||||
housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time); | ||||
} | ||||
void update_last_TC_rej(ccsdsTelecommandPacket_t *TC) | ||||
{ | ||||
housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | ||||
housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | ||||
housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | ||||
paul@pc-solar1.lab-lpp.local
|
r23 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | ||
paul@pc-solar1.lab-lpp.local
|
r21 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | ||
paul@pc-solar1.lab-lpp.local
|
r23 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | ||
paul@pc-solar1.lab-lpp.local
|
r21 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | ||
housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | ||||
housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | ||||
housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); | ||||
housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); | ||||
housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time); | ||||
} | ||||
void close_action(ccsdsTelecommandPacket_t *TC, int result) | ||||
{ | ||||
unsigned int val = 0; | ||||
if (result == LFR_SUCCESSFUL) | ||||
{ | ||||
send_tm_lfr_tc_exe_success( TC ); | ||||
update_last_TC_exe( TC ); | ||||
val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1]; | ||||
val++; | ||||
housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8); | ||||
housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val); | ||||
} | ||||
else | ||||
{ | ||||
update_last_TC_rej( TC ); | ||||
val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1]; | ||||
val++; | ||||
housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8); | ||||
housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val); | ||||
} | ||||
} | ||||
paul@pc-solar1.lab-lpp.local
|
r12 | //*************************** | ||
// Interrupt Service Routines | ||||
rtems_isr commutation_isr1( rtems_vector_number vector ) | ||||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | ||
paul@pc-solar1.lab-lpp.local
|
r15 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | ||
paul@pc-solar1.lab-lpp.local
|
r18 | } | ||
paul@pc-solar1.lab-lpp.local
|
r12 | } | ||
paul@pc-solar1.lab-lpp.local
|
r9 | |||
paul@pc-solar1.lab-lpp.local
|
r12 | rtems_isr commutation_isr2( rtems_vector_number vector ) | ||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r18 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | ||
paul@pc-solar1.lab-lpp.local
|
r15 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | ||
paul@pc-solar1.lab-lpp.local
|
r18 | } | ||
paul@pc-solar1.lab-lpp.local
|
r12 | } | ||