Browse Source

Z991239-1169 #comment 卡机加载修改健康记录信息 other:卡机加载修改健康记录信息

杨诗友80174847 4 năm trước cách đây
mục cha
commit
d9937ce662

+ 47 - 32
Module/mod_cardissuer/CardIssuerFSM.cpp

@@ -1909,54 +1909,75 @@ bool CCardIssuerFSM::LoadCMBPrint(CSimpleStringA csBinPath)
 }
 ErrorCodeEnum CCardIssuerFSM::OpenDevice(BYTE btOpenType, const char *pDevSN)
 {
-	//MessageBoxA(0,0,0,0);
 	LOG_FUNCTION();
+
 	m_devOpenFailedCount++;
 	ErrorCodeEnum eErrDev;
 
-	HRESULT hr;
+	//HRESULT hr;
 	int initTries = 0;
 	
+
 	CSimpleStringA dllName;
 	GetVendorDllName(dllName);
-	//eErrDev = SpGetDevAdaptorPath(m_pEntity,GetEntityBase()->GetEntityName(),dllName);
-	//if (eErrDev != Error_Succeed)
-	//{
-	//	Dbg("load vendor dll(%s) failed.", (const char*)dllName);
-	//	return Error_DevLoadFileFailed;
-	//}
-	//Dbg("%s,%s,%s", (LPCTSTR)m_csMachineType, (LPCTSTR)m_csSite,(LPCTSTR)dllName);
-	CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
-	CSmartPointer<IConfigInfo> spConfig;
+	Dbg("to load:%s",(const char*)dllName);
+#ifdef RVC_OS_WIN
 
-	CSimpleStringA csBinPath,csBackslash("\\");
-	ErrorCodeEnum eErrPath = GetEntityBase()->GetFunction()->GetPath("Bin", csBinPath);
-	if (eErrPath != Error_Succeed)
-	{
-		Dbg("GetBasePath failed (%d).",eErrPath);
-		return Error_Param;
-	}
 	//  [9/29/2019 14:13 @Gifur]
 	CloseAndClearDevObj(false);
 	m_hVerdorDll = LoadLibraryA(dllName);
 	Dbg("load vendor dll %s", (const char*)dllName);
 	if (m_hVerdorDll == NULL)
 	{
-		Dbg("Load dll failed.%d",GetLastError());
+		Dbg("Load dll failed.%d", GetLastError());
 		GetEntityBase()->GetFunction()->ShowFatalError("加载厂商适配器失败!请检查root.ini配置是否正确。");
 		return Error_DevLoadFileFailed;
 	}
-	if ((CreateDevComponent = (lpCreateDevCom)GetProcAddress(m_hVerdorDll,"CreateDevComponent")) == NULL)
+
+	if ((CreateDevComponent = (lpCreateDevCom)GetProcAddress(m_hVerdorDll, "CreateDevComponent")) == NULL)
 	{
 		Dbg("Get CreateDevComponent failed.");
 		return Error_DevLoadFileFailed;
 	}
-	if ((ReleaseDevComponent = (lpReleaseDevCom)GetProcAddress(m_hVerdorDll,"ReleaseDevComponent")) == NULL)
+
+	if ((ReleaseDevComponent = (lpReleaseDevCom)GetProcAddress(m_hVerdorDll, "ReleaseDevComponent")) == NULL)
 	{
 		Dbg("Get ReleaseDevComponent failed.");
 		return Error_DevLoadFileFailed;
 	}
 	Dbg("Get vendor function suc.");
+#else
+	Dbg("To test CardIssuer");
+	m_hVerdorDll = dlopen(dllName, RTLD_LAZY);
+	if (m_hVerdorDll == NULL)
+	{
+		Dbg("load failed:%s,%d,%s",(const char*)dllName,errno,strerror(errno));
+		return Error_DevLoadFileFailed;
+	}
+	CreateDevComponent = (lpCreateDevCom)dlsym(m_hVerdorDll, "CreateDevComponent");
+	if (CreateDevComponent == NULL)
+	{
+		Dbg("load CreateDevCom failed:");
+		return Error_DevLoadFileFailed;
+	}
+	ReleaseDevComponent = (lpReleaseDevCom)dlsym(m_hVerdorDll, "ReleaseDevComponent");
+	if (ReleaseDevComponent == NULL)
+	{
+		Dbg("load ReleaseDevComponent failed:");
+		return Error_DevLoadFileFailed;
+	}
+	Dbg("Get vendor function suc.");
+#endif
+	CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
+	CSmartPointer<IConfigInfo> spConfig;
+
+	CSimpleStringA csBinPath, csBackslash("\\");
+	ErrorCodeEnum eErrPath = GetEntityBase()->GetFunction()->GetPath("Bin", csBinPath);
+	if (eErrPath != Error_Succeed)
+	{
+		Dbg("GetBasePath failed (%d).", eErrPath);
+		return Error_Param;
+	}
 	for (int i = 0; i < 3; ++i)
 	{
 		m_CardBoxNoEx[i] = "";
@@ -1975,19 +1996,20 @@ ErrorCodeEnum CCardIssuerFSM::OpenDevice(BYTE btOpenType, const char *pDevSN)
 	do{
 		if (m_pCardIssuer == NULL)
 		{
-			if ((eErrDev = CreateDevComponent((DeviceBaseClass *&)m_pCardIssuer)) != Error_Succeed)
+			if ((eErrDev = CreateDevComponent((DeviceBaseClass*&)m_pCardIssuer)) != Error_Succeed)
 			{
 				LogErrMsg("OpenDevice:CreateDevComponent", eErrDev, MEC_DEV_OBJECT_CREATE_FAILED, TRUE);
 				initTries++;
+				m_pCardIssuer = NULL;
 				continue;
 			}
+			else
+				Dbg("CreateDevComponent suc.");
 		}
 		if(m_bUnbindType3) {
 			Dbg("Detect unbind type is true, return previously");
 			return Error_Cancel;
 		}
-		Dbg("Create vendor handle suc.");
-		CardIssuerClass* pxx = (CardIssuerClass*)m_pCardIssuer;
 		Dbg("Start to invoke DevOpenEx func with %d, %d, %s...", m_port, m_baudRate, pDevSN);
 		eErrDev = m_pCardIssuer->DevOpenEx(m_port, m_baudRate, btOpenType, pDevSN, m_connectType);
 		Dbg("DevOpenEx returned hr[%d], %d, connectType[%d]", eErrDev, btOpenType, m_connectType);
@@ -2053,14 +2075,6 @@ ErrorCodeEnum CCardIssuerFSM::OpenDevice(BYTE btOpenType, const char *pDevSN)
 					return Error_Unexpect;
 				}
 			}
-			//hr = m_pCardIssuer->Reset();
-			//Dbg("cardreader reset(%d)",hr);
-			//if (hr != Error_Succeed)
-			//{
-			//	DevErrorInfo devErrInfo;
-			//	m_pCardIssuer->GetLastErr(devErrInfo);
-			//	Dbg("reset err[%s]",devErrInfo.szErrMsg);
-			//}
 			if (!LoadCMBPrint(csBinPath))
 			{
 				Dbg("load CMBPrint failed.");
@@ -6932,6 +6946,7 @@ int CCardIssuerFSM::SplitDevModelInfo()
 
 void CCardIssuerFSM::CloseAndClearDevObj(bool bCheckConnecting, bool bCloseOnly)
 {
+	LOG_FUNCTION();
 	if(bCheckConnecting) {
 		Dbg("check connecting flag");
 	}

+ 4 - 0
Module/mod_cardissuer/CardIssuerFSM.h

@@ -953,7 +953,11 @@ protected:
 private:
 	///
 	int m_resetTimes;
+#ifdef RVC_OS_WIN
 	HMODULE m_hVerdorDll;
+#else
+	void* m_hVerdorDll;
+#endif
 	//GUIConsoleService_ClientBase *m_pGUIConsoleClient;
 	lpCreateDevCom CreateDevComponent;
 	lpReleaseDevCom ReleaseDevComponent;

+ 24 - 6
Module/mod_healthmanager/GuardianBase.h

@@ -2,7 +2,16 @@
 #define __GUARDIAN_BASE_H
 #pragma once
 
-#include "SpBase.h"
+//#include "SpBase.h"
+#include "ErrorCode.h"
+#ifdef linux
+//typedef unsigned long DWORD;
+//typedef char CHAR;
+//typedef char* PCHAR;
+//typedef bool BOOL;
+//typedef unsigned long long ULONGLONG;
+#else
+#endif
 enum WorkStateEnum
 {
 	WorkStateUpgrading=0,
@@ -15,6 +24,7 @@ enum GuardianOpEnum
 	GdOpShakeHand = 0,
 	GdOpUpdateTask,
 	GdOpQueryInstall,
+	GdOpUpgradeRestart,
 	GdOpFrameQuit,
 };
 enum GuardianStateEnum
@@ -27,6 +37,8 @@ enum GuardianStateEnum
 struct GuardianInfo
 {
 	GuardianOpEnum eType;
+	DWORD dwParam1;
+	DWORD dwParam2;
 	DWORD dwSize;//data size
 	PCHAR pData;
 };
@@ -35,17 +47,23 @@ const int DATA_BUFSIZE = 8192;
 extern "C" {
 #endif
 
-
-#ifdef GUARDIANBASE_EXPORTS
-#define GUARDIANBASE_API __declspec(dllexport)
+#if (defined(_WIN32) || defined(_WIN64))
+#   ifdef GUARDIANBASE_EXPORTS
+#       define GUARDIANBASE_API __declspec(dllexport)
+#   else
+#       define GUARDIANBASE_API __declspec(dllimport)
+#   endif
+#elif ( defined(__GNUC__) &&  __GNUC__ >= 4 )
+#   define GUARDIANBASE_API __attribute__((visibility("default")))
 #else
-#define GUARDIANBASE_API __declspec(dllimport)
+#   define GUARDIANBASE_API
 #endif
 
 GUARDIANBASE_API ErrorCodeEnum ShakeHands(WorkStateEnum &eState);
 GUARDIANBASE_API ErrorCodeEnum PushUpdateTask(const char *pszPackName);
 GUARDIANBASE_API bool IsInstalling();
-GUARDIANBASE_API ErrorCodeEnum FrameworkQuit(RebootTriggerEnum eReason);
+GUARDIANBASE_API ErrorCodeEnum UpgradeRestart(const DWORD dwParam1,const DWORD dwParam2);
+GUARDIANBASE_API ErrorCodeEnum FrameworkQuit(int eReason);
 
 
 #ifdef __cplusplus

+ 114 - 0
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -4,6 +4,9 @@
 #include <algorithm>
 #ifdef RVC_OS_WIN
 #include <io.h>
+#include "publicFunExport.h"
+#pragma comment(lib, "libpublicFun.lib")
+
 #else
 #include <unistd.h>
 #include <fcntl.h>
@@ -642,6 +645,7 @@ unsigned int CHealthManagerFSM::s4_on_event(FSMEvent* pEvt)
 				//LogEvent(Severity_Middle,EVENT_CONSOLE_REQ_RESTART_SHELL,"AccessAuth failed,to restart spshell.");
 				return 1;
 			}
+			ToLogWarnTermAboutInfo();
 			CSimpleStringA csTermStage;
 			ErrorCodeEnum eErrCode;
 			eErrCode = GetEntityBase()->GetFunction()->GetSysVar("TerminalStage",csTermStage);
@@ -744,6 +748,7 @@ unsigned int CHealthManagerFSM::s4_on_event(FSMEvent* pEvt)
 void CHealthManagerFSM::s5_on_entry()
 {
 	LOG_FUNCTION();
+	ToLogWarnTermAboutInfo();
 	m_fsmState = HM_FSM_STATE_FAULT;
 	CSmartPointer<IConfigInfo> spConfig,spConfigRun;
 	ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->OpenConfig(Config_Software, spConfig);
@@ -1523,7 +1528,10 @@ int CHealthManagerFSM::CheckLoadResult(LoadStage eStage)
 			if (it->second.eResult == LOADING_INIT)
 				return 3;
 			else if (it->second.eResult != LOADING_SUCCEED)
+			{
+				m_csErrEntity = it->first;
 				ret = 2;
+			}
 			break;
 		}
 		it++;
@@ -1934,6 +1942,44 @@ CSimpleStringA CHealthManagerFSM::QueryCheckCode()
 	}
 	return tmpCheckCode;
 }
+CSimpleStringA CHealthManagerFSM::QueryPinPadSM3DesInfo()
+{
+	ErrorCodeEnum eErr = Error_Unexpect;
+	CSimpleStringA sm3desInfo("support:");
+	PinPadService_ClientBase* pClient = new PinPadService_ClientBase(this->m_pEntity);
+	if (pClient != NULL)
+	{
+		eErr = pClient->Connect();
+		if (eErr == Error_Succeed)
+		{
+			PinPadService_QueryFunc_Req reqQ;
+			PinPadService_QueryFunc_Ans ansQ;
+			eErr = pClient->QueryFunc(reqQ, ansQ, 5000);
+			if (eErr == Error_Succeed)
+			{
+				Dbg("support:%d,loaded:%d",ansQ.encryptkey,ansQ.reserved1);
+				if (ansQ.encryptkey == 3)
+					sm3desInfo += "sm3des";
+				else if((ansQ.encryptkey == 2))
+					sm3desInfo += "sm";
+				else
+					sm3desInfo += "3des";
+				sm3desInfo += ",loadkey:";
+				if (ansQ.reserved1 == 3)
+					sm3desInfo += "sm3des";
+				else if ((ansQ.reserved1 == 2))
+					sm3desInfo += "sm";
+				else
+					sm3desInfo += "3des";
+			}
+			else
+				Dbg("QueryFunc failed.error code:%d", eErr);
+		}
+		else
+			Dbg("connect to pinpad failed.error code:%d", eErr);
+	}
+	return sm3desInfo;
+}
 void CHealthManagerFSM::DeviceReConnect()
 {
 	//if haven't called access auth ever or in the 1st accessauth processing,no need to call access auth
@@ -2007,4 +2053,72 @@ void CHealthManagerFSM::PostProcessAfterUpgrade()
 			}
 		}
 	}
+}
+CSimpleStringA GetOsVersion()
+{
+#ifdef RVC_OS_WIN
+	char   psBuffer[128];
+	FILE* pPipe;
+
+	/* Run DIR so that it writes its output to a pipe. Open this
+	 * pipe with read text attribute so that we can read it
+	 * like a text file.
+	 */
+
+	if ((pPipe = _popen("ver", "rt")) == NULL)
+		exit(1);
+
+	/* Read pipe until end of file, or an error occurs. */
+
+	while (fgets(psBuffer, 128, pPipe))
+	{
+		//puts(psBuffer);
+	}
+
+	Dbg("%s", psBuffer);
+	/* Close pipe and print return value of pPipe. */
+	if (feof(pPipe))
+	{
+		printf("\nProcess returned %d\n", _pclose(pPipe));
+	}
+	else
+	{
+		printf("Error: Failed to read the pipe to the end.\n");
+	}
+	string str(psBuffer);
+	int start = str.find("°æ±¾");
+	if (start > 0)
+		return CSimpleStringA(str.substr(start + 5, str.length() - start - 7).c_str());
+	else
+		return "";
+#else
+	//oiltestlinux
+	return "";
+#endif
+}
+void CHealthManagerFSM::ToLogWarnTermAboutInfo()
+{
+	LOG_FUNCTION();
+	CSmartPointer<IConfigInfo> spConfigRoot;
+	GetEntityBase()->GetFunction()->OpenConfig(Config_Root, spConfigRoot);
+	CSimpleStringA csEnvCamera(""),csOptCamera,csOSVerion;
+	spConfigRoot->ReadConfigValue("Video", "EnvCamera", csEnvCamera);
+	spConfigRoot->ReadConfigValue("Video", "OptCamera", csOptCamera);
+	std::map<std::string, std::string> termInfo;
+	termInfo["version"] = m_sysInfo.InstallVersion.ToString();
+	if (!m_csErrEntity.IsNullOrEmpty())
+		termInfo["ErrEntity"] = m_csErrEntity;
+	termInfo["EnvCamera"] = csEnvCamera;
+	termInfo["OptCamera"] = csOptCamera;
+	csOSVerion = GetOsVersion();
+	if (!csOSVerion.IsNullOrEmpty())
+		termInfo["OSVersion"] = csOSVerion;
+	termInfo["pinpad"] = QueryPinPadSM3DesInfo();
+	Dbg("%s,%s", termInfo["ErrEntity"].c_str(), termInfo["pinpad"].c_str());
+	//oiltestlinux as publicfucn have not been moved to linux
+	//std::pair<bool, std::string> strResult;
+	//strResult = generateJsonStr(termInfo);
+	//strResult.second.c_str();
+	//Dbg("[%s]", strResult.second.c_str());
+	//LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_HEALTH_UPLOAD_INFO_ABOUT_TERM, strResult.second.c_str());
 }

+ 4 - 2
Module/mod_healthmanager/HealthManagerFSM.h

@@ -185,7 +185,7 @@ public:
 	,m_bAccessAuth(false),m_bACFailed(false),m_pInitClient(NULL),m_bInitSuc(false),m_bInitFail(false)
 	, m_bIdleToMaintain(false), m_custMngerState(0), m_pDevCtrlClient(NULL), m_bHasAuthEver(false)
 	, m_checkCode(""), m_accessAuthCheckMD5(0), m_havReceiveMD5OK(0), m_bFirstAccessAuth(true), m_bEverAuthSucWithDevice(false)
-	, m_bIEBeforeHealth(false), m_hasCfgGpioInRootIni(false){}
+	, m_bIEBeforeHealth(false), m_hasCfgGpioInRootIni(false), m_csErrEntity(""){}
 	~CHealthManagerFSM(){}
 	virtual ErrorCodeEnum OnInit();
 	virtual ErrorCodeEnum OnExit();
@@ -263,6 +263,7 @@ public:
 		}
 	}
 	CSimpleStringA QueryCheckCode();
+	CSimpleStringA QueryPinPadSM3DesInfo();
 	void DeviceReConnect();
 	bool IfIEBeforeHealth(){ return m_bIEBeforeHealth; }
 	int QuitFrameworkAndSaveInfo(RebootTriggerEnum eTrigger, RebootWayEnum eWay = RebootWay_Unknown);
@@ -277,9 +278,10 @@ private:
 	virtual void OnAnswer(CSmartPointer<IAsynWaitSp> pAsynWaitSp);
 	int DoInitialization();
 	void ToCheckUPS();
+	void ToLogWarnTermAboutInfo();
 private:
 	LoadStage m_eStage;
-	CSimpleStringA m_SysState,m_strURL,m_strURLValue,m_checkCode;
+	CSimpleStringA m_SysState,m_strURL,m_strURLValue,m_checkCode,m_csErrEntity;
 	map<int,int> m_enOpt;//entity option
 	vector<CSimpleStringA> m_vCoreBoot,m_vSafeLoad,m_vOperating;
 	map<CSimpleStringA,EntityLoadInfo> m_coreBootOpt;

+ 1 - 1
Tool/guardian/guardian.cpp

@@ -1,6 +1,6 @@
 // guardian.cpp : Defines the entry point for the console application.
 //
-#include "stdafx.h"
+//#include "stdafx.h"
 #ifdef linux
 #include <sys/types.h>
 #include <sys/stat.h>