kgkjgkj

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of CDMS_SD_MNG_OVERDRIVE by saikiran cholleti

Revision:
1:aa24178260d2
Parent:
0:bcbd76c86cde
--- a/TMTC.cpp	Wed Dec 16 09:06:59 2015 +0000
+++ b/TMTC.cpp	Wed Dec 16 11:55:46 2015 +0000
@@ -7,7 +7,7 @@
 #include "cdms_sd.h"
 #include "Flash.h"
 
-DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
+//DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL
 
 uint8_t received = 0;
@@ -23,70 +23,9 @@
 
 Base_tm *FCTN_CDMS_RLY_TMTC(Base_tc *tc)
 {
-    printf("\rTC execution in progress\r\n");
     Base_tm *tm = new Long_tm;
     Base_tm *tm_pointer = tm;
-    received = 0;
-    switch(GETapid(tc))
-    {
-        case 1: //apid=01 implies it corresponds to bae
-        {
-            printf("Telecommand is for BAE\r\n");
-            printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
-            FCTN_I2C_WRITE((char*)tc->TC_string);
-            while(1)
-            {
-                wait(1); //TimeOut instead of wait
-                if(tm_status_4m_slv == 1)
-                {
-                    printf("receiving...\r\n");
-                    FCTN_I2C_READ((char*)tm_pointer->TM_string);
-                    printf("%s", tm_pointer->TM_string);
-                    received+=1;
-                    tm_pointer = tm_pointer->next_TM;
-                    break; //only for testing purpose
-                }
-                else
-                {
-                    break;
-                }
-            }
-            if(received >= 1 )
-            {
-                printf("Telemetry is received from BAE\r\n");
-                Base_tm *tm_print = tm;
-                for(uint8_t i=0;i<received;i++)
-                {   
-                    printf("%s", tm_print->TM_string);
-                    tm_print = tm_print->next_TM; //for check
-                }
-                received  = 0;
-                return tm;
-            }
-            else
-            {
-                printf("Telemetry is not received from BAE\r\n");
-                tm_pointer = new Short_tm;
-                tm_pointer->TM_string[0] = 0xB0;
-                tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
-                tm_pointer->TM_string[2] = 0x01;
-                tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
-                tm_pointer->TM_string[4] = 0x01;
-                for(uint8_t i=0;i<6;i++)
-                {
-                    tm_pointer->TM_string[i+5] = 0;
-                }
-                crc16 = CRC::crc16_gen(tm->TM_string,11);
-                tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-                tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
-                return tm;
-            }
-            break;
-        }
-        case 2:
-        {
-            printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms
-            switch(GETservice_type(tc))
+    switch(GETservice_type(tc))
             {
                 case 6:
                 {
@@ -329,7 +268,7 @@
                                     tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
                                     return tm;
                                     break;
-                                    break;
+                                
                                 }
                                 case 17:
                                 {
@@ -497,7 +436,10 @@
                                 return tm;
                             }
                             break;
-                        }
+                        
+                          }
+                       }
+                       
                         case 8:
                         {
                             printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); 
@@ -510,7 +452,7 @@
                                     {
                                         case 1:
                                         {
-                                            printf("P_PL_INIT\r\n"); //call P_PL_INIT using CDMS_RUN_PRCS
+                                            printf("P_EPS_INIT\r\n"); //call P_PL_INIT using CDMS_RUN_PRCS
                                             tm_pointer = new Short_tm; 
                                             tm_pointer->TM_string[0] = 0xB0; 
                                             tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
@@ -529,7 +471,7 @@
                                         }
                                         case 2:
                                         {
-                                            printf("P_PL_MNGR\r\n"); //call P_PL_MNGR using CDMS_RUN_PRCS
+                                            printf("P_EPS_MAIN\r\n"); //call P_PL_MNGR using CDMS_RUN_PRCS
                                             tm_pointer = new Short_tm; 
                                             tm_pointer->TM_string[0] = 0xB0; 
                                             tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
@@ -548,7 +490,7 @@
                                         }
                                         case 3:
                                         {
-                                            printf("P_COM_INIT\r\n"); //call P_COM_INIT using CDMS_RUN_PRCS
+                                            printf("P_ACS_INIT\r\n"); //call P_COM_INIT using CDMS_RUN_PRCS
                                             tm_pointer = new Short_tm; 
                                             tm_pointer->TM_string[0] = 0xB0; 
                                             tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
@@ -567,7 +509,64 @@
                                         }
                                         case 4:
                                         {
-                                            printf("P_CDMS_HK_MNGR\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS
+                                            printf("P_ACS_ACQ_DATA\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS
+                                            tm_pointer = new Short_tm; 
+                                            tm_pointer->TM_string[0] = 0xB0; 
+                                            tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
+                                            tm_pointer->TM_string[2] = 0x01;
+                                            tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
+                                            tm_pointer->TM_string[4] = 0x01;
+                                            for(uint8_t i=0;i<6;i++)
+                                            {
+                                                tm_pointer->TM_string[i+5] = 0;
+                                            }
+                                            crc16 = CRC::crc16_gen(tm->TM_string,11);
+                                            tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
+                                            tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
+                                            return tm;
+                                            break;
+                                        }
+                                         case 5:
+                                        {
+                                            printf("P_ACS_MAIN\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS
+                                            tm_pointer = new Short_tm; 
+                                            tm_pointer->TM_string[0] = 0xB0; 
+                                            tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
+                                            tm_pointer->TM_string[2] = 0x01;
+                                            tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
+                                            tm_pointer->TM_string[4] = 0x01;
+                                            for(uint8_t i=0;i<6;i++)
+                                            {
+                                                tm_pointer->TM_string[i+5] = 0;
+                                            }
+                                            crc16 = CRC::crc16_gen(tm->TM_string,11);
+                                            tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
+                                            tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
+                                            return tm;
+                                            break;
+                                        }
+                                         case 6:
+                                        {
+                                            printf("P_BCN_INIT\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS
+                                            tm_pointer = new Short_tm; 
+                                            tm_pointer->TM_string[0] = 0xB0; 
+                                            tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
+                                            tm_pointer->TM_string[2] = 0x01;
+                                            tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
+                                            tm_pointer->TM_string[4] = 0x01;
+                                            for(uint8_t i=0;i<6;i++)
+                                            {
+                                                tm_pointer->TM_string[i+5] = 0;
+                                            }
+                                            crc16 = CRC::crc16_gen(tm->TM_string,11);
+                                            tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
+                                            tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
+                                            return tm;
+                                            break;
+                                        }
+                                         case 7:
+                                        {
+                                            printf("P_BCN_MAIN\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS
                                             tm_pointer = new Short_tm; 
                                             tm_pointer->TM_string[0] = 0xB0; 
                                             tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
@@ -735,155 +734,11 @@
                                 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
                                 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
                                 return tm;
-                                break;
+                                
                             }
                             break;
-                        }
-                        case 7:
-                        {
-                            printf("service:PAYLOAD MANAGEMENT SERVICE\r\r\n"); //TM is ACKL234
-                            switch(GETservice_subtype(tc))
-                            {
-                                case 1:
-                                {
-                                    printf("INSERT PL SCHEDULE\r\n"); //should be called PL_MAIN 
-                                    tm_pointer = new Short_tm;  // for now sending dummy ACK L_234
-                                    tm_pointer->TM_string[0] = 0xB0; 
-                                    tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
-                                    tm_pointer->TM_string[2] = 0x01;
-                                    tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
-                                    tm_pointer->TM_string[4] = 0x01;
-                                    for(uint8_t i=0;i<6;i++)
-                                    {
-                                        tm_pointer->TM_string[i+5] = 0;
-                                    }
-                                    crc16 = CRC::crc16_gen(tm->TM_string,11);
-                                    tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-                                    tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
-                                    return tm;
-                                    break;
-                                }
-                                case 2:
-                                {
-                                    printf("DELETE PL SCHEDULE\r\n"); //Should be called PL_MAIN 
-                                    tm_pointer = new Short_tm; // for now sending dummy ACK L_234
-                                    tm_pointer->TM_string[0] = 0xB0; 
-                                    tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
-                                    tm_pointer->TM_string[2] = 0x01;
-                                    tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
-                                    tm_pointer->TM_string[4] = 0x01;
-                                    for(uint8_t i=0;i<6;i++)
-                                    {
-                                        tm_pointer->TM_string[i+5] = 0;
-                                    }
-                                    crc16 = CRC::crc16_gen(tm->TM_string,11);
-                                    tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-                                    tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
-                                    return tm;
-                                    break;
-                                }
-                                case 3:
-                                {
-                                    printf("REPORT PL SCHEDULE\r\n"); //Data is taken by calling PL_MAIN
-                                    tm_pointer = new Long_tm; //for now sending dummy PMS
-                                    tm_pointer->TM_string[0] = 0x48;
-                                    tm_pointer->TM_string[1] = 0x00; //spare 8 bits 
-                                    tm_pointer->TM_string[2] = GETpacket_seq_count(tc);                                    
-                                    tm_pointer->TM_string[3] = 0x01;
-                                    for(uint8_t i=4;i<132;i++)
-                                    {
-                                        tm_pointer->TM_string[i] = 0; // for now filling with zeros instead of PL_SCHEDULE
-                                    }
-                                    crc16 = CRC::crc16_gen(tm->TM_string,11);
-                                    tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8);
-                                    tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF);
-                                    return tm;
-                                    break;
-                                }
-                                default:
-                                {
-                                    printf("INVALID TC"); //send invalid TC TM
-                                    tm_pointer = new Short_tm; 
-                                    tm_pointer->TM_string[0] = 0xB0; 
-                                    tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
-                                    tm_pointer->TM_string[2] = 0x01;
-                                    tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
-                                    tm_pointer->TM_string[4] = 0x01;
-                                    for(uint8_t i=0;i<6;i++)
-                                    {
-                                        tm_pointer->TM_string[i+5] = 0;
-                                    }
-                                    crc16 = CRC::crc16_gen(tm->TM_string,11);
-                                    tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-                                    tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
-                                    return tm;
-                                    break;
-                                }
-                            }
-                            break;
-                        }
-                    }
-                    break;
-                }
-                default:
-                {
-                    printf("INVALID TC"); //send invalid TC TM
-                    tm_pointer = new Short_tm; 
-                    tm_pointer->TM_string[0] = 0xB0; 
-                    tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
-                    tm_pointer->TM_string[2] = 0x01;
-                    tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
-                    tm_pointer->TM_string[4] = 0x01;
-                    for(uint8_t i=0;i<6;i++)
-                    {
-                        tm_pointer->TM_string[i+5] = 0;
-                    }
-                    crc16 = CRC::crc16_gen(tm->TM_string,11);
-                    tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-                    tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
-                    return tm;
-                    break;
-                }
-            }
-        }
-        case 3:
-        {
-            printf("Telecommand is for PL\r\n");
-            // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae
-            // FCTN_I2C_WRITE((char*)tc->TC_string);
-            // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready
-            // wait(1); //wait time is to be optimised
-            // if(tm_status_4m_slv == 1)
-            // {
-            //     FCTN_I2C_READ((char*)tm->TM_string);
-            //     received = 1;
-            // }
-            // if(received == 1 )
-            // {
-            //     printf("Telemetry is received from BAE\r\n");
-            //     printf("%s", tm->TM_string);
-            //     received  = 0;
-            // } // similar to BAE functions
-            break;
-        }
-        default: //invalid TC
-        {
-            printf("INVALID TC\r\n");
-            tm_pointer = new Short_tm; 
-            tm_pointer->TM_string[0] = 0xB0; 
-            tm_pointer->TM_string[1] = GETpacket_seq_count(tc);                                    
-            tm_pointer->TM_string[2] = 0x01;
-            tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
-            tm_pointer->TM_string[4] = 0x01;
-            for(uint8_t i=0;i<6;i++)
-            {
-                tm_pointer->TM_string[i+5] = 0;
-            }
-            crc16 = CRC::crc16_gen(tm->TM_string,11);
-            tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
-            tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
-            return tm;
-            break;
-        }
-     }
-}
\ No newline at end of file
+                       }
+                       }
+                       }
+                       }
+        
\ No newline at end of file