|
@@ -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");
|
|
|
}
|