/******************************************************************************* * モジュール名称 :APP01 - CMD from DMC * * モジュールラベル :app01_CmdDMC * * タスク区分 :called from APP01 (CMD) * * コーリングシーケンス:void app01_CmdDMC( void ) * * 戻り値 :void * * 使用上の注意 :なし * * エラー処理 :なし * * 作成日・作成者 :2015/2/15 Y.K. (No MDM CMD) * ********************************************************************************/ #include "dpu_api.h" #include "dpu_api_proto.h" #include "app_core.h" #include "app_MWE.h" #include "app_rdn_core.h" // *** Macro - app01_CmdRdn.c *** int app01_CmdRdn ( unsigned char [], int ); // *** Macro - Local *** unsigned char app01_CmdGetDMC ( void ); int app01_CmdExeDMC ( unsigned char * , int ); // *** Macro - CMD-special void app01_CmdSpecial(); // **************************************************************************************** // *** CMD - from DMC *** // **************************************************************************************** void app01_CmdDMC() { int i; int i_flag; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) // unsigned int ui_currentTime2; :衛星時刻(1LSB=31.25ms) // *** CMD - Get *** if (Gt_cmdDMC[0].uc_NumBuf == 0) { // No CMD in CMD-buffer Gt_cmdDMC[0].uc_NumBuf = app01_CmdGetDMC(); // CMD-Get from DMC Gt_cmdDMC[0].uc_GetCount += Gt_cmdDMC[0].uc_NumBuf; // CMD counter } // *** CMD - Exe *** if (Gt_cmdDMC[0].uc_NumBuf != 0 ) { for (i=0; i= Gd_CMDBUFF_SIZE ) Gt_cmdDMC[0].uc_GetErr |= 1; // ***ERR-1: CMD-Size overflow else i_cmdNum ++; } if (i_flag) Gt_cmdDMC[0].uc_GetErr |= 2; // ***ERR-2: CMD-Buffer overflow return (i_cmdNum); } // ************************* // *** CMD-Exec from DMC *** // ************************* int app01_CmdExeDMC( unsigned char uc_cmdBuff[], int i_dataSize) { int i, j; unsigned int ui_APID; unsigned short us_ChID; // ------------------------------------------------------- // <<<< Check CCSDS header >>>> ui_APID = uc_cmdBuff[1]; // DPU1:18/20 MEA1:28 MEA2:30 MIA: 38 MSA:40 HEPE:48 HEPI:50 ENA:58 MGFO:60 // DPU2:19/21 MGFI:68 MDM: 70 MSAS:78 EWO:80 SOR: 90 MEF :98 MWE:A0 // <<<< CMD in Redundancy >>>> #ifdef _APP_RDN_ if (Guc_dpuRdn==2) { // *** RDN if (Guc_dpuNo==0) { // *** from DPU1 to DPU2 if ( ui_APID == 0x20 || ui_APID == 0x21 || ui_APID == 0x68 || ui_APID == 0x70 || ui_APID == 0x78 || ui_APID == 0x80 || ui_APID == 0x90 || ui_APID == 0x98 || ui_APID == 0xA0 ) { j = app01_CmdRdn( uc_cmdBuff, i_dataSize); return( j ); } } else { // *** from DPU2 to DPU1 if ( ui_APID == 0x18 || ui_APID == 0x19 || ui_APID == 0x28 || ui_APID == 0x30 || ui_APID == 0x38 || ui_APID == 0x40 || ui_APID == 0x48 || ui_APID == 0x50 || ui_APID == 0x58 || ui_APID == 0x60 ) { j = app01_CmdRdn( uc_cmdBuff, i_dataSize); return( j ); } } } #endif // _APP_RDN_ // ------------------------------------------------------- // <<<< CMD Format : *** changed for FM! (100804) *** >>>> // CCSDS header 8 Bytes (6+1+1) // -------------------------------------------------- // B0-1 Channel ID 2 Bytes (0x0000 - 0xFFFF) 0-1 // B2 NodeID 1 Bytes ( 0x00 - 0x80) 2 Gt_cmdDMC.uc_NID // B3-4 Control Code 2 Bytes (0x0000 - 0xFFFF) 3-4 Gt_cmdDMC[0].ui_CntlID // B5- Data 0x80 Bytes-MAX 5- // ------------------------------------------------------- // *** Decode *** i_dataSize -= 13; if (i_dataSize < 0) { Gt_cmdDMC[0].ui_ExeErr |= 0x01; return( 1 ); // *** ERR-1: Size short *** } // *** Broadcast-CMD *** us_ChID = (unsigned short)(uc_cmdBuff[8]<<8) + (unsigned short)uc_cmdBuff[9]; if ( us_ChID == 0x0003 && i_dataSize > 0) return( 1 ); // *** Broadcast-CMD [reject] *** Gt_cmdDMC[0].uc_NID = uc_cmdBuff[10]; Gt_cmdDMC[0].ui_CntlID = (unsigned int )(uc_cmdBuff[11]<<8) + (unsigned int )uc_cmdBuff[12]; i = j = Gt_cmdDMC[0].uc_NID; // rev: 20150210 Gt_cmdDMC[0].uc_Ans = 0; // -------------------- // **** CMD to DPU **** // -------------------- if (i==Gd_N_DPU1 || i==Gd_N_DPU2) { Gt_cmdDMC[0].uc_Ans = app01_DPU ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); if ( Gt_cmdDMC[0].uc_Ans ) { Gt_cmdDMC[0].ui_ExeErr |= 0x00004; return( 1 ); } return( 0 ); } if (Guc_dpuNo==0 || Guc_dpuRdn==2) { // *** RDN: OK if (i==Gd_N_MEA1) { Gt_cmdDMC[0].uc_Ans = app01_MEA1( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_MEA2) { Gt_cmdDMC[0].uc_Ans = app01_MEA2( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_MIA ) { Gt_cmdDMC[0].uc_Ans = app01_MIA ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_MSA ) { Gt_cmdDMC[0].uc_Ans = app01_MSA ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_HEPE) { Gt_cmdDMC[0].uc_Ans = app01_HEPE( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_HEPI) { Gt_cmdDMC[0].uc_Ans = app01_HEPI( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_ENA ) { Gt_cmdDMC[0].uc_Ans = app01_ENA ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_MGFO) { Gt_cmdDMC[0].uc_Ans = app01_MGFO( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } // if ( Gt_cmdDMC[0].uc_Ans ) { Gt_cmdDMC[0].ui_ExeErr |= ( 0x00010 << ( j-Gd_N_MEA1) ); return( 1 ); } if (i==0xFF) return( 0 ); } if (Guc_dpuNo==1 || Guc_dpuRdn==2) { // *** RDN: OK if (i==Gd_N_MGFI) { Gt_cmdDMC[0].uc_Ans = app01_MGFI( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_EWO ) { Gt_cmdDMC[0].uc_Ans = app01_EWO ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_MEF ) { Gt_cmdDMC[0].uc_Ans = app01_MEF ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } else if (i==Gd_N_MWE ) { Gt_cmdDMC[0].uc_Ans = app01_MWE ( Gt_cmdDMC[0].ui_CntlID, &(uc_cmdBuff[13]), i_dataSize); i=0xFF; } // if ( Gt_cmdDMC[0].uc_Ans ) { Gt_cmdDMC[0].ui_ExeErr |= ( 0x01000 << ( j-Gd_N_MGFI) ); return( 1 ); } if (i==0xFF) return( 0 ); } Gt_cmdDMC[0].ui_ExeErr |= 0x02; // *** ERR-2: miss Node-ID *** return( 1 ); } // ******************************** // *** CMD-Exec for Special CMD *** // ******************************** void app01_CmdSpecial() { int i_flag; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) unsigned char uc_cmd[4]; // ************************************************************************** // *** HRM Release: WPT-S1 // ************************************************************************** // WPT-S1: START (0A 56 00 53) if ( Guc_MWE_WPTSext == 0x01 ) { if ( Guc_HK_link[ Gd_N_MWE ] == 0 ) { Guc_MWE_WPTSext = 0x50; Gui_MWE_WPTSextTI = 0x0; return; } // for WPT-S1 uc_cmd[0] = 0x0A; uc_cmd[1] = 0x56; uc_cmd[2] = 0x00; uc_cmd[3] = 0x53; // WPT-S1 DRV-ON i_flag = app_PiCmd( Gd_N_MWE, uc_cmd, 4 ); if (i_flag) { Guc_MWE_WPTSext = 0x30; } else { Guc_MWE_WPTSext = 0x03; i_flag = dpu_getTime( &t_timeInfo ); Gui_MWE_WPTSextTI = t_timeInfo.ui_currentTime2; } return; } // WPT-S1: END (0A 56 00 54) if ( Guc_MWE_WPTSext == 0x03 ) { i_flag = dpu_getTime( &t_timeInfo ); if ( t_timeInfo.ui_currentTime2 - Gui_MWE_WPTSextTI >= 28 ) { // 28 x 1/32sec = 0.875sec uc_cmd[0] = 0x0A; uc_cmd[1] = 0x56; uc_cmd[2] = 0x00; uc_cmd[3] = 0x54; // WPT-S1 DRV-OFF i_flag = app_PiCmd( Gd_N_MWE, uc_cmd, 4 ); if (i_flag == 0) { Guc_MWE_WPTSext = 0x10; Gui_MWE_WPTSextTI = t_timeInfo.ui_currentTime2 - Gui_MWE_WPTSextTI; } } return; } // ************************************************************************** // *** HRM Release: WPT-S2 // ************************************************************************** // WPT-S2: START (0A 5E 00 58) if ( Guc_MWE_WPTSext == 0x02 ) { if ( Guc_HK_link[ Gd_N_MWE ] == 0 ) { Guc_MWE_WPTSext = 0x60; Gui_MWE_WPTSextTI = 0x0; return; } // for WPT-S2 uc_cmd[0] = 0x0A; uc_cmd[1] = 0x5E; uc_cmd[2] = 0x00; uc_cmd[3] = 0x58; // WPT-S2 DRV-ON i_flag = app_PiCmd( Gd_N_MWE, uc_cmd, 4 ); if (i_flag) { Guc_MWE_WPTSext = 0x40; } else { Guc_MWE_WPTSext = 0x04; i_flag = dpu_getTime( &t_timeInfo ); Gui_MWE_WPTSextTI = t_timeInfo.ui_currentTime2; } return; } // WPT-S2: END (0A 5E 00 59) if ( Guc_MWE_WPTSext == 0x04 ) { i_flag = dpu_getTime( &t_timeInfo ); if ( t_timeInfo.ui_currentTime2 - Gui_MWE_WPTSextTI >= 28 ) { // 28 x 1/32sec = 0.875sec uc_cmd[0] = 0x0A; uc_cmd[1] = 0x5E; uc_cmd[2] = 0x00; uc_cmd[3] = 0x59; // WPT-S1 DRV-OFF i_flag = app_PiCmd( Gd_N_MWE, uc_cmd, 4 ); if (i_flag == 0) { Guc_MWE_WPTSext = 0x20; Gui_MWE_WPTSextTI = t_timeInfo.ui_currentTime2 - Gui_MWE_WPTSextTI; } } return; } return; }