/******************************************************************************* * * * モジュール名称 :冗長SUNPULSE受信時刻送信 * * モジュールラベル :rap_sv_sendRdnSunpulseTime * * タスク区分 :冗長ライブラリ * * 機能 :ミッション機器へSUNPULSE受信時刻のRMAP Write Command * * を送信する * * * * コーリングシーケンス:int rap_sv_sendRdnSunpulseTime( nodeID ) * * 引数 :int nodeID :ミッション機器ID * * 戻り値 :処理結果 ( <0 :異常 , 0:正常) * * 0 :正常終了 * * -1 :自DPU 側ミッション機器 * * -2 :上記以外の異常 * * 使用上の注意 :なし * * エラー処理 :なし * * * *******************************************************************************/ #include "dpu_api.h" #include "dpu_api_proto.h" #include "rap_api.h" #include "rap_define.h" /* define定義 */ #include "rap_variable.h" /* グローバル変数宣言 */ #include "rap_func.h" /* 関数プロトタイプ宣言 */ #include "app_rdn_core.h" #define RMAP_PKT_SIZE 20 int rap_sv_sendRdnSunpulseTime( int nodeID ) { unsigned short us_buff[10]; unsigned char *ucp_buff; char c_msChannel; /* ミッションチャネル(0-7) */ char c_dpuIndex; /* 冗長DPUインデックス */ unsigned int ui_writeAddr; unsigned int ui_writeSize; M_T_TIME_INFO t_timeInfo; int i_result; /* コマンド送信結果 */ /* 処理開始 */ /* 引数チェック */ c_msChannel = Gc_CHID[ nodeID ]; c_dpuIndex = rap_cmm_getRdnDpuIndex(); if( c_msChannel < 0 || c_msChannel >= RA_d_MISSION_NUM ) { // ---comment out:110615 --- rap_cmm_putDbgTlm( c_msChannel ); return -1; } if( c_dpuIndex == 0 ) { if( nodeID >= RA_d_NODE_MGF_I ) { return -1; } }else{ if( nodeID < RA_d_NODE_MGF_I || nodeID == RA_d_NODE_EWO_B ) { return -1; } } /* RMAP Write Command作成 */ ui_writeAddr = RA_Gt_missionInfo[(int)c_dpuIndex][(int)c_msChannel].ui_tiRegister; ui_writeSize = 4; dpu_getTime( &t_timeInfo ); ucp_buff = (unsigned char *)us_buff; //big endianなので問題無し *ucp_buff = RA_Gt_missionInfo[(int)c_dpuIndex][(int)c_msChannel].uc_logicalAddr; /* Logical Address */ ucp_buff++; *ucp_buff = 0x01; /* Protocol Identifier (RMAP=0x01) */ ucp_buff++; *ucp_buff = 0x64; /* PacketType,Command,SourcePathAddrLen 01100100 */ ucp_buff++; *ucp_buff = 0x00; /* DestinationKey (0x00固定) */ ucp_buff++; *ucp_buff = 0x20; /* Source Logical Address (0x20固定) */ ucp_buff++; *ucp_buff = RA_d_SPW_SUNPULSE; /* Transaction Identifier MS (MSB=0,SUNPULSE) */ ucp_buff++; *ucp_buff = RA_Guc_rmapCnt[(int)c_msChannel][RA_d_SPW_SUNPULSE]; /* Transaction Identifier LS (Counter) */ ucp_buff++; *ucp_buff = 0x00; /* Extended Write Address (0x00固定) */ ucp_buff++; memcpy( ucp_buff, &ui_writeAddr, 4); ucp_buff+=4; /* *ucp_buff = (unsigned char)((ui_writeAddr >> 24) & 0xFF); // Write Address MS ucp_buff++; *ucp_buff = (unsigned char)((ui_writeAddr >> 16) & 0xFF); // Write Address ucp_buff++; *ucp_buff = (unsigned char)((ui_writeAddr >> 8) & 0xFF); // Write Address ucp_buff++; *ucp_buff = (unsigned char)( ui_writeAddr & 0xFF); // Write Address LS ucp_buff++; */ ui_writeSize = (ui_writeSize << 8); memcpy( ucp_buff, &ui_writeSize, 3); ucp_buff+=3; /* *ucp_buff = (unsigned char)((ui_writeSize >> 16) & 0xFF); // Data Length MS ucp_buff++; *ucp_buff = (unsigned char)((ui_writeSize >> 8) & 0xFF); // Data Length ucp_buff++; *ucp_buff = (unsigned char)( ui_writeSize & 0xFF); // Data Length LS ucp_buff++; */ /* Header CRCはハードが設定 */ /* Data本体(SUNPULSE受信時刻) */ memcpy( ucp_buff, &(t_timeInfo.ui_sunpulseTime), 4); ucp_buff+=3; /* *ucp_buff = (unsigned char)(( t_timeInfo.ui_sunpulseTime >> 24) & 0xFF); // SUNPULSE Time MS ucp_buff++; *ucp_buff = (unsigned char)(( t_timeInfo.ui_sunpulseTime >> 16) & 0xFF); // SUNPULSE Time ucp_buff++; *ucp_buff = (unsigned char)(( t_timeInfo.ui_sunpulseTime >> 8) & 0xFF); // SUNPULSE Time ucp_buff++; *ucp_buff = (unsigned char)( t_timeInfo.ui_sunpulseTime & 0xFF); // SUNPULSE Time LS */ /* Data CRCはハードが設定 */ i_result = rap_dr_sendRdnSingleCmd( c_msChannel, (unsigned char *)us_buff, RMAP_PKT_SIZE, RA_d_SDRAM_SADDR); if( i_result != 0 ) { // ---comment out:110615 --- rap_cmm_putDbgTlm( i_result ); return -2; } RA_Guc_rmapCnt[(int)c_msChannel][RA_d_SPW_SUNPULSE]++; return 0; }