Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Revision 137:489a93a04d6b, committed 2016-03-24
- Comitter:
- aniruddhv
- Date:
- Thu Mar 24 04:04:33 2016 +0000
- Parent:
- 135:522f7d73d04f
- Child:
- 144:4c20fcc105ce
- Commit message:
- Updated POWER_ON_TX, POWER_OFF_TX
Changed in this revision
--- a/COM_POWER_OFF_TX.h Wed Mar 02 17:17:45 2016 +0000
+++ b/COM_POWER_OFF_TX.h Thu Mar 24 04:04:33 2016 +0000
@@ -1,15 +1,51 @@
+#define power_on_bae {\
+ /*PENDING*/\
+}
+
+#define resume_bcn {\
+ Base_tc *beacon_tc = new Short_tc;\
+ beacon_tc->next_TC = NULL;\
+ PUTshort_or_long(beacon_tc,0);\
+ PUTcrc_pass(beacon_tc,0x1);\
+ PUTexec_status(beacon_tc,0);\
+ beacon_tc->TC_string[0] = 0x01;\
+ beacon_tc->TC_string[1] = 0x41;\
+ beacon_tc->TC_string[2] = 0x65;\
+ beacon_tc->TC_string[3] = 0x11;\
+ beacon_tc->TC_string[4] = 0x00;\
+ beacon_tc->TC_string[5] = 0;\
+ beacon_tc->TC_string[6] = 0;\
+ beacon_tc->TC_string[7] = 0;\
+ beacon_tc->TC_string[8] = 0x01;\
+ uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
+ beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\
+ beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
+ Base_tm *tm_ptr = new Short_tm;\
+ tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\
+}
+
#define COM_POWER_OFF_TX {\
/*gPC.puts("Inside COM_POWER_OFF_TX\r\n");*/\
/*PENDING: POWER OFF TRANSMITTER*/\
+ /*power_on_com_tx_pin = 0;*/\
RX1M.attach(&rx_read, Serial::RxIrq);\
gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
/*PENDING: SWITCH RF RELAY TO BEACON*/\
- /*PENDING: RF_SW_STATUS = RF_BCN*/\
- /*PENDING: POWER ON BAE*/\
- /*PENDING: SET BAE SW_EN_STATUS*/\
- /*PENDING: RESUME BEACON*/\
+ gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\
+ if( gFLAGS & COM_AUTO_POWER_OFF_BAE_FLAG ){\
+ power_on_bae;\
+ gFLAGS = gFLAGS | BAE_SW_EN_FLAG;\
+ gFLAGS & (~COM_AUTO_POWER_OFF_BAE_FLAG);\
+ resume_bcn;\
+ }\
+ else{\
+ if( gFLAGS & BAE_SW_EN_FLAG ){\
+ resume_bcn;\
+ }\
+ }\
gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG);\
gCOM_PA_COOLING_TIMEOUT.detach();\
gFLAGS = gFLAGS & (~COM_TX_FLAG);\
- /*gPC.puts("ompleted com_power_off tx\r\n");*/\
+ gFLAGS = gFLAGS & (~COM_SESSION_TIMEOUT_FLAG);\
+ /*gPC.puts("completed com_power_off tx\r\n");*/\
}
\ No newline at end of file
--- a/COM_POWER_ON_TX.h Wed Mar 02 17:17:45 2016 +0000
+++ b/COM_POWER_ON_TX.h Thu Mar 24 04:04:33 2016 +0000
@@ -1,47 +1,190 @@
+#define SET_BCN_STANDBY ( tm_ptr ){\
+ Base_tc *beacon_tc = new Short_tc;\
+ beacon_tc->next_TC = NULL;\
+ PUTshort_or_long(beacon_tc,0);\
+ PUTcrc_pass(beacon_tc,0x1);\
+ PUTexec_status(beacon_tc,0);\
+ beacon_tc->TC_string[0] = 0x01;\
+ beacon_tc->TC_string[1] = 0x41;\
+ beacon_tc->TC_string[2] = 0x65;\
+ beacon_tc->TC_string[3] = 0x11;\
+ beacon_tc->TC_string[4] = 0x00;\
+ beacon_tc->TC_string[5] = 0;\
+ beacon_tc->TC_string[6] = 0;\
+ beacon_tc->TC_string[7] = 0;\
+ beacon_tc->TC_string[8] = 0;\
+ uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
+ beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\
+ beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
+ tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\
+}
+
+#define reset_bae {\
+ Base_tc *reset_BAE = new Short_tc;\
+ reset_BAE->next_TC = NULL;\
+ PUTshort_or_long(reset_BAE,0);\
+ PUTcrc_pass(reset_BAE,0x1);\
+ PUTexec_status(reset_BAE,0);\
+ reset_BAE->TC_string[0] = 0x01;\
+ reset_BAE->TC_string[1] = 0x81;\
+ reset_BAE->TC_string[2] = 0x81;\
+ reset_BAE->TC_string[3] = 0x33;\
+ reset_BAE->TC_string[4] = 0;\
+ reset_BAE->TC_string[5] = 0;\
+ reset_BAE->TC_string[6] = 0;\
+ reset_BAE->TC_string[7] = 0;\
+ reset_BAE->TC_string[8] = 0;\
+ uint16_t crc16 = crc16_gen(reset_BAE->TC_string, 9);\
+ reset_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\
+ reset_BAE->TC_string[10] = (crc16 & 0x00FF);\
+ Base_tm *tm_ptr = new Short_tm;\
+ tm_ptr = FCTN_CDMS_RLY_TMTC(reset_BAE);\
+ /*DELETE THE TM AFTER USE*/\
+ obosc_tm_current = tm_ptr;\
+ int overCount = 0;\
+ while( obosc_tm_current != NULL ){\
+ if( (overCount < TM_OVERFLOW_CONSTANT) ){\
+ Base_tm *temp = obosc_tm_current->next_TM;\
+ delete obosc_tm_current;\
+ obosc_tm_current = temp;\
+ ++overCount;\
+ }\
+ else{\
+ /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
+ break;\
+ }\
+ }\
+}
+
+#define power_off_bae {\
+ Base_tc *power_off_BAE = new Short_tc;\
+ power_off_BAE->next_TC = NULL;\
+ PUTshort_or_long(power_off_BAE,0);\
+ PUTcrc_pass(power_off_BAE,0x1);\
+ PUTexec_status(power_off_BAE,0);\
+ power_off_BAE->TC_string[0] = 0x01;\
+ power_off_BAE->TC_string[1] = 0x81;\
+ power_off_BAE->TC_string[2] = 0x81;\
+ power_off_BAE->TC_string[3] = 0x23;\
+ power_off_BAE->TC_string[4] = 0;\
+ power_off_BAE->TC_string[5] = 0;\
+ power_off_BAE->TC_string[6] = 0;\
+ power_off_BAE->TC_string[7] = 0;\
+ power_off_BAE->TC_string[8] = 0;\
+ uint16_t crc16 = crc16_gen(power_off_BAE->TC_string, 9);\
+ power_off_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\
+ power_off_BAE->TC_string[10] = (crc16 & 0x00FF);\
+ Base_tm *tm_ptr = new Short_tm;\
+ tm_ptr = FCTN_CDMS_RLY_TMTC(power_off_BAE);\
+ /*DELETE THE TM AFTER USE*/\
+ obosc_tm_current = tm_ptr;\
+ int overCount = 0;\
+ while( obosc_tm_current != NULL ){\
+ if( (overCount < TM_OVERFLOW_CONSTANT) ){\
+ Base_tm *temp = obosc_tm_current->next_TM;\
+ delete obosc_tm_current;\
+ obosc_tm_current = temp;\
+ ++overCount;\
+ }\
+ else{\
+ /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
+ break;\
+ }\
+ }\
+}
+
#define COM_POWER_ON_TX {\
- /*gPC.puts("Inside COM_POWER_ON_TX\r\n");*/\
+ if (DEBUG)\
+ gPC.puts("Inside COM_POWER_ON_TX\r\n");\
if( !(gFLAGS & COM_TX_FLAG) ){\
gFLAGS = gFLAGS | COM_TX_FLAG;\
- /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/\
- bool retryFlag = true;\
- while( retryFlag == true ){\
- uint8_t standbyAck = 0xFF;\
- /*PENDING: SET BEACON TO STANDBY*/\
- if( standbyAck == 0xFF ){\
- /*ACK RECCEIVED*/\
- /*PENDING: BEACON TX MAIN STATUS*/\
- if( true ){\
- retryFlag = false;\
- /*PENDING: SWITCH RELAY TO COM_TX*/\
- /*PENDING: RF_SW_STATUS = RF_COM_TX*/\
- }\
- else{\
- gCOM_MNG_TMTC_THREAD->wait(5000);\
- }\
- }\
- else{\
- /*PENDING: RESET BAE*/\
- uint8_t standbyAck2 = 0x00;\
- /*PENDING: SET BEACON TO STANDBY*/\
- if( standbyAck2 == 0xFF ){\
- /*PENDING: BEACON TX MAIN STAUTS*/\
- if( true ){\
+ if( gFLAGS & BAE_SW_EN_FLAG ){\
+ /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/\
+ bool retryFlag = true;\
+ while( retryFlag == true ){\
+ Base_tm *tm_ptr = new Short_tm;\
+ SET_BCN_STANDBY ( tm_ptr );\
+ uint8_t standbyAck = (tm_ptr & 0xEF);\
+ if( standbyAck == 0xE0 ){\
+ /*ACK RECCEIVED*/\
+ uint8_t bcn_main_status = 0xFF;\
+ /*PENDING: BEACON TX MAIN STATUS from tm_ptr*/\
+ if( bcn_main_status ){\
retryFlag = false;\
- /*PENDING: SWITCH RF RELAY TO COM TX*/\
- /*PENDING: RF_SW_STATUS = RF_COM_TX*/\
+ /*PENDING: SWITCH RELAY TO COM_TX*/\
+ gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
+ }\
+ else{\
+ gCOM_MNG_TMTC_THREAD->wait(5000);\
}\
}\
else{\
- retryFlag = false;\
- /*PENDING: POWER OFF BEACON*/\
- /*PENDING: CLEAR BAE SW_EN*/\
- /*PENDING: SWITCH RF RELAY TO COM TX*/\
- /*PENDING: RF_SW_STATUS = RF_COM_TX*/\
+ reset_bae;\
+ Base_tm *tm_ptr2 = new Short_tm;\
+ SET_BCN_STANDBY ( tm_ptr2 );\
+ uint8_t standbyAck2 = (tm_ptr2 & 0xEF);\
+ if( standbyAck2 == 0xEF ){\
+ uint8_t bcn_main_status = 0xFF;\
+ /*PENDING: BEACON TX MAIN STATUS from tm_ptr2*/\
+ if( bcn_main_status = 0xFF ){\
+ retryFlag = false;\
+ /*PENDING: SWITCH RF RELAY TO COM TX*/\
+ gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
+ }\
+ else{\
+ gCOM_MNG_TMTC_THREAD->wait(5000);\
+ }\
+ }\
+ else{\
+ retryFlag = false;\
+ power_off_bae;\
+ gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG;\
+ gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG);\
+ /*PENDING: SWITCH RF RELAY TO COM TX*/\
+ gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
+ }\
+ /*DELETE THE TM AFTER USE*/\
+ obosc_tm_current = tm_ptr2;\
+ int overCount = 0;\
+ while( obosc_tm_current != NULL ){\
+ if( (overCount < TM_OVERFLOW_CONSTANT) ){\
+ Base_tm *temp = obosc_tm_current->next_TM;\
+ delete obosc_tm_current;\
+ obosc_tm_current = temp;\
+ ++overCount;\
+ }\
+ else{\
+ /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
+ break;\
+ }\
+ }\
+ }\
+ /*DELETE THE TM AFTER USE*/\
+ obosc_tm_current = tm_ptr;\
+ int overCount = 0;\
+ while( obosc_tm_current != NULL ){\
+ if( (overCount < TM_OVERFLOW_CONSTANT) ){\
+ Base_tm *temp = obosc_tm_current->next_TM;\
+ delete obosc_tm_current;\
+ obosc_tm_current = temp;\
+ ++overCount;\
+ }\
+ else{\
+ /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
+ break;\
+ }\
}\
}\
}\
+ else{\
+ power_off_bae;\
+ gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG);\
+ /*PENDING: SWITCH RF RELAY TO COM TX*/\
+ gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
+ }\
}\
/*PENDING: POWER ON COM_TX*/\
+ /*power_on_com_tx_pin = 1;*/\
uint8_t adfConfigPass = 0xFF;\
for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){\
/*PENDING: CONFIGURE ADF*/\
@@ -70,7 +213,6 @@
}\
}\
get_tc_list(power_on_tm->next_TM, 0x00);\
- /*PENDING: TRANSMIT ABOVE TM*/\
/*Call Sign, ACK_L1, TC_LIST*/\
/*snd_tm.head_pointer(power_on_tm_head);*/\
/*transmit_adf;*/\
@@ -89,6 +231,19 @@
break;\
}\
}\
+ if(/*NOT Transmitted succesfully*/){\
+ COM_POWER_OFF_TX;\
+ /*PENDING: CDMS HK MAIN*/\
+ uint8_t ackReceived = 0x00;\
+ /*PENDING: BCN TX MAIN*/\
+ if( ackReceived == 0xFF ){\
+ gCOM_MNG_TMTC_THREAD->wait(5000);\
+ /*PENDING: RESET CDMS*/\
+ }\
+ else{\
+ /*PENDING: RESET CDMS*/\
+ }\
+ }\
}\
else{\
/*PENDING: COM_POWER OFF TX*/\
--- a/DefinitionsAndGlobals.h Wed Mar 02 17:17:45 2016 +0000
+++ b/DefinitionsAndGlobals.h Thu Mar 24 04:04:33 2016 +0000
@@ -22,7 +22,7 @@
#define COM_TX_CONFIG_LIMIT 3
#define COM_TX_TICKER_LIMIT 32
-// ADF INTERRUPUT
+// ADF INTERRUPT
#define ADF_IRQ PTA14
// TC LIST
@@ -43,6 +43,14 @@
#define COM_PA_HOT_FLAG 0x0080
#define COM_TX_FLAG 0x0100
#define COM_SESSION_TIMEOUT_FLAG 0x0200
+ #define COM_AUTO_POWER_OFF_BAE_FLAG 0x0400
+ #define BAE_SW_EN_FLAG 0x0800
+ #define RF_SW_STATUS_FLAG 0x1000
+ #define COM_INIT_STATUS_FLAG 0x2000
+
+//RF relay STATUS
+ #define RF_COM_TX 0
+ #define RF_BCN 1
// COM_MNG_TMTC THREAD
#define SESSION_TIME_LIMIT 1500
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/P_COM_INIT.h Thu Mar 24 04:04:33 2016 +0000
@@ -0,0 +1,7 @@
+#define P_COM_INIT {\
+ gFLAGS = gFLAGS | COM_INIT_STATUS_FLAG;\
+ /*PENDING: SWITCH RF RELAY TO BEACON*/\
+ gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\
+ /*PENDING: Reset COM receiver (0.2 seconds)*/\
+ gFLAGS = gFLAGS & (~COM_INIT_STATUS_FLAG);\
+}
\ No newline at end of file
