/******************************************************************************* * * * モジュール名称 :冗長ミッションコマンド送信 * * モジュールラベル :rap_sv_sendRdnMissionCmd * * タスク区分 :冗長ライブラリ * * 機能 :ミッション機器へミッションコマンドのRMAP Write * * Commandを送信する * * * * コーリングシーケンス:int rap_sv_sendRdnMissionCmd( nodeID, commandBuff, * * dataSize ) * * 引数 :int nodeID :ミッション機器ID * * unsigned char commandBuff[163]:ミッションコマンド * * (RMAP Write Command のData 部分のみ) * * int dataSize :commandBuff に格納 * * したデータバイト数(byte) * * 戻り値 :処理結果 ( <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_MAX 178 int rap_sv_sendRdnMissionCmd( int nodeID, unsigned char commandBuff[], int dataSize ) { // int i; unsigned short us_buff[89]; unsigned char *ucp_buff; char c_msChannel; /* ミッションチャネル(0-7) */ char c_dpuIndex; /* 冗長DPUインデックス */ unsigned int ui_writeAddr; unsigned int ui_writeSize; 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; } } if( dataSize < 0 || dataSize > 163 ) { return -2; } /* コマンド生成 */ ui_writeAddr = RA_Gt_missionInfo[(int)c_dpuIndex][(int)c_msChannel].ui_cmdBuffer; ui_writeSize = dataSize; ucp_buff = (unsigned char *)us_buff; *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 = 0x6C; /* PacketType,Command,SourcePathAddrLen 01101100 */ ucp_buff++; *ucp_buff = 0x00; /* DestinationKey (0x00固定) */ ucp_buff++; *ucp_buff = 0x20; /* Source Logical Address (0x20固定) */ ucp_buff++; *ucp_buff = RA_d_SPW_MSCMD; /* Transaction Identifier MS (MSB=0,MS-Command) */ ucp_buff++; *ucp_buff = RA_Guc_rmapCnt[(int)c_msChannel][RA_d_SPW_MSCMD]; /* 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 */ /* Header CRCはハードが設定 */ /* Data本体 */ memcpy( ucp_buff, &(commandBuff[0]), dataSize); ucp_buff+=(dataSize-1); /* for( i=0 ; i