lkdsnf;

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_PL_Working by Siva ram

Files at this revision

API Documentation at this revision

Comitter:
ee12b079
Date:
Thu Jan 21 14:35:11 2016 +0000
Parent:
87:6e154fd43531
Child:
89:cca875337dd5
Child:
90:df55a5f68331
Commit message:
NOT DETECTING eOs

Changed in this revision

COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
DefinitionsAndGlobals.h Show annotated file Show diff for this revision Revisions of this file
OBSRS.h Show annotated file Show diff for this revision Revisions of this file
adf.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/COM_MNG_TMTC.h	Wed Jan 20 17:00:54 2016 +0000
+++ b/COM_MNG_TMTC.h	Thu Jan 21 14:35:11 2016 +0000
@@ -471,7 +471,7 @@
         }
         case 2:
         {
-            //printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms
+            //gPC.printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms
             switch(GETservice_type(tc_ptr))
             {
                 case 0x60:
@@ -1465,6 +1465,7 @@
                             /*execute_obsrs(current_TC, put_tm_here)*/\
                             /*read_TC(current_TC);*/\
                             execute_OBSRS_TC(current_TC);\
+                            adf_SND_SDCard();\
                             uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\
                             PUTexec_status(current_TC, tempExec);\
                             /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\
--- a/DefinitionsAndGlobals.h	Wed Jan 20 17:00:54 2016 +0000
+++ b/DefinitionsAndGlobals.h	Thu Jan 21 14:35:11 2016 +0000
@@ -1,6 +1,6 @@
 // **************DEFINITIONS*********************
 
-#define bypass_adf 1
+#define bypass_adf 0
 
 // COM_RX
     #define RX_TIMEOUT_LIMIT 0.5
--- a/OBSRS.h	Wed Jan 20 17:00:54 2016 +0000
+++ b/OBSRS.h	Thu Jan 21 14:35:11 2016 +0000
@@ -46,7 +46,7 @@
 
 uint8_t SID ;
 unsigned char buffer_112[112];
-uint32_t FSC;
+uint8_t FSC;
 uint16_t read_success = false;
 uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0;
 uint16_t counter_call_sign_buffer=0;
@@ -61,8 +61,8 @@
 uint16_t T_frame_Ack_andcallsign_sent = 0; 
 uint16_t T_frame_in_Ackandcallsign = 4;                        // needs to get from sukhdeep depends on size of Ack_L1
 uint64_t start_block_num ;
-uint32_t block_counter = 0;
-uint32_t no_of_frames =0;                             
+uint8_t block_counter = 0;
+uint8_t no_of_frames =0;                             
 int Ack_L1; // should be always even
 
 //#define max_segments = 65415/(48+T_frames_in_segment*159)
@@ -492,38 +492,41 @@
 void execute_OBSRS_TC(Base_tc *tcp){
     short_TC = true;
     //pc.printf("WELCOME\n\r");
-//    FCTN_CDMS_SD_INIT();/* sd card initialization*/
+    FCTN_CDMS_SD_INIT();/* sd card initialization*/
 //    SID = 0x0;
 //    FSC =10;
 //    no_of_frames =1;
 //    short_TC = true;
-//    adf_SND_SDCard;
+//    adf_SND_SDCard();
 
-    if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){
-        short_TC = true;
-    }
-    else{
-        short_TC = false;    
-    }
-    /*  reading SID from TC  */
-    SID = (tcp->TC_string[2]) & 0x0f;
-    /*  reading FSC and no. of frames from TC  */
-    if(short_TC){
-    FSC  = tcp->TC_string[3] << 24;
-    FSC += tcp->TC_string[4] << 16;
-    FSC += tcp->TC_string[5] << 8;
-    FSC += tcp->TC_string[6];
-    no_of_frames = tcp->TC_string[7] << 8;
-    no_of_frames += tcp->TC_string[8];
-    }
-    else{
-        no_of_frames = tcp->TC_string[3];
-        for(int i=0 ;i<no_of_frames ; i++){
-            list_of_FSC[i] = tcp->TC_string[4+i];
-        }
-    }
-    gPC.printf("sid = %u \r\n",SID);
-    gPC.printf("FSC = %u\r\n",FSC);
+//    if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){
+//        short_TC = true;
+//    }
+//    else{
+//        short_TC = false;    
+//    }
+//    /*  reading SID from TC  */
+//    SID = (tcp->TC_string[2]) & 0x0f;
+//    /*  reading FSC and no. of frames from TC  */
+//    if(short_TC){
+//    FSC  = tcp->TC_string[3] << 24;
+//    FSC += tcp->TC_string[4] << 16;
+//    FSC += tcp->TC_string[5] << 8;
+//    FSC += tcp->TC_string[6];
+//    no_of_frames = tcp->TC_string[7] << 8;
+//    no_of_frames += tcp->TC_string[8];
+//    }
+//    else{
+//        no_of_frames = tcp->TC_string[3];
+//        for(int i=0 ;i<no_of_frames ; i++){
+//            list_of_FSC[i] = tcp->TC_string[4+i];
+//        }
+//    }
+//    gPC.printf("sid = %u \r\n",SID);
+//    gPC.printf("FSC = %u\r\n",FSC);
+    SID = 0x0;
+    FSC = 10;
+    no_of_frames = 2;
 //    cout<<"max_segments = "<<max_segments<<ENDL;
     //while(0){
 //    while(!stop){
--- a/adf.h	Wed Jan 20 17:00:54 2016 +0000
+++ b/adf.h	Thu Jan 21 14:35:11 2016 +0000
@@ -245,7 +245,7 @@
   
  
 #define send_data {\
-    if(sent_tmfrom_SDcard){\
+if(sent_tmfrom_SDcard){\
         send_tm_from_SD_card();\
     }else{\
         snd_tm.transmit_data(buffer_112,&last_buffer);\
@@ -282,54 +282,6 @@
     SPI_mutex.unlock();\
     /*ticker.attach_us(&check,32000);*/\
 }
-    
-    
-    
-#define adf_SND_SDCard {\
-    buffer_state = true;\
-    last_buffer = false;\
-    loop_on = true;\
-    ADF_off = false;\
-    sent_tmfrom_SDcard = true;\
-    signal = COM_MNG_TMTC_SIGNAL_ADF_SD;\
-    start_block_num = starting_add;\
-    end_block_num = ending_add;\
-    initial_adf_check;\
-    initiate;\
-    send_data;\
-    while(loop_on){\
-        /*led2=!led2;*/\
-        gCOM_MNG_TMTC_THREAD->signal_wait(COM_MNG_TMTC_SIGNAL_ADF_SD);\
-        if(ADF_off){\
-            SPI_mutex.lock();\
-            /*ticker.detach();*/\
-            gCS_ADF=0;\
-            spi.write(0xB1);\
-            gCS_ADF=1;\
-            SPI_mutex.unlock();\
-            /*gPC.puts("transmission done\r\n");*/\
-            loop_on = false;\
-        }else{\
-            write_data;\
-            if(!last_buffer)\
-            send_tm_from_SD_card();\
-        }\
-    }\
-}
-    
-//void read_TC(Base_tc* TC_ptr){
-//    //gPC.puts("Inside sd card sending\r\n");
-//    unsigned char service_subtype = 0;
-//    uint64_t starting_add  = 0, ending_add = 0;
-//    service_subtype = (TC_ptr->TC_string[2])&0x0f;
-//    starting_add =  (TC_ptr->TC_string[5]) +  ( (TC_ptr->TC_string[4])<<8 ) + ( (TC_ptr->TC_string[3]) <<16);
-//    ending_add =  (TC_ptr->TC_string[8]) +  ( (TC_ptr->TC_string[7])<<8 ) + ( (TC_ptr->TC_string[6]) <<16);
-//    starting_add = 10; // for now
-//    ending_add = 20;
-////    adf_SND_SDCard(starting_add , ending_add);
-//    //gPC.puts("sending from sd card\r\n");
-//    adf_SND_SDCard;
-//}
  
 #define configure_adf {\
     finish_write_data = false;\
@@ -372,4 +324,35 @@
         }\
     }\
     /*gPC.puts("after while loop\r\n");*/\
-}
\ No newline at end of file
+}
+
+void adf_SND_SDCard() {
+    sent_tmfrom_SDcard = true;
+    configure_adf;
+    signal = COM_MNG_TMTC_SIGNAL_ADF_SD;
+    send_data;
+    while(loop_on){
+        wait_ms(COM_TX_TICKER_LIMIT);
+        if(IRQ || bypass_adf){
+            if(finish_write_data){
+                if(ADF_off){
+                    SPI_mutex.lock(); 
+                    gCS_ADF=0;
+                    spi.write(0xB1);
+                    gCS_ADF=1;
+                    SPI_mutex.unlock();
+                    loop_on = false;
+                    gPC.puts("Transmission done\r\n");
+                }
+                else{
+                    ADF_off = true;
+                }
+            }else{
+                write_data;
+                send_tm_from_SD_card();
+            }
+        }
+    }
+    /*gPC.puts("after while loop\r\n");*/
+}
+
--- a/main.cpp	Wed Jan 20 17:00:54 2016 +0000
+++ b/main.cpp	Thu Jan 21 14:35:11 2016 +0000
@@ -34,7 +34,7 @@
     RX1M.attach(&rx_read, Serial::RxIrq);
     
     // DEBUG
-//    gPC.puts("welcome to mng_tm_tc\r\n");
+    //gPC.puts("welcome to mng_tm_tc\r\n");
     gPC.baud(1200);
     
     // COMMON SPI