Bladeren bron

Z991239-3333 #comment other: 读卡器模块日志及错误码

翟俊伟80258120 3 jaren geleden
bovenliggende
commit
625ee4fc08

+ 89 - 0
Module/include/DevFSMCommBase.hpp

@@ -3,8 +3,10 @@
 
 #include "DevEntityCommBase.hpp"
 #include "SpFSM.h"
+#include "RVCComm.h"
 #include "DevErrorCode.h"
 #include "DeviceBaseClass.h"
+#include "publicFunExport.h"
 
 #if DEVICE_BASE_INTERFACE_FILE_VERSION == 2
 using DevAdaptObjCreateFunc = ErrorCodeEnum(*)(DWORD dwDevClassID, DeviceBaseClass * &pOutDevAptObj);
@@ -145,6 +147,18 @@ static const char* VendorNameStr[] = {
 	"hx"
 };
 
+static std::map<CSimpleStringA, DWORD> WarnCodeMap = {
+	{"CardIssuer", 0x2030021f},
+	{"ContactlessCard", 0x21300203},
+	{"CardSwiper", 0x20200207},
+	{"FingerPrint", 0x20400211},
+	{"IDCertificate", 0x20100202},
+	{"PinPad", 0x20600207},
+	{"Gpio", 0x20900201},
+	{"HSPScanner", 0x21700207},
+	{"WatchDog", 0x20d00201},
+	{"Ups", 0x20e00201}
+};
 
 inline static VendorNameType GetCurVendorType(LPCTSTR vendorName)
 {
@@ -322,6 +336,12 @@ private:
 	TSubAdpt* m_AdptObjPtr;
 };
 
+struct AdapterInfo
+{
+	CSimpleStringA adapterFileName;
+	DevCategoryInfo devCatInfo;
+};
+
 struct ErrorPackage {
 
 	CSimpleStringA msgHead;
@@ -418,11 +438,68 @@ public:
 		return dwCode;
 	}
 
+	void ToLogWarnInfoAboutTerm(FSMBase* pFSM, AdapterInfo adapterInfo)
+	{
+		CSmartPointer<IConfigInfo> spConfigRoot;
+		pFSM->GetEntityBase()->GetFunction()->OpenConfig(Config_Root, spConfigRoot);
+
+		CSimpleStringA entityName = CSimpleStringA::Format("%s", pFSM->GetEntityBase()->GetEntityName());
+		CSimpleStringA sectionName = CSimpleStringA::Format("Device.%s", entityName.GetData());
+		CSimpleStringA csPort(true), csBaudrate(true);
+		spConfigRoot->ReadConfigValue(sectionName.GetData(), "Port", csPort);
+		spConfigRoot->ReadConfigValue(sectionName.GetData(), "Port", csBaudrate);
+
+		//calculate file hash value
+		std::map<std::string, std::string> termInfo;
+		char* strFileHash = new char[128];
+		ZeroMemory(strFileHash, 128);
+		BYTE fileHash[32];
+		SM3File(const_cast<char*>(adapterInfo.adapterFileName.GetData()), fileHash);
+		HexBuf2StrBuf(fileHash, &strFileHash, 32);
+
+		//calculate file size
+		struct stat statbuf;
+		ZeroMemory(&statbuf, sizeof(statbuf));
+		stat(adapterInfo.adapterFileName.GetData(), &statbuf);
+		int fileSize = statbuf.st_size;
+
+		//necessary elements about adapter
+		CSimpleStringA csPortNum(true), csCheckData(true), csKeySN(true);
+		termInfo["VendorDllName"] = adapterInfo.adapterFileName;
+		termInfo["VendorDllFileHash"] = strFileHash;
+		ZeroMemory(strFileHash, 128);
+		termInfo["VendorDllFileSize"] = _itoa(fileSize, strFileHash, 10);
+		termInfo["szModel"] = adapterInfo.devCatInfo.szModel;
+		termInfo["szType"] = adapterInfo.devCatInfo.szType;
+		termInfo["Port"] = csPort;
+		termInfo["Baudrate"] = csBaudrate;
+		if (!entityName.Compare("Gpio")) {
+			spConfigRoot->ReadConfigValue(sectionName.GetData(), "PortNum", csPortNum);
+			termInfo["PortNum"] = csPortNum;
+		}
+		else if (!entityName.Compare("PinPad")) {
+			spConfigRoot->ReadConfigValue(sectionName.GetData(), "CheckData", csCheckData);
+			spConfigRoot->ReadConfigValue(sectionName.GetData(), "Keysn", csKeySN);
+		}
+		std::pair<bool, std::string> strResult;
+		strResult = generateJsonStr(termInfo);
+		strResult.second.c_str();
+
+		if (!entityName.IsNullOrEmpty())
+		{
+			LogWarn(Severity_Low, Error_Unexpect, WarnCodeMap[entityName], strResult.second.c_str());
+		}
+		else {
+			Dbg("Entity Name is empty, please check!!!");
+		}
+		return;
+	}
 
 protected:
 
 	DevAdptLibHelper<TDevClass> m_hDevHelper;
 	DevEntityErrorCode m_entCode;
+	BOOL m_FirstStart;
 	CSimpleStringA m_csAlarmMsg = "No more information";
 
 	void UpdateEntityIDIfZero()
@@ -505,6 +582,18 @@ protected:
 		return ((dwVal >> 20) == m_entCode.dwEntityId);
 	}
 
+	int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len)
+	{
+		char* tmpStr = *strBuf;
+		int count = 0;
+		for (int i = 0; i < len; ++i)
+		{
+			sprintf(tmpStr + count, "%0.2X", hexBuf[i]);
+			count += 2;
+		}
+		return 0;
+	}
+
 	void LogErrMsg(const char* pMsgHead, ErrorCodeEnum eErrCode, DWORD defaultDevCode = 0, BOOL bAlarm = FALSE);
 	void LogErrMsgEx(ErrorPackage errPkg, const char* pMsgBody, DWORD finalErrCode /*= 0*/, BOOL bToBusiness = FALSE);
 };

+ 144 - 58
Module/mod_CardReadAdapter/CardReadAdapterFSM.cpp

@@ -110,45 +110,11 @@ void CCardReadAdapterFSM::s2_on_entry()
 {
 	LOG_FUNCTION();
 	GetEntityBase()->GetFunction()->SetUserDefineState(USER_CARDISSUER_IDLE);
-	Dbg("set reset times 0.");
 	m_resetTimes = 0;
 	m_testResult = Error_Succeed;
 	m_bIssuingExit = false;
 	m_bCancelAccept = false;
 	m_lastS2Event = m_lastS2EvtParam1 = 0;
-	//oiltmp 测试便携厂商发卡
-	//m_pCardIssuer->SetIssuerCounter(0, 1);
-	//m_pCardIssuer->MoveCard(CI_MOVECARD_FROM_HOPPER);
-	//MagTracks magTracks;
-	//magTracks.eRange = CI_TRACK_RANGE_2_3;
-	//m_pCardIssuer->MagRead(magTracks);
-	//Dbg("%s,%d,%d", magTracks.track[1].data, magTracks.track[1].dwSize, magTracks.track[1].eStatus);
-	//m_pCardIssuer->MoveCard(CI_MOVECARD_FRONT_GATE);
-
-
-	//ErrorCodeEnum err = m_pIDCard->SetCardInType(CARD_IN_TYPE_ALL);
-	//Dbg("accept[%d]",err);
-	//Sleep(WAIT_INTERVAL*10);
-	//LPCardAccount* ppCardAccount;
-	////err = m_pIDCard->GetCardAccount(IDC_TRACK_1|IDC_TRACK_2|IDC_TRACK_3,&ppCardAccount);
-	////Dbg("read[%d]",err);
-	////Dbg("%d,%d,%d",ppCardAccount[0]->dataStatus,(ppCardAccount[1])->dataStatus,(ppCardAccount[2])->dataStatus);//,pCardAccount->data);
-	////Dbg("%d,%d,%d",ppCardAccount[0]->length,(ppCardAccount[1])->length,(ppCardAccount[2])->length);//,pCardAccount->data);
-	////Dbg("read data[%s][%s][%s]",(char*)(ppCardAccount[0]->data),(char*)(ppCardAccount[1]->data),(char*)(ppCardAccount[2]->data));
-
-	//err =  m_pIDCard->DectectCardType(m_cardType);
-	//Dbg("detectcardtyp[%d][%d]",err,m_cardType);
-	//err = m_pIDCard->ActiveCard();
-	//Dbg("activecard[%d]",err);
-	//vector<AIDData> vAIDs;
-	//MessageBoxA(0,0,0,0);
-	//if (m_cardType == CARDTYPE_CPU_T0 || m_cardType == CARDTYPE_CPU_T1)
-	//{
-	//	BuildSupportedAppList(vAIDs);
-	//	Dbg("[%s]",testIC);
-	//	AppSelected(m_vADFRec.at(0).name,m_vADFRec.at(0).nameLen);
-	//}
-
 }
 void CCardReadAdapterFSM::s2_on_exit()
 {
@@ -188,7 +154,7 @@ unsigned int CCardReadAdapterFSM::s2_on_event(FSMEvent* pEvt)
 				{
 					bContactlessCard = true;
 					GetEntityBase()->GetFunction()->PostThreadPoolTask(cTask);
-					Dbg("to ContactlessCard");
+					Dbg("ReadTask to ContactlessCard");
 				}
 			}
 			//oilyang@20200730 according to meeting with Ratail/Test/Hangzhou 
@@ -205,7 +171,7 @@ unsigned int CCardReadAdapterFSM::s2_on_event(FSMEvent* pEvt)
 				{
 					bCardSwiper = true;
 					GetEntityBase()->GetFunction()->PostThreadPoolTask(sTask);
-					Dbg("to CardSwiper");
+					Dbg("ReadTask to CardSwiper");
 				}
 			}
 			//oilyang@20200426 暂时未发现这行代码的用处,可能简版?后来废弃。暂时保留,后续考虑去掉
@@ -217,13 +183,13 @@ unsigned int CCardReadAdapterFSM::s2_on_event(FSMEvent* pEvt)
 				{
 					bCardIssuer = true;
 					GetEntityBase()->GetFunction()->PostThreadPoolTask(iTask);
-					Dbg("to CardIssuer");
+					Dbg("ReadTask to CardIssuer");
 				}
 				if (bCardIssuer || bCardSwiper || bContactlessCard)
-					Dbg("bCardIssuer,bCardSwiper,bContactlessCard:%d,%d,%d", bCardIssuer, bCardSwiper, bContactlessCard);
+					Dbg("ReadTask, bCardIssuer,bCardSwiper,bContactlessCard:%d,%d,%d", bCardIssuer, bCardSwiper, bContactlessCard);
 				else
 				{
-					Dbg("can't find the right entity.");
+					Dbg("ReadTask: can't find the right entity.");
 					ret = 1;//no need to change to "Working" state
 					cre->ctx->Answer(Error_Unexpect);
 				}
@@ -816,7 +782,7 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
 			}
 		}
 		else {
-			Dbg("CardIssuer QueryCardInfo return:", eErr);
+			Dbg("CardIssuer QueryCardInfo failed return:", eErr);
 			return 1;//oilyang@20190709
 		}
 		if (bHasCard && bNeedPreOnline)
@@ -839,10 +805,13 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
 					eErr = m_pCardIssuer->SetSomeFlag(ssfReq, ssfAns, 5000, dwUsrErrCode);
 					if (eErr == Error_Succeed)
 						ctx->Ans.ICCardNo = ssfAns.reserved2[0];
+					else
+						Dbg("CardIssuer SetSomeFlag failed return:%d", eErr);
 				}
 			}
 			else
 			{
+				Dbg("CardIssuer PreOnline failed return:%d", eErr);
 				ctx->Ans.result = "";
 				ctx->Ans.status = -1;
 			}
@@ -851,7 +820,7 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
 		}
 		if (bHasCard)
 		{
-			Dbg("%d", eErr);
+			Dbg("ReadCard, the final errCode:%d", eErr);
 			ctx->Answer(eErr, dwUsrErrCode);
 		}
 		return 0;
@@ -924,7 +893,7 @@ int CCardReadAdapterFSM::ContactlessCardRead(SpReqAnsContext<CardReadAdapterServ
 				else if (eErr == Error_Unexpect)
 				{
 					ctx->Answer(eErr);
-					Dbg("read failed.");
+					Dbg("ContactlessCard read failed.");
 					return 2;
 				}
 		//	}
@@ -938,7 +907,7 @@ int CCardReadAdapterFSM::ContactlessCardRead(SpReqAnsContext<CardReadAdapterServ
 			req.businessData = ctx->Req.businessData;
 			BroadcastReadICing(0);
 			eErr = m_pContactless->PreOnline(req, ans, 50000);
-			Dbg("PreOnline result:%d", eErr);
+			Dbg("ContacelssCard PreOnline result:%d", eErr);
 			if (eErr == Error_Succeed)
 			{
 				ctx->Ans.result = ans.result;
@@ -991,6 +960,9 @@ int CCardReadAdapterFSM::IssueCard(SpReqAnsContext<CardReadAdapterService_Issue_
 			Dbg("req.hopper:%d Deem that CardIssuer has card after issuing succ. Set busCtx:findCard:%d,cardPos:%d"
 				, req.hopper, ans.reserved1[0], ans.reserved1[1]);
 		}
+		else {
+			Dbg("CardIssuer IssueCard failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 		return 0;
 	}
@@ -1026,9 +998,8 @@ int CCardReadAdapterFSM::CardSwiperRead(SpReqAnsContext<CardReadAdapterService_R
 			req.LightPos += 2;
 		if ((ctx->Req.lightPos&LightPos_CardSwiper_RFIC) == LightPos_CardSwiper_RFIC)
 			req.LightPos += 4;
-		Dbg("aid:%s,lightPos:%d",(const char*)req.aid,req.LightPos);
+		Dbg("CardSwiperRead, aid:%s,lightPos:%d",(const char*)req.aid,req.LightPos);
 		eErr = m_pCardSwiper->Read(req, ans, 61000);
-		Dbg("eErr:%d", eErr);
 		eRetErr = eErr;
 		if (eErr == Error_Succeed)
 		{
@@ -1060,7 +1031,7 @@ int CCardReadAdapterFSM::CardSwiperRead(SpReqAnsContext<CardReadAdapterService_R
 			ctx->Ans.t2CardSerial = ans.t2CardSerial;
 			ctx->Ans.t2CVC = ans.t2CVC;
 			ctx->Ans.t2ExpireDate = ans.t2ExpireDate;
-			Dbg("ICType:%d,%d,%s****%s", ctx->Ans.ICType, ans.ICType,(const char*)ctx->Ans.t2Account.SubString(0, 4), (const char*)ctx->Ans.t2Account.SubString(ctx->Ans.t2Account.GetLength() - 4, 4));
+			Dbg("ICType:%d,%d, accountNo:%s****%s", ctx->Ans.ICType, ans.ICType,(const char*)ctx->Ans.t2Account.SubString(0, 4), (const char*)ctx->Ans.t2Account.SubString(ctx->Ans.t2Account.GetLength() - 4, 4));
 			if (ans.ICType == 3 || ans.ICType == 4)
 			{
 				CardSwiperService_PreOnline_Req req;
@@ -1072,10 +1043,15 @@ int CCardReadAdapterFSM::CardSwiperRead(SpReqAnsContext<CardReadAdapterService_R
 				{
 					ctx->Ans.result = ans.result;
 				}
-				else
+				else {
+					Dbg("CardSwiper PreOnline failed return:%d", eErr);
 					ctx->Ans.result = "";
+				}
 			}
 		}
+		else {
+			Dbg("CardSwiper Read failed return:%d", eErr);
+		}
 		if (eErr == Error_TimeOut)
 		{
 			Dbg("CardSwiper timeout.");
@@ -1190,6 +1166,9 @@ int CCardReadAdapterFSM::PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnl
 		{
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg("PreOnline, CardIssuer PreOnline failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else if (IsTheEntity(ctx->Req.module, Module_ContactlessCard) && IsContactlessCardSessionOK() && m_busCtx.eCardFromWhich == Card_In_ContactlessCard)
@@ -1204,6 +1183,9 @@ int CCardReadAdapterFSM::PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnl
 		{
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg(CSimpleStringA::Format("PreOnline, ContactlessCard PreOnline failed return:%d", eErr));
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
@@ -1218,6 +1200,9 @@ int CCardReadAdapterFSM::PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnl
 		{
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg("PreOnline, CardSwiper PreOnline failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	return 0;
@@ -1225,7 +1210,7 @@ int CCardReadAdapterFSM::PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnl
 int CCardReadAdapterFSM::PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-	Dbg("ctx->Req.module:%d,cardIn(Iss 1,RF 2):%d",ctx->Req.module, m_busCtx.eCardFromWhich);
+	Dbg("<PostOnline>, ctx->Req.module:%d,cardIn(Iss 1,RF 2):%d", ctx->Req.module, m_busCtx.eCardFromWhich);
 	ErrorCodeEnum eErr = Error_Unexpect;
 	DWORD dwUsrErrCode = 0;
 	if (IsTheEntity(ctx->Req.module, Module_CardIssuer) && IsCardIssuerSessionOK() && m_busCtx.eCardFromWhich == Card_In_CardIssuer)
@@ -1238,6 +1223,9 @@ int CCardReadAdapterFSM::PostOnline(SpReqAnsContext<CardReadAdapterService_PostO
 		{
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg("PostOnline, CardIssuer PostOnline failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else if (IsTheEntity(ctx->Req.module, Module_ContactlessCard) && IsContactlessCardSessionOK() && m_busCtx.eCardFromWhich == Card_In_ContactlessCard)
@@ -1250,6 +1238,9 @@ int CCardReadAdapterFSM::PostOnline(SpReqAnsContext<CardReadAdapterService_PostO
 		{
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg("PostOnline, ContactlessCard PostOnline failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
@@ -1262,6 +1253,9 @@ int CCardReadAdapterFSM::PostOnline(SpReqAnsContext<CardReadAdapterService_PostO
 		{
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg("PostOnline, CardSwiper PostOnline failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	return 0;
@@ -1282,6 +1276,9 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
 			Dbg("CardIssuer EjectCard suc.");
 		}
+		else {
+			Dbg("EjectCard, CardIssuer EjectCard failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else if (IsTheEntity(ctx->Req.module, Module_ContactlessCard) && IsContactlessCardSessionOK() && m_busCtx.eCardFromWhich == Card_In_ContactlessCard)
@@ -1294,6 +1291,9 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
 			Dbg("ContactlessCard EjectCard suc.");
 		}
+		else {
+			Dbg("EjectCard, ContactlessCard EjectCard failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
@@ -1306,11 +1306,14 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
 			Dbg("CardSwiper EjectCard suc.");
 		}
+		else {
+			Dbg("EjectCard, CardSwiper EjectCard failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else
 	{
-		Dbg("nothing to do.");
+		Dbg("EjectCard, nothing to do.");
 		ctx->Answer(Error_NotExist);
 	}
 	return 0;
@@ -1327,14 +1330,17 @@ int CCardReadAdapterFSM::CaptureCard(SpReqAnsContext<CardReadAdapterService_Capt
 		eErr = m_pCardIssuer->Capture(req, ans, 15000, dwUsrErrCode);
 		if (eErr == Error_Succeed)
 		{
-			Dbg("Capture card suc.");
+			Dbg("CardIssuer Capture card suc.");
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
 		}
+		else {
+			Dbg("CaptureCard, CardIssuer Capture failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 	}
 	else
 	{
-		Dbg("Something wrong.the module(%d),cardinwhere(%d)", ctx->Req.module, m_busCtx.eCardFromWhich);
+		Dbg("CaptureCard, Something wrong.the module(%d),cardinwhere(%d)", ctx->Req.module, m_busCtx.eCardFromWhich);
 		ctx->Answer(eErr);
 	}
 	return 0;
@@ -1363,6 +1369,9 @@ int CCardReadAdapterFSM::QueryCardInfo(SpReqAnsContext<CardReadAdapterService_Qu
 				break;
 			}
 		}
+		else {
+			Dbg("QueryCardInfo, CardIssuer QueryCardInfo failed return:%d", eErr);
+		}
 	}
 	if (IsTheEntity(ctx->Req.module, Module_ContactlessCard) && IsContactlessCardSessionOK() && m_busCtx.eCardFromWhich == Card_In_ContactlessCard)
 	{
@@ -1384,8 +1393,10 @@ int CCardReadAdapterFSM::QueryCardInfo(SpReqAnsContext<CardReadAdapterService_Qu
 				break;
 			}
 		}
-		else
+		else {
+			Dbg("QueryCardInfo, ContactlessCard QueryCardInfo failed return:%d", eErr);
 			ctx->Ans.ContactlessCardPos = -1;
+		}
 	}
 	if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
 	{
@@ -1412,11 +1423,14 @@ int CCardReadAdapterFSM::QueryCardInfo(SpReqAnsContext<CardReadAdapterService_Qu
 				break;
 			}
 		}
-		else
+		else {
+			Dbg("QueryCardInfo, CardSwiper QueryCardInfo failed return:%d", eErr);
 			ctx->Ans.CardSwiperPos = -1;
+		}
 	}
 	ctx->Answer(Error_Succeed);
-	Dbg("%d,position(CI,CC,CS) %d,%d,%d", m_busCtx.eCardFromWhich, ctx->Ans.CardIssuerPos, ctx->Ans.ContactlessCardPos, ctx->Ans.CardSwiperPos);
+	Dbg("<QueryCardInfo>, CardFromWhich:%d, position(CI,CC,CS) %d,%d,%d",
+		m_busCtx.eCardFromWhich, ctx->Ans.CardIssuerPos, ctx->Ans.ContactlessCardPos, ctx->Ans.CardSwiperPos);
 	return 0;
 }
 void CCardReadAdapterFSM::CheckAndReconnectSession()
@@ -1617,6 +1631,9 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
 			csCIVersion = ans.version;
 			ciState = ans.state;
 		}
+		else {
+			Dbg("GetDevInfo, CardIssuer GetDevInfo failed return:%d", eErr);
+		}
 	}
 	if (IsTheEntity(ctx->Req.module, Module_ContactlessCard) && IsContactlessCardSessionOK())
 	{
@@ -1632,6 +1649,9 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
 			csCCVersion = ans.version;
 			ccState = ans.state;
 		}
+		else {
+			Dbg("GetDevInfo, ContactlessCard GetDevInfo failed return:%d", eErr);
+		}
 	}
 	if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
 	{
@@ -1648,6 +1668,9 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
 			csState = ans.state;
 		}
 	}
+	else {
+		Dbg("GetDevInfo, CardSwiper GetDevInfo failed return:%d", eErr);
+	}
 	ctx->Ans.ModuleNum = count;
 	ctx->Ans.ModuleSN.Init(count);
 	ctx->Ans.type.Init(count);
@@ -1723,8 +1746,10 @@ int CCardReadAdapterFSM::GetMaterialCount(SpReqAnsContext<CardReadAdapterService
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 			ctx->Answer(Error_Succeed);
 		}
-		else
+		else {
+			Dbg("GetMaterialCount, CardIssuer GetMaterialCountEx failed return:%d", eErr);
 			ctx->Answer(Error_Unexpect, dwUsrErrCode);
+		}
 	}
 	else
 	{
@@ -1763,8 +1788,10 @@ int CCardReadAdapterFSM::SetMaterialCount(SpReqAnsContext<CardReadAdapterService
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 			ctx->Answer(Error_Succeed);
 		}
-		else
+		else {
+			Dbg("SetMaterialCount, CardIssuer SetMaterialCountEx failed return:%d", eErr);
 			ctx->Answer(Error_Unexpect, dwUsrErrCode);
+		}
 	}
 	else
 	{
@@ -1788,6 +1815,9 @@ int CCardReadAdapterFSM::GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSC
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("GetSCIInfo, CardIssuer GetSCIInfo failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -1813,6 +1843,9 @@ int CCardReadAdapterFSM::OpenSafeLock(SpReqAnsContext<CardReadAdapterService_Ope
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("OpenSafeLock, CardIssuer OpenSafeLock failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -1837,6 +1870,9 @@ int CCardReadAdapterFSM::MagTransferInit(SpReqAnsContext<CardReadAdapterService_
 			ctx->Ans.ex = ans.ex;
 			ctx->Ans.result = ans.result;
 		}
+		else {
+			Dbg("MagTransferInit, CardSwiper MagTransferInit failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -1860,6 +1896,9 @@ int CCardReadAdapterFSM::QueryConnInfo(SpReqAnsContext<CardReadAdapterService_Qu
 			ctx->Ans.reserved1 = ans.reserved1;
 			ctx->Ans.reserved2 = ans.reserved2;
 		}
+		else {
+			Dbg("QueryConnInfo, CardSwiper QueryConnInfo failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -1889,6 +1928,7 @@ void CCardReadAdapterFSM::BroadcastReadICing(int status)
 {
 	ReadICing evt;
 	evt.status = status;
+	Dbg("BroadcastReadICing, status:%d", status);
 	SpSendBroadcast(GetEntityBase()->GetFunction(), SP_MSG_OF(ReadICing), SP_MSG_SIG_OF(ReadICing), evt);
 }
 int CCardReadAdapterFSM::SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx)
@@ -1911,6 +1951,10 @@ int CCardReadAdapterFSM::SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAM
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("SAMICCommand, CardIssuer SAMICCommand failed return:%d", eErr);
+
+		}
 		ctx->Answer(eErr);
 		return 0;
 	}
@@ -1941,6 +1985,9 @@ int CCardReadAdapterFSM::QueryPrinterStatus(SpReqAnsContext<CardReadAdapterServi
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("QueryPrinterStatus, CardIssuer QueryPrinterStatus failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 		return 0;
 	}
@@ -1973,6 +2020,9 @@ int CCardReadAdapterFSM::Print(SpReqAnsContext<CardReadAdapterService_Print_Req,
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("Print, CardIssuer Print failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 		return 0;
 	}
@@ -2014,6 +2064,9 @@ int CCardReadAdapterFSM::QuerySCIList(SpReqAnsContext<CardReadAdapterService_Que
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("QuerySCIList, CardIssuer QuerySCIList failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 		return 0;
 	}
@@ -2043,6 +2096,9 @@ int CCardReadAdapterFSM::BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 		}
+		else {
+			Dbg("BindSCI, CardIssuer BindSCI failed return:%d", eErr);
+		}
 		ctx->Answer(eErr, dwUsrErrCode);
 		return 0;
 	}
@@ -2069,6 +2125,18 @@ int CCardReadAdapterFSM::PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService
 		req.reserved2.Copy(ctx->Req.reserved2);
 		req.reserved3.Copy(ctx->Req.reserved3);
 		req.reserved4.Copy(ctx->Req.reserved4);
+		CSimpleStringA inParam("");
+		if (!req.account.IsNullOrEmpty() && req.account.GetLength() > 10)
+		{
+			inParam = CSimpleStringA::Format("account:%s****%s, bussinessDataLen:%d, slot:%d, termNo:%s",
+				req.account.SubString(0, 6).GetData(), req.account.SubString(req.account.GetLength() - 4, 4).GetData(), req.businessData.GetLength(), req.slot, req.termNo.GetData());
+		}
+		else {
+			inParam = CSimpleStringA::Format("accountLen:%d, bussinessDataLen:%d, slot:%d, termNo:%s",
+				req.account.GetLength(), req.businessData.GetLength(), req.slot, req.termNo.GetData());
+		}
+		LogWarn(Severity_Low, Error_Unexpect, CardReadAdapter_UserErrorCode_PreOnline_Invoke, inParam.GetData());
+		
 		eErr = m_pCardIssuer->PreOnlineOnStore(req, ans, 63000);
 		if (eErr == Error_Succeed)
 		{
@@ -2079,12 +2147,18 @@ int CCardReadAdapterFSM::PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
+			CSimpleStringA outParam = CSimpleStringA::Format("cardPos:%d, findCard:%d, resultLen:%d",
+				ctx->Ans.cardPos, ctx->Ans.findCard, ctx->Ans.result.GetLength());
+			LogWarn(Severity_Low, Error_Unexpect, CardReadAdapter_UserErrorCode_PreOnline_Result, outParam.GetData());
+		}
+		else {
+			Dbg("PreOnlineOnStore, CardIssuer PreOnlineOnStore failed return:%d", eErr);
 		}
 		ctx->Answer(eErr);
 	}
 	else
 	{
-		Dbg("Entity CardIssuer is not ok.");
+		LogError(Severity_High, Error_Unexpect, CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok, "Entity CardIssuer is not ok.");
 		ctx->Answer(Error_Unexpect);
 	}
 	return 0;
@@ -2115,6 +2189,9 @@ int CCardReadAdapterFSM::NotifyPreonline(SpReqAnsContext<CardReadAdapterService_
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
 		}
+		else {
+			Dbg("NotifyPreonline, CardIssuer NotifyPreonline failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -2147,6 +2224,9 @@ int CCardReadAdapterFSM::QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterSer
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
 		}
+		else {
+			Dbg("QueryCardInfoOnStore, CardIssuer QueryCardInfoOnStore failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -2181,6 +2261,9 @@ int CCardReadAdapterFSM::GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_G
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
 		}
+		else {
+			Dbg("GetAddCardInfo, CardIssuer GetAddCardInfo failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 	}
 	else
@@ -2347,7 +2430,7 @@ int CCardReadAdapterFSM::PrintCardIm(SpReqAnsContext<CardReadAdapterService_Prin
 		int timeout = 60000;
 		if (ctx->Req.reserved1.GetCount() > 0 && ctx->Req.reserved1[0] > 50000 && ctx->Req.reserved1[0] < 200000)
 			timeout = ctx->Req.reserved1[0];
-		Dbg("timeout:%d",timeout);
+		Dbg("PrintCardIm, timeout:%d",timeout);
 		eErr = m_pCardIssuer->PrintCardImmediately(req, ans, timeout);
 		if (eErr == Error_Succeed)
 		{
@@ -2357,6 +2440,9 @@ int CCardReadAdapterFSM::PrintCardIm(SpReqAnsContext<CardReadAdapterService_Prin
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
 		}
+		else {
+			Dbg("PrintCardImmediately, CardIssuer PrintCardImmediately failed return:%d", eErr);
+		}
 		ctx->Answer(eErr);
 		return 0;
 	}

+ 4 - 0
Module/mod_CardReadAdapter/CardReadAdapter_UserErrorCode.h

@@ -9,4 +9,8 @@
 #define CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Working		(CardReadAdapter_UserErrorCode_Start + 3)	//在"Working"状态收到了QueryCardInfo指令(不正常)
 #define CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Failed			(CardReadAdapter_UserErrorCode_Start + 4)	//在"Failed"状态收到了QueryCardInfo指令(不正常)
 #define CardReadAdapter_UserErrorCode_MayBe_ThreadPool_Wrong				(CardReadAdapter_UserErrorCode_Start + 5)	//可能线程池抛出时序异常
+
+#define CardReadAdapter_UserErrorCode_PreOnline_Invoke						(CardReadAdapter_UserErrorCode_Start + 6)	//web端发起一笔跨机业务
+#define CardReadAdapter_UserErrorCode_PreOnline_Result						(CardReadAdapter_UserErrorCode_Start + 7)	//跨机返回结果
+#define CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok			(CardReadAdapter_UserErrorCode_Start + 8)	//CardIssuer实体异常
 #endif //_CARDREADADAPTER_USER_ERRORCODE_H

+ 19 - 1
Module/mod_ContactlessCard/ContactlessCard_UserErrorCode.h

@@ -4,5 +4,23 @@
 
 #define ContactlessCard_UserErrorCode_Start 0x21300200
 #define ContactlessCard_UserErrorCode_Reset_Failed	(ContactlessCard_UserErrorCode_Start + 1)		//Reset失败
-#define ContactlessCard_UserErrorCode_DetectAndReadICData_Failed	(ContactlessCard_UserErrorCode_Start + 2)
+#define ContactlessCard_UserErrorCode_GetDevInfo_Failed	(ContactlessCard_UserErrorCode_Start + 2)	//获取设备信息失败
+#define ContactlessCard_UserErrorCode_LOGWARN_TERM_INFO	(ContactlessCard_UserErrorCode_Start + 3)	//硬件信息告警
+#define ContactlessCard_UserErrorCode_NO_ADAPTER_FILE	(ContactlessCard_UserErrorCode_Start + 4)	//未找到适配器文件
+#define ContactlessCard_UserErrorCode_ZssDeviceInfo	(ContactlessCard_UserErrorCode_Start + 5)	//中世顺机型信息告警
+#define ContactlessCard_UserErrorCode_RootInfo	(ContactlessCard_UserErrorCode_Start + 6)	//root信息
+
+#define ContactlessCard_UserErrorCode_FORGET_FETCH	(ContactlessCard_UserErrorCode_Start + 7)	//客户忘记取卡
+
+
+//预留一部分用于CardAssist.cpp中的报错告警
+//自ContactlessCard_UserErrorCode_Start + 11 ~ CardIssuer_UserErrorCode_Start + 20
+#define ContactlessCard_UserErrorCode_ActiveContactlessICCard_Failed						(ContactlessCard_UserErrorCode_Start + 11)	//DetectIfICCard调用ContactIC失败
+#define ContactlessCard_UserErrorCode_RFTypeABCommand_Failed								(ContactlessCard_UserErrorCode_Start + 12)	//BuildSupportedAppList调用RFTypeABCommand失败
+#define ContactlessCard_UserErrorCode_ICCommand_RecvData_Invalid							(ContactlessCard_UserErrorCode_Start + 13)	//APDU接收到的数据无效
+#define ContactlessCard_UserErrorCode_BuildSupportedAppList_Failed							(ContactlessCard_UserErrorCode_Start + 14)	//BuildSupportedAppList失败
+
+//Error_DevNotAvailable情况
+#define ContactlessCard_UserErrorCode_Read_OpenFailed						(ContactlessCard_UserErrorCode_Start + 21)	//设备未打开,读卡失败
+
 #endif //_CONTACTLESSCARD_USER_ERRORCODE_H

+ 79 - 51
Module/mod_ContactlessCard/ContactlessFSM.cpp

@@ -3,7 +3,6 @@
 #include "EventCode.h"
 #include "GetDevInfoHelper.h"
 #include "ModuleMix.h"
-#include "ContactlessCard_UserErrorCode.h"
 #include "CommDevEntityErrorCode.h"
 #include <winpr/sysinfo.h>
 
@@ -77,9 +76,12 @@ unsigned int CContactlessCardFSM::s1_on_event(FSMEvent* event)
 void CContactlessCardFSM::s2_on_entry()
 {
     LOG_FUNCTION();
+	if (m_FirstStart) {
+		m_FirstStart = FALSE;
+		ToLogWarnInfoAboutTerm(this, m_adapterInfo);
+	}
     GetEntityBase()->GetFunction()->SetUserDefineState(USER_CONTACTLESSCARD_IDLE);
     m_eDevState = DEVICE_STATUS_NORMAL;
-    Dbg("set reset times 0.");
     m_resetTimes = 0;
     m_testResult = Error_Succeed;
 }
@@ -442,7 +444,7 @@ void CContactlessCardFSM::s9_on_exit()
 }
 unsigned int CContactlessCardFSM::s9_on_event(FSMEvent* pEvt)
 {
-    Dbg("s9 evt(%d)", pEvt->iEvt);
+    Dbg("s9 evt(%d)(%d)", pEvt->iEvt, pEvt->param1);
     switch (pEvt->iEvt) {
     case USER_EVT_RESET:
     {
@@ -451,7 +453,7 @@ unsigned int CContactlessCardFSM::s9_on_event(FSMEvent* pEvt)
         if (m_resetTimes > MAX_RESET_TIMES_PERIOD) {
             Dbg("restart tried %d times,give up", m_resetTimes);
             m_testResult = Error_InvalidState;
-            LogWarn(Severity_Low, Error_Unexpect, ContactlessCard_UserErrorCode_Reset_Failed, GetEntityBase()->GetEntityName());
+            LogWarn(Severity_Low, Error_Unexpect, ContactlessCard_UserErrorCode_Reset_Failed, "reset failed more times");
             return 0;
         }
         ResetDeviceEvent* rde = dynamic_cast<ResetDeviceEvent*>(pEvt);
@@ -464,7 +466,6 @@ unsigned int CContactlessCardFSM::s9_on_event(FSMEvent* pEvt)
     case USER_EVT_RESETFINISHED:
     {
         ResetFinishedEvent* rfe = dynamic_cast<ResetFinishedEvent*>(pEvt);
-        Dbg("err,reset result %d", rfe->param1);
         return rfe->param1;
     }
     case USER_EVT_QUERY_CARD_INFO:
@@ -536,15 +537,18 @@ ErrorCodeEnum CContactlessCardFSM::Load()
 
     Dbg("dllName = %s", dllName.GetData());
     if (errDev != Error_Succeed) {
-        Dbg("load vendor lib failed");
+        Dbg("load vendor lib(%s) failed", dllName.GetData());
         return Error_DevLoadFileFailed;
     }
 
+	LogWarn(Severity_Low, Error_Unexpect, ContactlessCard_UserErrorCode_RootInfo, dllName.GetData());
+
     errDev = m_hDevHelper.LoadUp(dllName);
     if (Error_Succeed != errDev) {
         Dbg("load vendorlib or create DevAdapterObject failed.");
         return Error_DevLoadFileFailed;
     }
+	m_adapterInfo.adapterFileName = dllName;
 
     CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
     CSmartPointer<IConfigInfo> spConfig;
@@ -575,8 +579,24 @@ ErrorCodeEnum CContactlessCardFSM::Load()
         Dbg("open card issuer [%d][%d]", port, baudRate);
         errDev = m_hDevHelper->DevOpen(port, baudRate);
         if (errDev == Error_Succeed) {
-            Dbg("读卡器打开成功!");
-            bClosePort = true;
+			bClosePort = true;
+			ZeroMemory(m_devCatInfo.szModel, sizeof(m_devCatInfo.szModel));
+			ZeroMemory(m_devCatInfo.szType, sizeof(m_devCatInfo.szType));
+			ZeroMemory(m_devCatInfo.szVendor, sizeof(m_devCatInfo.szVendor));
+
+			errDev = m_hDevHelper->GetDevCategory(m_devCatInfo);
+			if (errDev == Error_Succeed)
+			{
+				Dbg("szVendor:%s, szType:%s, szModel:%s",
+					m_devCatInfo.szVendor, m_devCatInfo.szType, m_devCatInfo.szModel);
+				m_adapterInfo.devCatInfo = m_devCatInfo;
+			}
+			else
+			{
+				SetErrPackage(m_errPkg, "Load::GetDevCategory", m_csDevNo, errDev, MEC_DEVAPI_RF_GetDevCategory);
+				AlarmDEC(m_errPkg);
+				return Error_DevCommFailed;
+			}
 #ifdef RVC_OS_WIN
             CSimpleStringA csCMBPrint("CMBPrint.dll");
 #else
@@ -634,12 +654,19 @@ ErrorCodeEnum CContactlessCardFSM::Load()
             && (spConfig->ReadConfigValueInt("RunInfo", "CardMixed", m_CardMixed) == Error_Succeed)
             && (spConfig->ReadConfigValueInt("RunInfo", "CardInit", m_CardInit) == Error_Succeed)
             && (spConfig->ReadConfigValueInt("RunInfo", "CardPercent", m_CardPercent) == Error_Succeed)) {
-            Dbg("in %d cycle", isIssue);
+			Dbg("CardRemains:%d, m_CardIssued:%d, CardCaptured:%d, isIssue:%d, CardMixed:%d, CardInit:%d",
+				m_CardRemains, m_CardIssued, m_CardCaptured, isIssue, m_CardMixed, m_CardInit);
             m_bIssued = isIssue;
-
-            return Error_Succeed;
         } else
             return Error_IO;
+		if (ret == 0)
+		{
+			Dbg("读卡器打开成功");
+			m_devInit = true;
+			return Error_Succeed;
+		}
+		else
+			return Error_Unexpect;
     }
 }
 
@@ -654,10 +681,13 @@ bool CContactlessCardFSM::GetDevStatus()
     ErrorCodeEnum err;
     do {
         err = m_hDevHelper->GetDevStatus(devStatus);
+		Dbg("GetDevStatus, eMedia:%d", devStatus.eMediaPos);
         if (Error_Succeed == err)
             return true;
         else {
-            LOG_RF_ERROR_MSG_MACRO(err, GetDevStatus);
+			DevErrorInfo devErrInfo;
+			m_hDevHelper->GetLastErr(devErrInfo);
+			Dbg("GetDevStatus, errMsg:%s", devErrInfo.szErrMsg);
             getDevInfoCount++;
             SLEEP(3000);
         }
@@ -684,12 +714,17 @@ int CContactlessCardFSM::Reset()
     if (eErr == Error_Succeed) {
         if (Error_Succeed == m_hDevHelper->GetDevStatus(devStatus)) {
 
-            Dbg("media position %d", devStatus.eMediaPos);
+            Dbg("Reset, eMedia:%d", devStatus.eMediaPos);
             return 0;
-        } else
-            return 2;
+		}
+		else {
+			SetErrPackage(m_errPkg, "Reset::GetDevStatus", m_csDevNo, eErr, MEC_DEVAPI_RF_GetDevStatus);
+			AlarmDEC(m_errPkg);
+			return 2;
+		}
     } else {
-        Dbg("reset not succeed %d", eErr);
+		SetErrPackage(m_errPkg, "Reset::Reset", m_csDevNo, eErr, MEC_DEVAPI_RF_Reset);
+		AlarmDEC(m_errPkg);
         return 1;
     }
 }
@@ -718,7 +753,6 @@ int CContactlessCardFSM::InternalAcceptCard()
         }
 
         if (GetDevStatus()) {
-            Dbg("GetDevStatus %d, %d", devStatus.eMediaPos, acceptTries);
             if (devStatus.eMediaPos == CI_MEDIA_RF) {
                 LogEvent(Severity_Middle, LOG_EVT_CONTACTLESS_CARD_OP, "Contactless card op.");
                 acceptTries = 0;
@@ -783,11 +817,12 @@ int CContactlessCardFSM::AcceptCard(SpReqAnsContext<ContactlessCardService_Inser
     LogEvent(Severity_Middle, LOG_EVT_CONTACTLESS_CARD_GREEN_ON, "ContactCard green on");
     m_bWaitAccepteMore = false;
     int rc = InternalAcceptCard();
-
+	Dbg("InternalAcceptCard ret:%d", rc);
     LogEvent(Severity_Middle, LOG_EVT_CONTACTLESS_CARD_GREEN_OFF, "ContactCard green off");
 
     if (rc == 0) {
         if (ctx != NULL) {
+			Dbg("insert error_succeed");
             FetchCard evt;
             evt.status = 3;//oilyang@20181210 用于通知CardIssuer取消插卡
             SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(FetchCard), SP_MSG_SIG_OF(FetchCard), evt);
@@ -796,7 +831,7 @@ int CContactlessCardFSM::AcceptCard(SpReqAnsContext<ContactlessCardService_Inser
             int activeCardType;
             int retDetectAndRead = -1;
             if (!ctx->Req.aid.IsNullOrEmpty()) {
-                Dbg("aid:[%s]", (const char*)ctx->Req.aid);
+				Dbg("front business provide aid:[%s]", (const char*)ctx->Req.aid);
 				CAutoArray<CSimpleStringA> aidReq;
 				aidReq.Init(1);
 				aidReq[0] = ctx->Req.aid;
@@ -806,25 +841,22 @@ int CContactlessCardFSM::AcceptCard(SpReqAnsContext<ContactlessCardService_Inser
             }
 
             if (retDetectAndRead < 0) {
-                DevErrorInfo errInfo;
-                ErrorCodeEnum eErr = m_hDevHelper->GetLastErr(errInfo);
-                if (eErr == Error_Succeed) {
-                    LogWarn(Severity_High, Error_Unexpect, ContactlessCard_UserErrorCode_DetectAndReadICData_Failed,
-                            CSimpleStringA::Format("DetectAndReadICData failed: %s", errInfo.szErrMsg));
-                } else {
-                    LogWarn(Severity_High, Error_Unexpect, ContactlessCard_UserErrorCode_DetectAndReadICData_Failed, "DetectAndReadICData failed");
-                }
-                ctx->Answer(Error_Unexpect);
-                return 1;
+				Dbg("DetectAndReadICData failed:%d", retDetectAndRead);
+				ctx->Answer(AnswerErrCode(Error_Unexpect));
+				return 1;
             }
             ctx->Ans.t2Account = ctx->Ans.ICData = "";
             ICData track2(false, 0x57, 0x00);
             ErrorCodeEnum eErr = Error_Unexpect;
             string t2ICAccount(""), t2ICCardSerial(""), t2ICCVC(""), t2ICTrack2(""), cardType;
             if (m_pCardProcess->FindTagValue(TAG_VECTOR_IC, track2, false, 0) == -1) {
-                Dbg("[ic]no track2 data");
+				Dbg("no track2 data in ic");
                 eErr = m_hDevHelper->HaltCard();
-                ctx->Answer(Error_Unexpect);//can't find track2,retry 20150128
+				if (Error_Succeed != eErr) {
+					SetErrPackage(m_errPkg, "AcceptCard::HaltCard", m_csDevNo, eErr, MEC_DEVAPI_RF_HaltCard);
+					AlarmDEC(m_errPkg);
+				}
+				ctx->Answer(AnswerErrCode(Error_Unexpect));//can't find track2,retry 20150128
             } else {
                 int pos = FindHexCharPosition(track2.value, 0x0d, track2.lenth);
                 char* pICTrack2 = new char[128];
@@ -838,7 +870,7 @@ int CContactlessCardFSM::AcceptCard(SpReqAnsContext<ContactlessCardService_Inser
 
                 t2ICTrack2 = pICTrack2;
                 t2ICAccount = (char*)ddd;//oiltest
-                Dbg("contactless card countcount:%s,%s", t2ICAccount.substr(0, 6).c_str(), t2ICAccount.substr(t2ICAccount.length() - 4, 4).c_str());
+				Dbg("split pos:%d, card acount:%s,%s", pos, t2ICAccount.substr(0, 6).c_str(), t2ICAccount.substr(t2ICAccount.length() - 4, 4).c_str());
                 ctx->Ans.ICData = ctx->Ans.t2Account = t2ICAccount.c_str();
                 ctx->Ans.ICType = 4;
                 ctx->Ans.status = 0;
@@ -857,7 +889,7 @@ int CContactlessCardFSM::AcceptCard(SpReqAnsContext<ContactlessCardService_Inser
         }
     } else {
         if (ctx != NULL)
-            ctx->Answer(Error_Unexpect);
+			ctx->Answer(AnswerErrCode(Error_Unexpect));
     }
     return rc;
 }
@@ -917,10 +949,10 @@ int CContactlessCardFSM::PreOnline(SpReqAnsContext<ContactlessCardService_PreOnl
 {
     LOG_FUNCTION();
     m_pCardProcess->DataInit();
-    Dbg("bus data[%s]", (LPCTSTR)ctx->Req.businessData);
+	Dbg("<PreOnline>, bus data[%s]", ctx->Req.businessData.GetData());
     m_pCardProcess->SplitBusinessData(ctx->Req.businessData, ctx->Req.businessData.GetLength());
     if (m_bSM) {
-        Dbg("We support sm.");
+        Dbg("<PreOnline>, We support sm.");
         m_pCardProcess->SplitBusinessData("DF690101", strlen("DF690101"));
     }
     int activeCardType;
@@ -934,7 +966,7 @@ int CContactlessCardFSM::PreOnline(SpReqAnsContext<ContactlessCardService_PreOnl
         char* pAIDTmp = new char[64];
         memset(pAIDTmp, 0, 64);
         HexBuf2StrBuf(aidFromBus.value, &pAIDTmp, aidFromBus.lenth);
-        Dbg("the aid is[%s],len:%d .", pAIDTmp, strlen(pAIDTmp));
+        Dbg("<PreOnline>, the aid is[%s],len:%d .", pAIDTmp, strlen(pAIDTmp));
 		CAutoArray<CSimpleString> preAIDs;
 		preAIDs.Init(1);
 		preAIDs[0] = (CSimpleStringA)pAIDTmp;
@@ -943,7 +975,8 @@ int CContactlessCardFSM::PreOnline(SpReqAnsContext<ContactlessCardService_PreOnl
             delete[]pAIDTmp;
     }
     if (retDetectAndRead < 0) {
-        ctx->Answer(Error_Unexpect);
+		Dbg("<PreOnline::DetectAndReadICData>, return:%d", retDetectAndRead);
+		ctx->Answer(AnswerErrCode(Error_Unexpect));
         return 0;
     }
 
@@ -1007,14 +1040,13 @@ int CContactlessCardFSM::PreOnline(SpReqAnsContext<ContactlessCardService_PreOnl
     }
     if (m_pCardProcess->FindTagValue(TAG_VECTOR_IC, track2, false, 0) == -1) {
         Dbg("[ic]no track2 data");
-        Dbg("ic failed,release it %d", eErr);
     } else {
         int pos = FindHexCharPosition(track2.value, 0x0d, track2.lenth);
         char* pICTrack2 = new char[128];
         ZeroMemory(pICTrack2, 128);
         HexBuf2StrBuf(track2.value, &pICTrack2, track2.lenth);
         pICTrack2[37] = '\0';
-        Dbg("ic.track2,pos:%d", pos);
+		Dbg("<PreOnline>, split pos:%d", pos);
         char* ddd = new char[40];
         ZeroMemory(ddd, 40);
         memcpy(ddd, pICTrack2, pos - 1);
@@ -1120,6 +1152,8 @@ int CContactlessCardFSM::PostOnline(SpReqAnsContext<ContactlessCardService_PostO
     } else
         csTransEnd = "TRANSEND,1";
     ctx->Ans.result = csTransEnd;
+	Dbg("PostOnline, issBnkAuth:%d, csTransEnd:%s", issBnkAuth, csTransEnd.GetData());
+
     ctx->Answer(Error_Succeed);
     return 0;
 }
@@ -1144,7 +1178,7 @@ int CContactlessCardFSM::EjectCard(SpReqAnsContext<ContactlessCardService_Eject_
         }
         ErrorCodeEnum eErr = m_hDevHelper->GetDevStatus(devStatus);
         if (eErr == Error_Succeed) {
-            Dbg("devStatus.eMedia %d", devStatus.eMediaPos);
+			Dbg("EjectCard, devStatus.eMedia %d", devStatus.eMediaPos);
             if (devStatus.eMediaPos == CI_MEDIA_RF || devStatus.eMediaPos == CI_MEDIA_NOTPRESENT) {
                 if (devStatus.eMediaPos == CI_MEDIA_NOTPRESENT)
                     ret = 0;
@@ -1155,7 +1189,7 @@ int CContactlessCardFSM::EjectCard(SpReqAnsContext<ContactlessCardService_Eject_
         }
         SLEEP(100);
     }
-    Dbg("oiltest eject");
+    Dbg("eject return.");
     if (ctx != NULL)
         ctx->Answer(Error_Succeed);
     return ret;
@@ -1188,12 +1222,13 @@ int CContactlessCardFSM::QueryCardInfo(SpReqAnsContext<ContactlessCardService_Qu
     RFICReaderStatus devStatus;
     ErrorCodeEnum eErr = m_hDevHelper->GetDevStatus(devStatus);
     if (eErr != Error_Succeed) {
-        Dbg("GetDevStatus failed(%d).", eErr);
-        ctx->Answer(Error_Unexpect);
+		SetErrPackage(m_errPkg, "QueryCardInfo::GetDevStatus", m_csDevNo, eErr, MEC_DEVAPI_RF_GetDevStatus);
+		AlarmDEC(m_errPkg);
+		ctx->Answer(AnswerErrCode(Error_Unexpect));
         return 1;
     }
     int ret = 0;
-    Dbg("media pos:%d", devStatus.eMediaPos);
+	Dbg("QueryCardInfo, eMedia pos:%d", devStatus.eMediaPos);
     switch (devStatus.eMediaPos) {
     case CI_MEDIA_IC:
         ret = 2;
@@ -1213,10 +1248,3 @@ int CContactlessCardFSM::QueryCardInfo(SpReqAnsContext<ContactlessCardService_Qu
     ctx->Answer(Error_Succeed);
     return ret;
 }
-void CContactlessCardFSM::LogErrInfo(const char* msgHead)
-{
-    DevErrorInfo errInfo;
-    ErrorCodeEnum eErr = m_hDevHelper->GetLastErr(errInfo);
-    if (eErr == Error_Succeed)
-        Dbg("%s,%s", msgHead, errInfo.szErrMsg);
-}

+ 34 - 2
Module/mod_ContactlessCard/ContactlessFSM.h

@@ -8,8 +8,10 @@
 #include "RFICClass.h"
 #include "CardAssist.h"
 #include "ICDataElement.h"
+#include "DeviceBaseHelper.h"
 #include "ContactlessCard_server_g.h"
 #include "ContactlessCard_msg_g.h"
+#include "ContactlessCard_UserErrorCode.h"
 
 enum EvtType
 {
@@ -218,12 +220,16 @@ public:
         CContactlessCardFSM() : m_pRFIC(NULL), m_bCancelAccept(false), m_bWaitingAccept(false),
         m_bWaitAccepteMore(false), m_bExit(false), m_resetTimes(0), m_testResult(Error_Succeed)
         //,m_pTACReject(NULL),m_pIACOnline(NULL),m_pTACOnline(NULL),m_pIACDefault(NULL),m_pTACDefault(NULL)
-        , m_bCDA(false), m_pDataToARQC(NULL), m_bSM(false), m_bOnlineOnly(false)
+        , m_bCDA(false), m_pDataToARQC(NULL), m_bSM(false), m_bOnlineOnly(false), m_port(true), m_Baudrate(true)
+		, m_csDevNo(true), m_devInit(false), m_repeatErrTimes(0)
     {
+		HARDWARE_ENTITY_RESET_ENTITYID(m_entCode, 0x203);
+		m_FirstStart = TRUE;
 		m_aidList.Init(3);
 		m_aidList[0] = "A000000333";
 		m_aidList[1] = "A0000000108888";
 		m_aidList[2] = "A000000790";
+		ZeroMemory(&m_adapterInfo, sizeof(m_adapterInfo));
     }
     ~CContactlessCardFSM() {}
     virtual ErrorCodeEnum OnInit();
@@ -275,12 +281,30 @@ public:
     bool GetWaitFlag() { return m_bWaitingAccept; }
     void SetWaitMore() { m_bWaitAccepteMore = true; }
     void SetExitFlag(bool bFlag = true) { m_bExit = bFlag; }
+	bool GetDevInitFlag() { return m_devInit; }
 
     void SelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext)
     {
         pTransactionContext->SendAnswer(m_testResult);
     }
     DevStateEnum GetDevState() { return m_eDevState; }
+
+	ErrorCodeEnum AnswerErrCode(const ErrorCodeEnum& ec)
+	{
+		ErrorCodeEnum result(ec);
+		if (ec == Error_Succeed) {
+
+		}
+		else if (!m_devInit) {
+			result = Error_DevNotAvailable;
+		}
+		else if (0 < DeviceBaseHelper::CountDevError(GetEntityBase()->GetFunction(), m_repeatErrTimes)) {
+			result = Error_DevFailAddUp;
+			Dbg("exceed max allow repeat error times! 0x%x -> 0x%x", ec, result);
+		}
+		return result;
+	}
+
 protected:
     int m_iInsertTries;
     int m_resetTries;
@@ -302,11 +326,19 @@ private:
     long xxTest;
 	CAutoArray<CSimpleStringA> m_aidList;
 
+	DevCategoryInfo m_devCatInfo;
+	CSimpleStringA m_port, m_Baudrate;
+
+	ErrorPackage m_errPkg;
+	CSimpleStringA m_csDevNo;
+	AdapterInfo m_adapterInfo;
+
+	int m_repeatErrTimes;
+
     char m_AuthCode[2];
     bool m_bOnlineOnly, m_bCDA;
 
     int SplitTrack2(CSimpleStringA pTrack2, Track2Data& decodeData);
-    void LogErrInfo(const char*);
 };
 struct InitTask : public ITaskSp
 {

+ 0 - 7
Module/mod_ContactlessCard/mod_ContactlessCard.cpp

@@ -9,13 +9,6 @@ bool bCard = false;
 void ContactlessCardServerSession::Handle_Insert(SpReqAnsContext<ContactlessCardService_Insert_Req, ContactlessCardService_Insert_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-	//oiltest
-	//bCard = true;
-	//ctx->Ans.t2Account = "6226096550123456";
-	//ctx->Ans.ActiveCardType = "A";
-	//ctx->Ans.ICType = 4;
-	//ctx->Ans.status = 0;
-	//ctx->Answer(Error_Succeed);
 	m_pEntity->Insert(ctx);
 }
 void ContactlessCardServerSession::Handle_CancelInsert(SpOnewayCallContext<ContactlessCardService_CancelInsert_Info>::Pointer ctx)

+ 10 - 4
Module/mod_ContactlessCard/mod_ContactlessCard.h

@@ -77,10 +77,16 @@ public:
 	void Insert(SpReqAnsContext<ContactlessCardService_Insert_Req, ContactlessCardService_Insert_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
-		m_fsm.SetExitFlag(false);
-		CardAcceptEvent* e = new CardAcceptEvent();
-		e->ctx = ctx;
-		m_fsm.PostEventFIFO(e);
+		if (!m_fsm.GetDevInitFlag()) {
+			ctx->Answer(Error_DevNotAvailable);
+			LogWarn(Severity_Middle, Error_DevNotAvailable, ContactlessCard_UserErrorCode_Read_OpenFailed, "ReadCard but DevOpen failed.");
+		}
+		else {
+			m_fsm.SetExitFlag(false);
+			CardAcceptEvent* e = new CardAcceptEvent();
+			e->ctx = ctx;
+			m_fsm.PostEventFIFO(e);
+		}
 	}
 
 	void CancelInsert(SpOnewayCallContext<ContactlessCardService_CancelInsert_Info>::Pointer ctx)

+ 0 - 1
Module/mod_cardissuer/CMakeLists.txt

@@ -17,7 +17,6 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${MODULE_BASE_DIR}/mod_heartbeat
 	${MODULE_BASE_DIR}/mod_guiconsole
 	${MODULE_BASE_DIR}/mod_accessauth
-	${OTHER_LIB_BASE_DIR}/libpublicFun
 	${CONAN_INCLUDE_DIRS_OPENSSL}
 )
 get_target_property(EXISTED_PROPERTIES ${MODULE_NAME} COMPILE_DEFINITIONS)

+ 7 - 2
Module/mod_cardissuer/CardIssuerFSM.cpp

@@ -9,12 +9,10 @@
 #include "RVCComm.h"
 //oilyang@20200522 go on using
 // deprecated!! [4/17/2020 16:15 @Gifur]
-#include "CardIssuer_UserErrorCode.h"	//后续替代EventCode.h,暂时混合使用,时间太紧
 #include "CommDevEntityErrorCode.h"
 #include "CardIssuer_msg_g.h"
 #include "ModuleMix.h"
 #include "fileutil.h"
-#include "publicFunExport.h"
 #include <algorithm>
 
 char tmpxx[1024];
@@ -194,6 +192,10 @@ void CCardIssuerFSM::s2_on_entry()
 {
 	LOG_FUNCTION();
 	m_currentFSMState = 2;
+	if (m_FirstStart) {
+		m_FirstStart = FALSE;
+		ToLogWarnInfoAboutTerm(this, m_adapterInfo);
+	}		
 	GetEntityBase()->GetFunction()->SetUserDefineState(USER_CARDISSUER_IDLE);
 	SetDevStateAndSendMsg(DEVICE_STATUS_NORMAL, false);
 	
@@ -1943,6 +1945,7 @@ ErrorCodeEnum CCardIssuerFSM::OpenDevice(BYTE btOpenType, const char *pDevSN)
 	LogWarn(Severity_Low, Error_Unexpect, CardIssuer_UserErrorCode_RootInfo, dllName.GetData());
 
 	eErrDev = m_hDevHelper.LoadUp(dllName);
+	m_adapterInfo.adapterFileName = dllName;
 
 	CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
 	CSmartPointer<IConfigInfo> spConfig;
@@ -1992,6 +1995,8 @@ ErrorCodeEnum CCardIssuerFSM::OpenDevice(BYTE btOpenType, const char *pDevSN)
 				int ret = SplitDevModelInfo();
 				Dbg("OpenDevice, szVendor:%s, szType:%s, szModel:%s, version:%s, ret:%d",
 						m_devCat.szVendor, m_devCat.szType, m_devCat.szVendor, tmpVersion.GetData(), ret);
+				m_adapterInfo.devCatInfo = m_devCat;
+				Dbg("m_adapterInfo:%s,%s,%s", m_adapterInfo.devCatInfo.szModel, m_adapterInfo.devCatInfo.szType);
 			}
 			else
 			{

+ 6 - 2
Module/mod_cardissuer/CardIssuerFSM.h

@@ -8,6 +8,8 @@
 #include "DevEntityCommBase.hpp"
 #include "DevFSMCommBase.hpp"
 #include "DeviceBaseHelper.h"
+#include "CardIssuer_UserErrorCode.h"
+
 enum EvtType
 {
 	USER_EVT_TEST = EVT_USER + 1,
@@ -720,12 +722,14 @@ public:
 		, m_bInMainPage(false)
 	{
 		HARDWARE_ENTITY_RESET_ENTITYID(m_entCode, 0x203);
+		m_FirstStart = TRUE;
 		cmdDecodeMag2 = NULL;
 		cmdDecodeEx = NULL;
 		m_aidList.Init(3);
 		m_aidList[0] = "A000000333";
 		m_aidList[1] = "A0000000108888";
 		m_aidList[2] = "A000000790";
+		ZeroMemory(&m_adapterInfo, sizeof(m_adapterInfo));
 	}
 
 	~CCardIssuerFSM() {}
@@ -892,6 +896,7 @@ public:
 	void SetCancelByRFICFlag(bool bCancel = true) { m_bCancelByRFIC = bCancel; }
 	CSimpleStringA GetPreOnlineICCardNo() { return m_currCardNo; }
 	void CloseAndClearDevObj(bool bCheckConnecting = true, bool bCloseOnly = false);
+	bool GetDevInitFlag() { return m_bOpened; }
 
 	ErrorCodeEnum AnswerErrCode(const ErrorCodeEnum& ec)
 	{
@@ -951,6 +956,7 @@ private:
 	CCardProcess* m_pCardProcess;
 	CAutoArray<CSimpleStringA> m_aidList;
 	ErrorPackage m_errPkg;
+	AdapterInfo m_adapterInfo;
 	pfEncryptDukptHSM EncypteDukptHSM;
 	pfGetEncrypedData GetEncrypedData;
 	char* m_pDataToARQC;
@@ -981,8 +987,6 @@ private:
 	void ClearAllLocalSlotInfo();
 	bool LoadCMBPrint(CSimpleStringA csBinPath);
 	DevCategoryInfo m_devCat;
-	void ToLogWarnInfoAboutTerm();
-	HardwareEntityCode m_entCode;
 	CSimpleStringA m_csAlarmMsg, m_csVendorDllName;
 };
 struct InitTask : public ITaskSp

+ 5 - 0
Module/mod_cardissuer/CardIssuer_UserErrorCode.h

@@ -152,4 +152,9 @@
 #define CardIssuer_UserErrorCode_Load_CMBPrint_Failed		(CardIssuer_UserErrorCode_Start + 116)	//加载CMBPrint失败
 
 
+//预留一部分用于CardAssist.cpp中的报错告警
+//自CardIssuer_UserErrorCode_Start + 121 ~ CardIssuer_UserErrorCode_Start + 140
+#define CardIssuer_UserErrorCode_ICCommand_RecvData_Invalid				(CardIssuer_UserErrorCode_Start + 121)	//APDU接收到的数据无效
+
+
 #endif //_CARDISSUER_USER_ERRORCODE_H

+ 22 - 8
Module/mod_cardissuer/mod_cardissuer.h

@@ -108,11 +108,18 @@ public:
 	void Insert(SpReqAnsContext<CardIssuerService_Insert_Req, CardIssuerService_Insert_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
-		m_bNewSessionInit = false;
-		m_fsm.SetExitFlag(false);
-		CardAcceptEvent *e = new CardAcceptEvent();
-		e->ctx = ctx;
-		m_fsm.PostEventFIFO(e);
+		if (!m_fsm.GetDevInitFlag()) {
+			ctx->Answer(Error_DevNotAvailable);
+			LogWarn(Severity_Middle, Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpenFailed_Insert, "Insert but DevOpen failed.");
+		}
+		else
+		{
+			m_bNewSessionInit = false;
+			m_fsm.SetExitFlag(false);
+			CardAcceptEvent* e = new CardAcceptEvent();
+			e->ctx = ctx;
+			m_fsm.PostEventFIFO(e);
+		}
 	}
 
 	void Read(SpReqAnsContext<CardIssuerService_Read_Req, CardIssuerService_Read_Ans>::Pointer ctx)
@@ -125,9 +132,16 @@ public:
 	void ReadEx(SpReqAnsContext<CardIssuerService_ReadEx_Req, CardIssuerService_ReadEx_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
-		CardReadExEvent* e = new CardReadExEvent();
-		e->ctx = ctx;
-		m_fsm.PostEventFIFO(e);
+		if (!m_fsm.GetDevInitFlag()) {
+			ctx->Answer(Error_DevNotAvailable);
+			LogWarn(Severity_Middle, Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpenFailed_ReadEx, "ReadEx but DevOpen failed.");
+		}
+		else
+		{
+			CardReadExEvent* e = new CardReadExEvent();
+			e->ctx = ctx;
+			m_fsm.PostEventFIFO(e);
+		}
 	}
 	void Capture(SpReqAnsContext<CardIssuerService_Capture_Req, CardIssuerService_Capture_Ans>::Pointer ctx)
 	{

+ 0 - 3
Module/mod_cardswiper/CardSwiperFSM.cpp

@@ -7,9 +7,6 @@
 #include "ModuleMix.h"
 #include "CardSwiper_UserErrorCode.h"
 #include "CommDevEntityErrorCode.h"
-//#include "..\\mod_gpio\\Gpio_def_g.h"
-
-
 
 #include <algorithm>
 #define _ATL_NO_AUTOMATIC_NAMESPACE

+ 13 - 16
Module/mod_cardswiper/CardSwiperFSM.h

@@ -8,17 +8,26 @@
 #include "sm3.h"
 #include "public.h"
 #include "EventCode.h"
+#include "CardSwiper_server_g.h"
+#include "CardSwiper_msg_g.h"
+#include "CardSwiperClass.h"
+#include "CardAssist.h"
+#include "ICDataElement.h"
+#include "DevErrorCode.h"
+#include "DeviceBaseHelper.h"
 #include "CardSwiper_UserErrorCode.h"
 
 #include "..\mod_selfchecker\SelfChecker_client_g.h"
 #include "..\mod_selfchecker\SelfChecker_def_g.h"
-using namespace SelfChecker;
-
 #include "..\mod_healthmanager\HealthManager_client_g.h"
 #include "..\mod_healthmanager\HealthManager_def_g.h"
-using namespace HealthManager;
-
 #include "..\mod_pinpad\PinPad_client_g.h"
+#include "..\\mod_accessauth\\AccessAuthorization_client_g.h"
+
+using namespace CardSwiper;
+using namespace AccessAuthorization;
+using namespace SelfChecker;
+using namespace HealthManager;
 using namespace PinPad;
 
 class SelfChekerClient:public SelfCheckerService_ClientBase
@@ -88,18 +97,6 @@ struct FWBRecord
 	CSimpleStringA name;
 	CSimpleStringA remoteMac;
 };
-#include "CardSwiper_server_g.h"
-#include "CardSwiper_msg_g.h"
-#include "CardSwiperClass.h"
-#include "CardAssist.h"
-#include "ICDataElement.h"
-using namespace CardSwiper;
-#include "..\\mod_accessauth\\AccessAuthorization_client_g.h"
-using namespace AccessAuthorization;
-//#include "..\mod_guiconsole\GUIConsole_client_g.h"
-//using namespace GUIConsole;
-#include "DevErrorCode.h"
-#include "DeviceBaseHelper.h"
 
 typedef int(*lpCMBdecodeMag2)(char* Mag2Data, char * data);
 typedef int(*lpCMBdecodeEx)( char* MagData, char * type, char * data);

+ 30 - 0
Module/mod_cardswiper/CardSwiper_UserErrorCode.h

@@ -7,5 +7,35 @@
 #define CardSwiper_UserErrorCode_No_Encryted_Channel								(CardSwiper_UserErrorCode_Start + 2)	//未建立安全通道
 #define CardSwiper_UserErrorCode_Customer_Forget_Fectch_Card				(CardSwiper_UserErrorCode_Start + 3)	//客户超时未取卡
 #define CardSwiper_UserErrorCode_After_Bind_FWB_Initial_Failed			(CardSwiper_UserErrorCode_Start + 4)	//绑定后初始化蓝牙多合一失败
+#define CardSwiper_UserErrorCode_Wrong_Track2_Data						(CardSwiper_UserErrorCode_Start + 5)	//磁道2数据异常
+#define CardSwiper_UserErrorCode_Wrong_Track3_Data						(CardSwiper_UserErrorCode_Start + 6)	//磁道3数据异常
+#define CardSwiper_UserErrorCode_LogInfoAboutTerm						(CardSwiper_UserErrorCode_Start + 7)	//告警上送终端模块信息
+#define CardSwiper_UserErrorCode_Invalid_Track_Size						(CardSwiper_UserErrorCode_Start + 8)	//磁道长度有误
+#define CardSwiper_UserErrorCode_RootInfo								(CardSwiper_UserErrorCode_Start + 9)	//root信息
+
+#define CardSwiper_UserErrorCode_ALREADY_CONNECTED						(CardSwiper_UserErrorCode_Start + 10)	//设备已连接
+#define CardSwiper_UserErrorCode_FWB_DISCONNECTED_BLUETOOTH				(CardSwiper_UserErrorCode_Start + 11)	//蓝牙多合一断开连接
+#define CardSwiper_UserErrorCode_DEV_DISCONNECTED						(CardSwiper_UserErrorCode_Start + 12)	//多合一断开连接
+
+#define CardSwiper_UserErrorCode_LOAD_FILE_FAILED						(CardSwiper_UserErrorCode_Start + 13)	//加载文件失败
+#define CardSwiper_UserErrorCode_OBJECT_CREATE_FAILED					(CardSwiper_UserErrorCode_Start + 14)	//创建对象失败
+#define CardSwiper_UserErrorCode_CONNECT_ACCESS_FAILED					(CardSwiper_UserErrorCode_Start + 15)	//连接准入实体失败
+#define CardSwiper_UserErrorCode_ACCESS_INITDEV_FAILED					(CardSwiper_UserErrorCode_Start + 16)	//准入调用初始化接口失败
+#define CardSwiper_UserErrorCode_CONNECT_HEALTH_FAILED					(CardSwiper_UserErrorCode_Start + 17)	//连接健康实体失败
+
+#define CardSwiper_UserErrorCode_Build_Channel_Failed					(CardSwiper_UserErrorCode_Start + 18)	//建立加密传输通道失败
+
+//预留一部分用于CardAssist.cpp中的报错告警
+//自CardSwiper_UserErrorCode_Start+21 ~ CardSwiper_UserErrorCode_Start+40
+#define CardSwiper_UserErrorCode_ContactIC_Failed						(CardSwiper_UserErrorCode_Start + 21)	//DetectIfICCard调用ContactIC失败
+#define CardSwiper_UserErrorCode_ActiveICCard_Failed					(CardSwiper_UserErrorCode_Start + 22)	//DetectIfICCard调用ActiveICCard失败
+#define CardSwiper_UserErrorCode_ActiveContactlessICCard_Failed			(CardSwiper_UserErrorCode_Start + 23)	//DetectIfICCard调用ActiveContactlessICCard失败
+#define CardSwiper_UserErrorCode_ICCommand_Failed						(CardSwiper_UserErrorCode_Start + 24)	//BuildSupportedAppList调用ICCommand失败
+#define CardSwiper_UserErrorCode_RFTypeABCommand_Failed					(CardSwiper_UserErrorCode_Start + 25)	//BuildSupportedAppList调用RFTypeABCommand失败
+#define CardSwiper_UserErrorCode_ICCommand_RecvData_Invalid				(CardSwiper_UserErrorCode_Start + 26)	//APDU接收到的数据无效
+#define CardSwiper_UserErrorCode_BuildSupportedAppList_Failed			(CardSwiper_UserErrorCode_Start + 27)	//BuildSupportedAppList失败
+
+//Error_DevNotAvailable情况
+#define CardSwiper_UserErrorCode_Read_OpenFailed						(CardSwiper_UserErrorCode_Start + 41)	//设备未打开,读卡失败
 
 #endif //_CARDSWIPER_USER_ERRORCODE_H