======Version Compare======
SW Version 및 호환성 확인 방법에 대한 안내 페이지입니다.
====Code====
===C#===
using ec = ComiLib.EtherCAT.SafeNativeMethods;
bool IsVersionMatch(ref string message)
{
ec.TEcFileVerInfo_SDK sdkInfo = new ec.TEcFileVerInfo_SDK();
ec.TEcFileVerInfo_WDM driverInfo = new ec.TEcFileVerInfo_WDM();
ec.TEcFileVerInfo_FW fwInfo = new ec.TEcFileVerInfo_FW();
bool isVersionMatch = ec.ecNet_GetVerInfo(0, ref sdkInfo, ref driverInfo, ref fwInfo, ref errorCode);
if (isVersionMatch)
{
message = "OK";
return true;
}
// Firmware Verion 확인
string ver_Fw = string.Format("{0}.{1}.{2}.{3}", fwInfo.CurVer.MajorVer, fwInfo.CurVer.MinorVer, fwInfo.CurVer.BuildNo, fwInfo.CurVer.RevNo);
string comp_Fw_Drv = string.Empty;
string comp_Fw_Lib = string.Empty;
string comp_Drv_Lib = string.Empty;
//FW - SDK 호환성 결과
switch ((ec.EEcVerCompatResult)sdkInfo.nFwCompResult)
{
case ec.EEcVerCompatResult.ecVER_MISMATCH_LOWER: comp_Fw_Lib = "Library version is higher than the Firmware"; break;
case ec.EEcVerCompatResult.ecVER_MISMATCH_HIGHER: comp_Fw_Lib = "Library version is lower than the Firmware"; break;
case ec.EEcVerCompatResult.ecVER_MATCH: comp_Fw_Lib = "OK"; break;
default: comp_Fw_Lib = "Firmware Version is invalid"; break;
}
//FW-WDM 호환성 결과
switch ((ec.EEcVerCompatResult)driverInfo.nFwCompResult)
{
case ec.EEcVerCompatResult.ecVER_MISMATCH_LOWER: comp_Fw_Drv = "Driver version is higher than the Firmware"; break;
case ec.EEcVerCompatResult.ecVER_MISMATCH_HIGHER: comp_Fw_Drv = "Driver version is lower than the Firmware"; break;
case ec.EEcVerCompatResult.ecVER_MATCH: comp_Fw_Drv = "OK"; break;
default: comp_Fw_Drv = "Firmware Version is invalid"; break;
}
//SDK-WDM
switch ((ec.EEcVerCompatResult)sdkInfo.nWdmCompResult)
{
case ec.EEcVerCompatResult.ecVER_MISMATCH_LOWER: comp_Drv_Lib = "Driver version is lower than the Library"; break;
case ec.EEcVerCompatResult.ecVER_MISMATCH_HIGHER: comp_Drv_Lib = "Library version is lower than the Driver"; break;
case ec.EEcVerCompatResult.ecVER_MATCH: comp_Drv_Lib = "OK"; break;
default: comp_Drv_Lib = "Driver Version is invalid"; break;
}
message = string.Format("FW-WDM : {0}. WDM-DLL : {1}. FW-DLL : {2}", comp_Fw_Drv, comp_Drv_Lib, comp_Fw_Lib);
return false;
}
===C++===
\\
bool IsVersionMatch()
{
TEcFileVerInfo_SDK SdkVerInfo;
TEcFileVerInfo_WDM WdmVerInfo;
TEcFileVerInfo_FW FwVerInfo;
int nErrCode;
return ecNet_GetVerInfo(NETID, &SdkVerInfo, &WdmVerInfo, &FwVerInfo, &nErrCode);
}