UINT8 ucInitRS232(DevHandle hDev, uchar ucBPS) { uchar ucRet = 0; ucRet = EA_ucInitRS232(hDev, ucBPS, EM_232_NOPAR, EM_232_8DBS); if (ucRet != EM_SUCCESS) { EA_vCls(); display(2, "打印口初始化失败[%02X]", ucRet); inkey(0); return 1; } return 0; }
int SetS100LoadKeyMode(void) { uchar aucOut[20], ucRet; DevHandle hDevHandle; uint uiOutLen; int nReturn; nReturn = 0; ucRet = EA_ucOpenDevice("COM", EM_io_PORT2, &hDevHandle); if ( ucRet != EM_SUCCESS) { EA_vCls(); PubDisplay(2,"打开端口错误 %d", ucRet); PubuiInkey(30); return -1; } EA_ucInitRS232(hDevHandle, EM_232_115200BPS, EM_232_NOPAR, EM_232_8DBS); EA_ucClearRS232(hDevHandle);//清除缓冲区 memcpy(aucOut,"\x02\x06\x9a\x01\x00\x00\x03\x02",8); ucRet = EA_ucWriteDevice(hDevHandle, 8, 1, (char*)aucOut); memset(aucOut, 0x00, 8); memcpy(aucOut+8,"\x06\x02\x04\x00\x01\x03\x02",7); uiOutLen = 0; ucRet = EA_ucReadDevice(hDevHandle, 7, 3, aucOut, &uiOutLen); if ( ucRet != EM_SUCCESS|| uiOutLen != 7) { EA_vCls(); PubDisplay(2,"从端口读数据错 %d %d", ucRet, uiOutLen); PubuiInkey(30); nReturn = -2; } else { if(memcmp(aucOut+8, aucOut, 7)) { EA_vCls(); PubDisplay(2,"数据校验错误"); PubuiInkey(30); nReturn = -3; } } EA_ucCloseDevice(&hDevHandle); return nReturn; }
int send_to_EFT(int len, char *p) { uchar ucRet; DevHandle hRS232Handle; ET_ProductInfo tProductInfo; #ifdef EPT_A9L memset(&tProductInfo, 0x00, sizeof(ET_ProductInfo)); EA_ucGetProductInfo(&tProductInfo); if ( memcmp(tProductInfo.acName , "E520" , 4) == 0 && tProductInfo.ucMachType == 2) { ucRet = EA_ucOpenDevice("COM3", 0, &hRS232Handle); } else { ucRet = EA_ucOpenDevice(SERIAL_PORT, 0, &hRS232Handle); } #else ucRet = EA_ucOpenDevice("COM", EM_io_PORT1, &hRS232Handle); #endif if (ucRet != EM_SUCCESS) { EA_vCls(); EA_vDisplay(2, "打开RS232口出错"); EA_ucCloseDevice(&hRS232Handle); PubuiInkey(3); return (EXCEPTION); } EA_ucInitRS232(hRS232Handle, EM_232_9600BPS, EM_232_NOPAR, EM_232_8DBS); EA_ucClearRS232(hRS232Handle);//清除RS232缓冲区 ucRet = EA_ucWriteDevice(hRS232Handle, (uint)len, 0, p); EA_ucCloseDevice(&hRS232Handle); // debug_print((char*)"SendToPC", p, len); if (ucRet == EM_io_SUCCESS) return NORMAL; else return EXCEPTION; return (NORMAL) ; }
/***************************************************************** 函数原型:Device_Handle_Init() 功能描述:设备所有句柄初始化 参数描述: 返回值: OK ? NOTOK 作 者: 刘及华 日 期: 2012-11-24 修改历史: 日期 修改人 修改描述 ------ --------- ------------- *****************************************************************/ INT8U Device_Handle_Init(void) { uchar ucRet; if (EA_ucOpenDevice("RFCARD", EM_mifs_TYPEA, &hMifsHandle) != EM_SUCCESS) { lcddisperr("读卡器初始化失败"); return notok; } if ( EA_ucOpenDevice("PRINT", EM_io_REALMODE, &hDprinterHandle) != EM_SUCCESS ) { lcddisperr("获得打印操作句柄失败!"); return notok; } // if ( EA_ucOpenDevice("USBD", EM_io_REALMODE, &hUSBDHandle) != EM_SUCCESS ) // { // lcddisperr("获得打印操作句柄失败!"); // return notok; // } // if ( EA_ucOpenDevice("WLM", 0, &hWLMHandle) != EM_SUCCESS ) // { // lcddisperr("获得GPRS句柄失败!"); // return notok; // } ///////////////////////////////////////////////打印机设置参数 ucRet = EA_ucInitPrinter(hDprinterHandle); if ( ucRet != EM_SUCCESS ) { EA_vDisplay(2, "初始化打印机芯失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_XSPACE, 0); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_YSPACE, 6); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } // ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_PAGESPACE, 578); ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_PAGESPACE , 220); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_ASCII_DOTTYPE, EM_prn_ASCIIDOT24X12); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_ASCII_PRNTYPE, EM_prn_ASCIIPRN1X1); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_HZ_DOTTYPE, EM_prn_HZDOT24X24); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_HZ_PRNTYPE, EM_prn_HZPRN1X1); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_PRNGRAY, 4); if ( ucRet != EM_SUCCESS ) { // (void)EA_ucCloseDevice(&hDprinterHandle); lcddisperr("打印机设置失败!"); return notok; } /////////////////////////////////////////////////////////////////////////////初始化时候只设置一次 if (EA_ucOpenDevice("SAM1CARD", 0, &hSam1Handle) != EM_SUCCESS) { lcddisperr("PSAM卡初始化失败"); return notok; } // if (EA_ucOpenDevice("USERCARD", 0, &hCpuHandle) != EM_SUCCESS) // { // lcddisperr("CPU卡初始化失败"); // return notok; // } // if (EA_ucICInitModule(hCpuHandle, EM_ic_VOLDEFAULT, EM_ic_TCRMODE) != EM_SUCCESS) // { // lcddisperr("设置CPU规范失败"); // return notok; // } ucRet = EA_ucOpenDevice("USBD", 0, &hRS232Handle); if ( ucRet != EM_SUCCESS ) { (void)EA_ucCloseDevice(&hRS232Handle); lcddisperr("COM口设置失败!"); return notok; } EA_ucInitRS232(hRS232Handle, EM_232_115200BPS, EM_232_NOPAR, EM_232_8DBS); return ok; }
//两个出口参数,*uiTotalKeyCounts = 0表示第一个包接收失败 uchar ucOfflineLoad(uint *uiTotalKeyCounts, uint *uiLoadKeyCounts) { DevHandle hRS232Handle; uchar ucRet; uchar ucInitBuf[11]; uchar ucKeyBuf[100]; uchar ucCloseBuf[11]; uchar ucCMD[2]; uchar ucRespCode[2]; uint uiDealCounts;//处理次数,三次失败函数返回EM_ERROR uint uiNextKeyNo; uint uiKeyNo; uint uiKeySum; uint uiWRecNum;//可写记录数 uint uiVRecNum;//有效记录数 uchar ucKeyFileID; uchar ucFlashBuf[50]; uchar ucIsFileEmpty; ucRet = PubOpenDevice("COM", EM_io_PORT1,&hRS232Handle); if (ucRet != EM_SUCCESS) { PubClearAll(); PubDisplayInv(1, "错误"); PubDisplayCen(2, "打开串口错误"); PubuiInkey(3); EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = 0; return EM_ERROR; } ucRet = EA_ucInitRS232(hRS232Handle, FV.ucBPS, EM_232_NOPAR, EM_232_8DBS);//!!!!!!!!!!!!! ucRet = EA_ucClearRS232(hRS232Handle);//清除缓冲 ucRet = ucInitConnect(hRS232Handle, ucInitBuf);//与PC建链 if (ucRet != EM_SUCCESS)//建链失败 { PubClearAll(); PubDisplayInv(1, "错误"); PubDisplayCen(2, "建链失败"); PubuiInkey(3); EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = 0; return EM_ERROR; } //打开密钥文件 ucKeyFileID = ucKeyFileOpen("KeyFile");//包含报错 if (ucKeyFileID == 0) { ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = 0; return EM_ERROR; } //-------------------------------------------------------- //查询剩余可写记录数 ucRet = EA_ucPFInfo(ucKeyFileID, EM_ffs_FREEREC, &uiWRecNum); if(ucRet == EM_SUCCESS) { if( uiWRecNum < 1) { EA_ucPFInfo( ucKeyFileID, EM_ffs_VALIDREC, &uiWRecNum); PubClearAll(); PubDisplayInv(1, "错误"); PubDisplay(2,"系统已有%d条密钥",uiWRecNum); PubDisplayCen(3,"密钥文件已满,无法加载密钥"); PubDisplayCen(4,"请先清除所有密钥"); PubuiInkey(10); ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = 0; return EM_ERROR; } } //--------------------------------------------------------- ucIsFileEmpty = 0; EA_ucPFInfo( ucKeyFileID, EM_ffs_VALIDREC, &uiVRecNum); if(uiVRecNum == 0)//密钥文件为空 { //使用ucFileOpNoSearch函数 ucIsFileEmpty = 1; } //----------------------------- *uiTotalKeyCounts = 0; uiKeySum = 0; uiNextKeyNo = 1; PubClearAll(); while (1) { uiDealCounts = 3; while (uiDealCounts > 0) { ucRet = ucRecvPackage(hRS232Handle, ucKeyBuf); if (ucRet != EM_SUCCESS)//收密钥失败 { PubClearAll(); PubDisplayInv(1, "错误"); PubDisplay(2, "接收第%d条密钥失败", uiNextKeyNo); PubuiInkey(3); ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_ERROR; } if(ucKeyBuf[7] != 0x00 || ucKeyBuf[8] != 0x02)//不是离线加载报文,抛弃 { continue; } uiKeyNo = ucKeyBuf[9] / 16 * 100000 + ucKeyBuf[9] % 16 * 10000 + ucKeyBuf[10] / 16 * 1000 + ucKeyBuf[10] % 16 * 100 + ucKeyBuf[11] / 16 * 10 + ucKeyBuf[11] % 16 ;//当前密钥序号 if( uiKeyNo != uiNextKeyNo ) { continue;//若当前密钥序号!=预计的序号,抛弃该包 } if (uiKeySum == 0)//第一次收到密钥包,仅计算一次密钥总条数 { uiKeySum = ucKeyBuf[12] / 16 * 100000 + ucKeyBuf[12] % 16 * 10000 + ucKeyBuf[13] / 16 * 1000 + ucKeyBuf[13] % 16 * 100 + ucKeyBuf[14] / 16 * 10 + ucKeyBuf[14] % 16 ;//包内密钥总条数 *uiTotalKeyCounts = uiKeySum;//修改出口 } //核对密钥校验值 ucRet = ucCheckTMK(&ucKeyBuf[38], &ucKeyBuf[62]); if (ucRet != EM_SUCCESS)//密钥校验失败 { ucCMD[0] = 0x80, ucCMD[1] = 0x02; ucRespCode[0] = 0x39, ucRespCode[1] = 0x39; ucResponse(hRS232Handle, &ucKeyBuf[3], ucCMD, ucRespCode);//&ucInitBuf[3]:SEQ序列号 uiDealCounts --; continue; } break; }//结束该循环表示:收到一个包或重试了三次 if (uiDealCounts == 0)//三次处理失败 { ucCloseConnect(hRS232Handle, ucCloseBuf);//断链 ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); PubClearAll(); PubDisplayInv(1, "错误"); PubDisplay(2, "接收第%d条密钥失败",uiNextKeyNo); PubuiInkey(3); ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_ERROR; } /*写flash*/ memcpy( ucFlashBuf, &ucKeyBuf[15], 47 ); ucFlashBuf[47] = ucKeyBuf[66]; ucFlashBuf[49] = 0; if(ucIsFileEmpty == 1) { //密钥文件为空时,不搜索匹配,直接添加记录 if(ucFileOpNoSearch( ucKeyFileID,ucFlashBuf) != EM_SUCCESS) { ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_ERROR; } } else if(ucIsFileEmpty == 0) { //密钥文件非空时,搜索是否有一样记录,防重复 if( ucFileOp( ucKeyFileID, ucFlashBuf) != EM_SUCCESS) { ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_ERROR; } } else { PubClearAll(); PubDisplayInv(1, "错误"); PubDisplayCen(2, "搜索标志位错误"); PubuiInkey(3); ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_ERROR; } ucCMD[0] = 0x80, ucCMD[1] = 0x02; ucRespCode[0] = 0x30, ucRespCode[1] = 0x30;//加载成功 ucResponse(hRS232Handle, &ucKeyBuf[3], ucCMD, ucRespCode);//&ucInitBuf[3]:SEQ序列号 //----------------------------------------------------------- uiWRecNum--; if(uiWRecNum == 0) { //查询剩余可写记录数 EA_ucPFInfo( ucKeyFileID, EM_ffs_VALIDREC, &uiVRecNum); PubClearAll(); PubDisplayInv(1, "错误"); PubDisplay(2,"系统已有%d条密钥",uiVRecNum); PubDisplayCen(3,"密钥文件已满,无法加载密钥"); PubuiInkey(5); ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_ERROR; } //----------------------------------------------- PubDisplayInv(1, "密钥加载"); PubDisplayCen(2,"正在接收密钥..."); PubDisplay(3,"接收第%d条密钥成功", uiNextKeyNo); uiNextKeyNo ++ ; if (uiNextKeyNo - 1 == uiKeySum)//接收完所有密钥 { break; } } ucCloseConnect(hRS232Handle, ucCloseBuf);//断链 ucKeyFileClose(ucKeyFileID);//关闭文件 EA_ucCloseDevice(&hRS232Handle); *uiLoadKeyCounts = uiNextKeyNo - 1; return EM_SUCCESS; }
int dlm_main(char *CMDBUF , int *nCmdLen) { char szGetBuffer[30],szTmpBuf[30]; char szBuffer[100]; // char cWaitRet; uint uiKey , uiRet,nRet; // uchar ucRetVal; // uchar ucFd; uchar ucRet; int nScreen = 0; char cMenuTime; // uint uiCount; uint uiOption; uint puiConfigInfo; // uchar i, ucIfExist, ucStatus; const char *pcModuleName = MODULE_FILE_NAME; // const char *pcCommModuleName = "applib"; DevHandle phPinpad; // DevHandle hVoiceHandle; #ifdef EPT_A9L // uint_64 llCnt = 0; // char szData[100]; #endif #ifdef EMVIC EA_EMV_vInit(); #endif //设备句柄清空 gbPrintHandle = EM_NULL; //清空所有全局设备句柄,add by zhuchentao 060831 gbhdlMagCard = EM_NULL;; //磁卡模块 gbhdlUserCard = EM_NULL; gbhdlMasterCard = EM_NULL; gbhdlSAM1Card = EM_NULL; gbhdlSAM2Card = EM_NULL; gbhdlSAM3Card = EM_NULL; gbhdlSAM4Card = EM_NULL; gbMifCardHandle = EM_NULL; #ifdef EMVIC gbhdlPINPAD = EM_NULL; gbhdlRS232 = EM_NULL; gbMifCardHandle = EM_NULL; #endif cRunState = 1; CommInfo.gbHdl = EM_NULL; memset(&iso, 0, sizeof(ISODataStru)); memset(&iso1, 0, sizeof(ISODataStru)); memset(&printiso, 0, sizeof(ISODataStru)); memset(&upiso, 0, sizeof(ISODataStru)); gbcECDefault = 0; #ifndef EPT_A9L #ifdef EPT_M3 if (EA_uiLoadAndExecuteModule("LibRFReader.dlm", "") != EM_SUCCESS) #endif #ifdef EPT56X0 if (EA_uiLoadAndExecuteModule("LibRFReader", "") != EM_SUCCESS) #endif { PubDisplay(3, "载入LibRFReader.dlm失败"); PubDisplay(4, "请下载LibRFReader.dlm文件"); PubuiInkey(0); return EXCEPTION; } #endif EA_vCls(); PubucLoadAllMfVar((char*)MODULE_FILE_NAME, &FV, sizeof(FV)); // #ifdef EPT56X0 // EA_ucSetStopFlag(EM_DISABLE_STOP); // #endif // #ifdef EPT_A9L // EA_ucSetStopFlag(EM_DISABLE_STOP); // #endif // 银商允许修改参数标志,提交程序的时候分别2种情况编译提交 // setup.c 中还有一个地方要设置,勿忘!!! #ifdef TMS cSetupModifyFlag = 0;// TMS服务器版 不允许修改参数 #else cSetupModifyFlag = 1;// 下载版 允许修改参数 #endif #ifndef EPT5610 EA_vSetLCDLightTimer(60); #endif EA_vCls(); if (PubucFirstRunPara(pcModuleName, "parafile") == EM_SUCCESS) { PubGetPinpadPara();// 先读取参数文件中密码键盘标签 FV.gbnParaFirstFlag = YES; WRITE_nVAR(FV.gbnParaFirstFlag); } PubUsePinpadInside(FV.Other.SetPinpadType); // PubUsePinpadInside(1); PubGetPrinterType(&iPrinterType); PubGetPinpadType(&iPinpadType); while ((ucRet = PubOpenDevice("PINPAD", EM_io_IPP, &phPinpad)) != EM_SUCCESS) { PubGetPosType(); if (FV.gbnPosTypeFlag == YES) { FV.Other.SetPinpadType = 1; PubUsePinpadInside(1); WRITE_nVAR(FV.Other.SetPinpadType); } else { PubDisplayInv(2, "打开密码键盘错"); PubDisplay(3, "请接入密码键盘"); PubDisplay(4, "[%d][%02x][%d]", ucRet, ucRet,FV.gbnPosTypeFlag); EA_vBeepMs(50); uiRet = PubuiInkey(1); if (uiRet == EM_key_FUNC1) { PubSetUsePinpadType(); } if (uiRet == EM_key_FUNC9||EM_key_CANCEL) { return EM_ERROR; } } } while ((PubGetPinpadVer(phPinpad ,&iPinpadVer)) == 3) { PubDisplayInv(2, "请接好密码键盘"); EA_vBeepMs(50); PubuiInkey(1); } #ifndef EPT5610 //20070914 by wei 将安全级别设置成默认级别 if ( iPinpadVer == 2 ) { EA_pci_ucGetSecureConfig(phPinpad, EM_NULL, &puiConfigInfo); if ( puiConfigInfo != EM_pin_DEFAULTCONFIG) { EA_pci_ucSetSecureConfig(phPinpad, EM_NULL, EM_pin_DEFAULTCONFIG); } } #endif EA_ucCloseDevice(&phPinpad); nFirstSetupFlag = NO; if (PubucFirstRunProg(pcModuleName) == EM_SUCCESS) { FV.gbnFirstFlag = YES; WRITE_nVAR(FV.gbnFirstFlag); } // 注册headcommon /* if (PubLoadAndExecuteModule(pcCommModuleName, "F0506") != EM_SUCCESS) { EA_vCls(); PubDisplay(3, "装载公共模块失败!"); //因为PubDisplay是在applib中的,注册applib失败也就无法使用PubDisplay函数,只能用EA_vDisplay函数 PubuiInkey(0); return EXCEPTION; } */ // 导入def8583.h中的8583包定义 if (PubImport8583(YlIso8583Def) == EXCEPTION) { EA_vCls(); PubDisplay(3, "8583包导入出错"); PubDisplay(4, "请检查程序重新下装"); PubuiInkey(0); return EXCEPTION; } // 导入结束 PubGetMifsType(&iMifsType); //增加POS模块判断/必须放在initcomm之前,initcomm可能会影响底层的判断 if (FV.gbnFirstFlag == YES) { PubGetPosType(); PubSetupFirst(); #ifdef EMVIC setup_first (); #endif WRITE_nVAR(FV); //这里把setupfirst里面的内容统一写入一次 nFirstSetupFlag = YES; FV.gbnFirstFlag = NO; WRITE_nVAR(FV.gbnFirstFlag); FV.gbnParaFirstFlag = YES; WRITE_nVAR(FV.gbnParaFirstFlag); if (FV.gbnParaFirstFlag == YES) { PubReadPara() ; } FV.gbnParaFirstFlag = NO; WRITE_nVAR(FV.gbnParaFirstFlag); } if (FV.gbnParaFirstFlag == YES) { PubReadPara(); } if (nFirstSetupFlag == YES) { PubInitGlobal(); PubSetup(10); nFirstSetupFlag = NO; } else { PubInitGlobal(); } #ifdef TMS //读取主控应用参数 ProReadBasePara(); #endif // by wei 每次进入应用不需要重新操作员签到 modify by baijz 20110723 BCTC要求每次开机操作员签到 BUFCLR(szGetBuffer); // VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer)); // if (szGetBuffer[0] == LOGON) // PubSetPoscfgcPosState(NO_LOGON); EA_vCls(); PubKeyOn(); #ifdef BZ /*标准版*/ PubDisplayInv( 1, "中国银联"); #endif #ifdef Largevalue /*大额支付*/ PubDisplayInv( 1, "中国银联-大额"); #endif #ifdef NMLS /*内蒙移动零售*/ PubDisplayInv( 1, "内蒙移动零售"); #endif #ifdef NMJF /*内蒙移动缴费*/ PubDisplayInv( 1, "内蒙移动缴费"); #endif PubDisplayCen(2, "CUP2.0"); PubDisplayCen(3, "自检..."); szGetCmdFlag = 0 ; szCMDChangeAppFlag = 0 ; //ucRet = EA_ucOpenDevice("PINPAD",EM_io_IPP, &phPinpad); while ((ucRet = PubOpenDevice("PINPAD", EM_io_IPP, &phPinpad)) != EM_SUCCESS) { PubDisplayInv(2, "打开密码键盘错"); PubDisplay(3, "[%d][%02x]", ucRet, ucRet); EA_vBeepMs(50); PubuiInkey(1); } while ((ucRet = PubResetPinpad(phPinpad)) != EM_SUCCESS) { PubDisplayInv(2, "请接好密码键盘"); PubDisplay(3, "[%d][%02x]", ucRet, ucRet); EA_vBeepMs(50); PubuiInkey(1); } // 为多应用,怕其他应用使用和银联相同的mackey workkey的ID号,这里重新load一次。 PubucSelectKey(phPinpad, EM_pin_MASTERKEY, FV.bank.nMKeyIndex); if(FV.Other.gbMacKeyLen) PubucLoadKey(phPinpad,EM_pin_DEFAULTMODE ,EM_pin_MACKEY, 0, FV.Other.gbMacKeyLen, FV.Other.gbszMacKey); if(FV.Other.gbWorkKeyLen) PubucLoadKey(phPinpad, EM_pin_DEFAULTMODE ,EM_pin_WORKKEY, 0, FV.Other.gbWorkKeyLen, FV.Other.gbszWorkKey); EA_ucCloseDevice(&phPinpad); if (PubuiInkeyMs(500) == EM_key_CANCEL) PubLogin(); PubGetMifsType(&iMifsType); //增加POS模块判断/必须放在initcomm之前,initcomm可能会影响底层的判断 PubInitComm(&CommInfo, AUTOCHECK); BUFCLR(szGetBuffer); VERIFY_NORMAL(PubGetPoscfgcBatchState(szGetBuffer)); if (szGetBuffer[0] == YES) { EA_vCls(); PubDisplayInv(2, "请先结算再作交易"); PubuiInkey(1); } //打开MISPOS的通讯接口 #ifdef EPT_A9L ucRet = EA_ucOpenDevice(FV.Other.gbcMISPort,0, &gbhdCMDRS232); if (ucRet != EM_SUCCESS) { ucRet = EA_ucOpenDevice("COM3",0, &gbhdCMDRS232); if (ucRet == EM_SUCCESS) { memcpy(FV.Other.gbcMISPort,"COM3",4); WRITE_nVAR(FV.Other.gbcMISPort); } } if (ucRet != EM_SUCCESS) { EA_vCls(); PubDisplay(1,"请先设置COMPOS 端口"); EA_vBeepMs(1000); PubuiInkey(0); return ProFuncBankszComPos(); /*memcpy(FV.Other.gbcMISPort,"COM2",4); WRITE_nVAR(FV.Other.gbcMISPort); EA_vCls(); PubDisplay(1,"无法打开通信端口!"); PubDisplay(2,"请重启设备"); EA_vBeepMs(1000); PubuiInkey(2); return EXCEPTION;*/ } else { ucRet = EA_ucInitRS232(gbhdCMDRS232,FV.gbRSInfo.ucBps,EM_232_NOPAR ,EM_232_8DBS); //ucRet = EA_ucCloseDevice(&gbhdCMDRS232); //gbhdCMDRS232 = EM_NULL; } #endif if ( nCmdLen != NULL && CMDBUF != NULL) { CMDBUFLen = *nCmdLen; if (CMDBUFLen >0 ) { memset(szCMDBuffer , 0 , sizeof(szCMDBuffer)); memcpy(szCMDBuffer , CMDBUF , CMDBUFLen); memset(&TlvSendValue,0,sizeof(struct TLVVALUE)); CMDProcess(szCMDBuffer, (char*)&TlvSendValue, &gbctlvflag); szGetCmdFlag = 15; } } BUFCLR(szGetBuffer); BUFCLR(gbPosTags); gbTags = 0; gbnDisplayTime = 0; #ifdef EMVIC PubSetExeReader(1); #endif while (1) { PubDispIcon();//显示一下5650电池电量和信号 #ifdef TMS if (ProJudgeBaseDlaVer() == EM_SUCCESS) { ProGetBaseDialFix(); ucRet = PubReturnUpdate() ; if (ucRet != EM_ERROR) { PubDelAllBit(&iso); close_all_dev(); return ucRet; } if (PubCheckRunState() == EM_SUCCESS) { PubDelAllBit(&iso); close_all_dev(); return EM_ERROR; } } #endif memset(&gbTrkInfo, 0, sizeof(struct TrackInfo)); memset(&gbCardinfo, 0, sizeof(struct CardConfig)); // PubDisplay(4 , "%d %d %d %d",EM_VOC_LEVEL0,EM_VOC_LEVEL1,EM_VOC_LEVEL2,EM_VOC_LEVEL3); // PubuiInkey(60); // FV.Other.POSSTATFLAG = 6;//chenjs20060915 ls add for test TMS // EA_ucAudioSetVolume(FV.Other.ucNewVolume); // EA_ucAudioPlay("qing.wav"); // EA_ucAudioPlay("shuaka.wav"); #if 0 ucRet = EA_ucOpenDevice("EVOICE", 0, &hVoiceHandle); //打开外置语音设备 if(ucRet != EM_SUCCESS) { EA_vDisplays(2,1, "Test Open Err:%02x", ucRet); EA_uiInkey(0); return EM_ERROR; } else { EA_vDisplays(2,1, "Open OK"); EA_uiInkey(2); } ucRet = EA_ucIfVoiceExist(hVoiceHandle, &ucIfExist); if(ucRet != EM_SUCCESS) { EA_vDisplays(2,1, "Test IfExist Err:%02x", ucRet); EA_ucCloseDevice(&hVoiceHandle); EA_uiInkey(0); return EM_ERROR; } else { if(ucIfExist == 1) //If Exist { for(i = 0; i < 8; i++) { ucRet = EA_ucPlayVoice(hVoiceHandle, i); if(ucRet != EM_SUCCESS) { EA_vDisplays(2,1, "Test play%d Err:%02x",i, ucRet); EA_uiInkey(0); } else { EA_vDisplays(2,1, "Test play%d OK", i); } do { EA_ucGetPlayStatus(hVoiceHandle, &ucStatus); }while(ucStatus == EM_VOICE_PLAYING); } } else { EA_vDisplays(2,1, "No voice module exists"); EA_uiInkey(0); } EA_ucCloseDevice(&hVoiceHandle); } #endif #if 0 switch (FV.Other.POSSTATFLAG) { case 0: break; case 1: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "系统要求下载参数"); PubDisplay(2, "请按确认键继续"); PubuiInkey(0); if ( PubDownPara() == NORMAL) { ACK(4,"00"); } else { NAK_info(4,"XX","交易失败"); } continue; case 2: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "系统要求上传状态"); PubDisplay(2, "请按确认键继续"); PubuiInkey(0); if (PubUploadState() == NORMAL) { ACK(4,"00"); } else { NAK_info(4,"XX","交易失败"); } continue; case 3: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "系统要求重新签到"); PubDisplay(2, "请按确认键继续"); PubuiInkey(0); if (PubBankLogin() == NORMAL) { ACK(4,"00"); } else { NAK_info(4,"XX","交易失败"); } continue; #ifdef EMVIC case 4: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "系统要求公钥下载"); PubDisplay(2, "请按确认键继续"); PubuiInkey(0); //if(PubYlConnect(&CommInfo)!=NORMAL) // continue; if (PubQueryPubilcKey () == 1) { PubDownPubilcKey (); } ACK(4, "00"); //PubDialOff (&CommInfo); continue; case 5: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "系统要求更新参数"); PubDisplay(2, "请按确认键继续"); PubuiInkey(0); if(PubYlConnect(&CommInfo)!=NORMAL) continue; //add by baijz 20110906 下载过程断电,需要删除EMV参数文件,否则会重复下载 EA_ucPFDel (FEmvPara); EA_ucPFCreate (FEmvPara, (sizeof (struct EMVPARA))); //add end PubDownEmvPara (); PubDialOff (&CommInfo); continue; #endif #ifdef TMS case 6: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "要求下载TMS参数"); PubDisplay(2, "请按确认键继续"); PubuiInkey(60); TmsDownPara(); continue; #endif case 7: if (ProCheckPOSSTATFLAG()!= NORMAL) { break; } EA_vCls(); PubDisplay(1, "要求下载卡BIN黑名单"); PubDisplay(2, "请按确认键继续"); PubuiInkey(60); PubDownCardBin(); continue; //JP add default: break; } FV.Other.POSSTATFLAG = 0;//chenjs20070104 add防止不小心死循环 CheckPOSSTATFLAGTimes = 0; WRITE_nVAR(FV.Other.POSSTATFLAG); #endif EA_ucGetDateTime(&datetime); sprintf(szTmpBuf , "%04d%02d%02d", datetime.usYear, datetime.ucMonth, datetime.ucDay); PubDialOff(&CommInfo); // 判断打印是否完成 PubJudePrintFinish(1); // 如果隔日了,就要求POS的操作员签到。 if(memcmp( szTmpBuf , FV.Other.gbLoginDate, 8 )) PubSetPoscfgcPosState(NO_LOGON); BUFCLR(szGetBuffer); VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer)); /* if (szGetBuffer[0] == NO_LOGON) { #ifdef TMS EA_vCls(); PubDisplayInv(1,"银联EMV应用"); PubDisplayCen(3,"按任意键签到"); PubDisplayCen(4,"按取消键切换应用"); uiRet = PubuiInkey(10); if (uiRet == EM_key_FUNC9|| uiRet == EM_key_CANCEL) { EA_vCls(); PubDisplayCen(2, "应用切换"); PubuiInkeyMs(500); PubDelAllBit(&iso); close_all_dev(); EA_vCls(); return EM_ERROR; } #endif if (PubLogin() != NORMAL) continue; } */ // 20060119 //for test dudj /* PubDisplay(3, "是否联机签到?"); if (PubuiInkey(2)!=EM_key_ENTER) sprintf( FV.Other.gbLoginDate , "%s", szTmpBuf); PubDisplay(3, ""); */ // 测试的时候打开。发布的封掉 /*sprintf( FV.Other.gbLoginDate , "%s", szTmpBuf); if(memcmp( szTmpBuf , FV.Other.gbLoginDate, 8 )) { if (PubBankLogin() != NORMAL) { PubSetPoscfgcPosState(NO_LOGON); } else { EA_ucGetDateTime(&datetime); sprintf(szTmpBuf , "%04d%02d%02d", datetime.usYear, datetime.ucMonth, datetime.ucDay); sprintf( FV.Other.gbLoginDate , "%s", szTmpBuf); WRITE_nVAR(FV.Other.gbLoginDate); } continue; }*/ BUFCLR(szGetBuffer); VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer)); if (szGetBuffer[0] == LOCK) { PubLock(); continue; } PubGetPoscfgcMenuTime(&cMenuTime); PubGetTermCapSet(); //add by chenjis 20130311 while (1) { if (szCMDChangeAppFlag == 2)//强制切换到应用2 { PubDelAllBit(&iso); close_all_dev(); return 2; } // PubSetExeReader(0); gbcECDefault = 0; PubDispIcon(); #ifdef TMS if (ProJudgeBaseDlaVer() == EM_SUCCESS) { // for 主控应用更新,添加一个新返回值2 ucRet = PubReturnUpdate() ; if (ucRet != EM_ERROR) { PubDelAllBit(&iso); close_all_dev(); return ucRet; } if (PubCheckRunState() == EM_SUCCESS) { PubDelAllBit(&iso); close_all_dev(); return EM_ERROR; } } #endif PubSetPoscfgcSettleEnd(1); /*设置结算未结束标志 */ EA_vCls(); nScreen = 0 ; //chenjs20060725 add down memset(&gbTrkInfo, 0, sizeof(struct TrackInfo)); memset(&gbCardinfo, 0, sizeof(struct CardConfig)); gbTrkInfo.cDoneFlag = 0; PubSetBankcMacChk(MAC_ECB); #ifdef EMVIC //ecash by wei gblTranAmt = 0l; BUFCLR(gbszTermData); gbszTermData[0] = FV.EmvStru.gbcMSD;//loyes #endif strcpy(gbszErrCode, ""); while (1) { gbnComposFlag =1; gbnSettleFlag=0; if (szCMDChangeAppFlag == 2)//强制切换到应用2 { PubDelAllBit(&iso); close_all_dev(); return 2; } PubSetPoscfgcSettleEnd(1); /*设置结算未结束标志 */ //EA_vCls(); nScreen = 0 ; //chenjs20060725 add down memset(&gbTrkInfo, 0, sizeof(struct TrackInfo)); memset(&gbCardinfo, 0, sizeof(struct CardConfig)); gbTrkInfo.cDoneFlag = 0; if (CMDCONT.Type == CMD_NONE) // CMD_NONE表示无命令 { nRet = GetCMD(); if (szCMDChangeAppFlag == 15) { PubDelAllBit(&iso); close_all_dev(); EA_ucCloseDevice(&gbhdCMDRS232); memcpy(CMDBUF , szCMDBuffer , CMDBUFLen); CMDBUF[CMDBUFLen] = 0 ; *nCmdLen = CMDBUFLen; return 15; } if (nRet != NORMAL) { //PubDisdoter(); PubDispLogo(); if( EA_ucKBHit_ped() == EM_key_HIT ) { uiKey = PubuiInkeyMs(500); #ifdef BZ /*标准版*/ if (uiKey == ENTER) #endif #ifdef Largevalue /*大额支付*/ if (uiKey == ENTER) #endif #ifdef NMLS /*内蒙移动零售*/ if (uiKey == EM_key_F1) /*应内蒙银商要求F1进入查询菜单wujianyuan modify 20130712*/ #endif #ifdef NMJF /*内蒙移动缴费*/ if (uiKey == EM_key_F1) /*应内蒙银商要求F1进入查询菜单wujianyuan modify 20130712*/ #endif { EA_vCls(); PubDisplay(2, "请输入安全密码:"); BUFCLR(szGetBuffer); PubGetSAFEPWD(szGetBuffer, sizeof(szGetBuffer)); PubKeyOff(); BUFCLR(szBuffer); if (PubGetNStr(3, BIGFONT, szBuffer, 6) == NORMAL && memcmp(szGetBuffer, szBuffer, 6) == 0) { PubKeyOn(); EA_ucCloseDevice(&gbhdCMDRS232); gbhdCMDRS232 = EM_NULL; PubSetupNew(); EA_vCls(); } EA_vCls(); PubKeyOn(); } if(uiKey==EM_key_9) { if (PubuiInkey(1) == '5') if (PubuiInkey(1) == '9') { EA_vSystemManage(EM_RESET);//add by wujy 20111020 实现重启 } } if (uiKey == EM_key_FUNC9) //多应用切换 { EA_ucCloseDevice(&gbhdCMDRS232); gbhdCMDRS232 = EM_NULL; PubDelAllBit(&iso); close_all_dev(); EA_vCls(); return EM_SUCCESS; } if (uiKey == EM_key_FUNC) { gbnComposFlag =0; memset(&TlvSendValue,0,sizeof(struct TLVVALUE)); PubGetBankszTerminal(TlvSendValue.szTerminal, 8); PubGetBankszCust(TlvSendValue.szCust, 15); BUFCLR(szGetBuffer); VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer)); if (szGetBuffer[0] == NO_LOGON) { if(PubLogin()!=NORMAL) { EA_vCls(); continue; } } BUFCLR(szGetBuffer); VERIFY_NORMAL(PubGetPoscfgcLoginState(szGetBuffer)); if (szGetBuffer[0] == NO_LOGON) { VERIFY_NORMAL(PubSetPoscfgcPosState(NO_LOGON)); if(PubBankLogin()== NORMAL) { VERIFY_NORMAL(PubSetPoscfgcPosState(LOGON)); VERIFY_NORMAL(PubSetPoscfgcLoginState(LOGON)); EA_ucGetDateTime(&datetime); BUFCLR(FV.Other.gbLoginDate); sprintf(FV.Other.gbLoginDate , "%04d%02d%02d", datetime.usYear, datetime.ucMonth, datetime.ucDay); WRITE_nVAR(FV.Other.gbLoginDate); } else { PubDialOff (&CommInfo); EA_vCls(); continue; } } EA_vCls(); PubDisplay (1, "1.消 费 2.撤 销"); PubDisplay (2, "3.退 货 4.预授权"); PubDisplay (3, "5.离 线 6.打 印"); PubDisplay (4, "7.管 理 8.其 它"); uiKey = PubuiInkey((char) cMenuTime); if(uiKey>='1'&&uiKey<='8') uiOption=uiKey-'0'; else { EA_vCls(); continue; } PubUpYLDataOld(); PubProcessOld(uiOption); EA_vCls(); continue; } } continue; } } if (CMDCONT.Type != CMD_NONE) { break; } } if (PubProcess(CMDCONT.Type) != CMD_INTERRUPT) { ClearCMD(); } EA_vLCDLightOff(); } return EM_SUCCESS; } }
int read_from_EFT(int *pLen, char *readstr) { char buffer[512]; ET_ProductInfo tProductInfo; uint unActLen; uchar ucRet; DevHandle hRS232Handle = EM_INVALID_HANDLE; unActLen = 0; #ifdef EPT_A9L memset(&tProductInfo, 0x00, sizeof(ET_ProductInfo)); EA_ucGetProductInfo(&tProductInfo); if ( memcmp(tProductInfo.acName , "E520" , 4) == 0 && tProductInfo.ucMachType == 2) { ucRet = EA_ucOpenDevice("COM3", 0, &hRS232Handle); } else { ucRet = EA_ucOpenDevice(SERIAL_PORT, 0, &hRS232Handle); } #else ucRet = EA_ucOpenDevice("COM", EM_io_PORT1, &hRS232Handle); #endif if (ucRet != EM_SUCCESS || hRS232Handle == EM_INVALID_HANDLE) { EA_vCls(); EA_vDisplay(2, "打开RS232口出错[%02x]", ucRet); EA_ucCloseDevice(&hRS232Handle); PubuiInkey(3); return (EXCEPTION); } ucRet = EA_ucInitRS232(hRS232Handle, EM_232_9600BPS, EM_232_NOPAR, EM_232_8DBS); if (ucRet != EM_SUCCESS) { EA_vCls(); EA_vDisplay(2, "RS232初始化错[%02x]", ucRet); EA_ucCloseDevice(&hRS232Handle); PubuiInkey(3); return (EXCEPTION); } while (1) { *pLen = 0; /* * read STX 0x02 until time out */ memset (buffer ,0 ,sizeof(buffer)); do { if(EM_key_HIT == EA_ucKBHit()) { EA_ucCloseDevice(&hRS232Handle); return (EXCEPTION); } EA_ucReadDeviceMs(hRS232Handle, 1, 10, buffer, &unActLen); } while (buffer[0] != 0x02); //read left data ucRet = EA_ucReadDeviceMs(hRS232Handle, 200, 10, buffer+1, &unActLen); if (ucRet != EM_SUCCESS || unActLen > 200) continue; // debug_print((char*)"SERIAL CMD", buffer, unActLen + 1);//FIXME *pLen = unActLen + 1; memcpy(readstr, buffer, *pLen); break; } //end of while EA_ucCloseDevice(&hRS232Handle); return (NORMAL); }
/***************************************************************** 函数原型:Device_Handle_Init() 功能描述:设备所有句柄初始化 参数描述: 返回值: OK ? NOTOK 作 者: 刘及华 日 期: 2012-11-24 修改历史: 日期 修改人 修改描述 ------ --------- ------------- *****************************************************************/ INT8U Device_Handle_Init(void) { uchar ucRet; uint cap_sd; if (EA_ucOpenDevice("RFCARD", EM_mifs_TYPEA, &hMifsHandle) != EM_SUCCESS) { lcddisperr("读卡器初始化失败"); return notok; } if ( EA_ucOpenDevice("PRINT", EM_io_REALMODE, &hDprinterHandle) != EM_SUCCESS ) { lcddisperr("获得打印操作句柄失败!"); return notok; } if ( EA_ucOpenDevice("USBD", EM_io_REALMODE, &hUSBDHandle) != EM_SUCCESS ) { lcddisperr("获得打印操作句柄失败!"); return notok; } // if ( EA_ucOpenDevice("WLM", 0, &hWLMHandle) != EM_SUCCESS ) // { // lcddisperr("获得GPRS句柄失败!"); // return notok; // } ///////////////////////////////////////////////打印机设置参数 ucRet = EA_ucInitPrinter(hDprinterHandle); if ( ucRet != EM_SUCCESS ) { EA_vDisplay(2, "初始化打印机芯失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_XSPACE, 0); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印字符间距设置失败"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_YSPACE, 8); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印行距设置失败"); return notok; } // ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_PAGESPACE, 578); ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_PAGESPACE , 180); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印页长度设置失败"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_ASCII_DOTTYPE, EM_prn_ASCIIDOT24X12); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印ASCII字符设置失败"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_ASCII_PRNTYPE, EM_prn_ASCIIPRN1X1); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印ASCII字符大小失败"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_HZ_DOTTYPE, EM_prn_HZDOT24X24); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印汉字设置失败!"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_HZ_PRNTYPE, EM_prn_HZPRN1X1); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印汉字大小设置失败"); return notok; } ucRet = EA_ucSetPrinterFormat(hDprinterHandle, EM_prn_PRNGRAY, 4); if ( ucRet != EM_SUCCESS ) { lcddisperr("打印灰度设置失败"); return notok; } /////////////////////////////////////////////////////////////////////////////初始化时候只设置一次 if (EA_ucOpenDevice("SAM1CARD", 0, &hSam1Handle) != EM_SUCCESS) { lcddisperr("PSAM卡初始化失败"); return notok; } // if (EA_ucOpenDevice("USERCARD", 0, &hCpuHandle) != EM_SUCCESS) // { // lcddisperr("CPU卡初始化失败"); // return notok; // } // if (EA_ucICInitModule(hCpuHandle, EM_ic_VOLDEFAULT, EM_ic_TCRMODE) != EM_SUCCESS) // { // lcddisperr("设置CPU规范失败"); // return notok; // } ucRet = EA_ucOpenDevice("USBD", 0, &hRS232Handle); if ( ucRet != EM_SUCCESS ) { (void)EA_ucCloseDevice(&hRS232Handle); lcddisperr("COM口初始化失败!"); return notok; } ucRet = EA_ucInitRS232(hRS232Handle, EM_232_115200BPS, EM_232_NOPAR, EM_232_8DBS); if ( ucRet != EM_SUCCESS ) { (void)EA_ucCloseDevice(&hRS232Handle); lcddisperr("COM口设置失败!"); return notok; } //获取SD卡信息 ucRet = EA_ucGetDiskInfo(EM_DISK_SDCARD, &ptDiskInfo); if ( ucRet != EM_SUCCESS ) { lcddisperr("请插入SD卡!"); return notok; } cap_sd = ptDiskInfo.ullSize / 0x100000; EA_vDisplay(3, " SD卡可用容量%dM", cap_sd); SleepMs(2000); if(cap_sd < 1) { lcddisperr("请及时清理SD中数据!"); Beeperr(); } // // 分配空间来存储磁盘的分区列表 // ptPartList = EA_pvMalloc(ptDiskInfo.uiPartNum * sizeof(ptPartList)); // if (!ptPartList) // { // lcddisperr("分配SD卡缓存区失败!"); // return notok; // } // // 获取磁盘的分区列表 // ucRet = EA_ucGetPartList(EM_DISK_SDCARD, ptDiskInfo.uiPartNum, &uiRealPartNum, ptPartList); // if (ucRet != EM_SUCCESS) // { // EA_vFree(ptPartList); // lcddisperr("获取SD卡列表失败!"); // return notok; // } // // EA_vDisplay(1, "分区数目:%d", ptDiskInfo.uiPartNum); // SleepMs(3000); ucRet = EA_ucGetPartInfo(EM_DISK_SDCARD, 0, &ptPartInfo); if (ucRet != EM_SUCCESS) { lcddisperr("获取SD卡分区信息失败!"); return notok; } return ok; }
// E5X0的DLM需要固定dlm_main这个名字,base才能调用 int dlm_main(void) { DevHandle phPinpad; uchar ucFd; uint uiCount, uiValidRec; char cMenuTime; uchar ucRet; int nLoginFailCnt; // 签到失败次数 int nSettleFailCnt; // 自动结算失败次数 ET_DATETIME dtTmp; char szBuffer[200]; char *CMDBUF=0 ;//yinzc add 2011-10-29 int *nCmdLen=0;//yinzc add 2011-10-29 int nRet;//yinzc add 2011-10-29 UINT uiKey;//yinzc add 2011-10-29 #ifdef EPT56X0 uint uiConfigInfo; #endif char cIsAutoVoid=0; // 是否需要自动发送冲正,开机若有遗留冲正,签到后自动发送一次 ProInitVar(); PubucLoadAllMfVar (MODULE_FILE_NAME, (void *)&FV, sizeof(FV)); #ifdef _ECASH_ PubInitRFReader(); #endif #ifdef EPT_A9L // EPT_A9L的FV内存写操作不记录日志 PubSetFVDBGMsgWrite(1); #endif #ifdef SGPL ///add by kevin 20150423 uchar ucFd1; uint uiCount3; #endif BUFCLR(szBuffer); // 导入def8583.h中的8583包定义。 if (PubImport8583(Iso8583Def) == EXCEPTION) { EA_vCls(); PubDisplay(3, "8583包导入出错"); PubDisplay(4, "请检查程序重新下装"); PubuiInkey(0); ASSERT_NORMAL(EXCEPTION); } if (PubucFirstRunProg(MODULE_FILE_NAME) == EM_SUCCESS) FV.gbcFirstFlag = YES; if (PubucFirstRunPara(MODULE_FILE_NAME, PARAM_FILE_NAME) == EM_SUCCESS) FV.gbcParaFirstFlag = YES; gbPrintHandle = NULL_HANDLE; CommInfo.gbHdl = NULL_HANDLE; EA_vCls(); PubGetPrinterType(&iPrinterType); gbcPrintType = iPrinterType; PubUsePinpadInside(FV.bank.cPinpadUseInside); PubGetPinpadType(&iPinpadType); ucRet = FV.bank.cIsDCCMode; FV.bank.cIsDCCMode = YES; // 20090928确保DCC模块存在的话,能先执行DCC模块的初始化动作 ucFd=PubRunBocccProc(CMD_INITPOS, (char *)"", 0); FV.bank.cIsDCCMode = ucRet; if (FV.gbcFirstFlag == YES || FV.gbcParaFirstFlag == YES) { if (FV.gbcFirstFlag == YES) { PubSetupFirst(); #ifdef EMVIC setup_first(); gbnNeedDownAIDParamAll = YES; gbnNeedDownAIDParam = YES;//[5/12/2015 shizd]modify gbnNeedDownCAPKeyAll = YES; gbnNeedDownCAPKey = YES;//[5/12/2015 shizd]modify #endif FV.gbcNeedDownParam = YES; } PubInitGlobal(); if (PubReadPara() != NORMAL) { PubDisplayCen(2, "读参数失败"); PubDisplayCen(3, "请下载参数"); PubDisplayCen(4, "或按<确认键>设置"); while (PubuiInkey(5) != ENTER) ; PubSetup(); } else { #ifdef TMS ProTmsRestorePara(); // 成功读入参数文件后,恢复TMS保存的相关参数 #endif } FV.gbcFirstFlag = NO; FV.gbcParaFirstFlag = NO; PubWriteMemFile(&FV, sizeof(FV)); PubRunBocccProc(CMD_SETFORCECHGPWD, &FV.bank.cForceChgPwd, 1); #ifdef TMS iInitTmsVar((void *)&EG_tTMSHead, sizeof(EG_tTMSHead)); // 支持TMS的如果系统管理员密码是默认值,则提示设置,否则不设置 if (memcmp(FV.gbszParSetupOperPwd, "000000", ADMIN_PWD_LEN) == 0) { ProSetManager(); ProSetCustom(); } #else ProSetManager(); ProSetCustom(); #endif } PubInitGlobal(); #ifdef TEL_FUNC if (FV.bank.cCommFlag == TCP) EA_ucSelectEnetOrFsk(ETH_USED); //获取以太网模块工作需要的SPI口,使用以太网通讯方式,将无法支持电话来电显示 else EA_ucSelectEnetOrFsk(FSK_USED); //获取FSK模块工作需要的SPI口 //电话模块初始化 TA_Tel_vInit(0x71,0x1b); // main_teltest(); // 电话功能测试 #endif #ifdef EMVIC #if EPT_A9L || EPT_M3 EA_EMV_vInit(); #endif #endif #ifdef TMS iRestoreAllTmsVar((void *)&EG_tTMSHead, sizeof(EG_tTMSHead)); // 载入TMS结构 #endif EA_vCls(); PubDisplayInv(1, "BOC POS"); PubDisplay(2, "自检..."); PubKeyOn(); /* EA_vCls(); PubDisplay(1, "自检:"); PubDisplayInv(2, "密码键盘"); PubDisplayCen(3, "打 印 机"); PubDisplayCen(4, "通 信 口"); PubDisplayInv(2, "密码键盘"); EA_vDelay(1); PubDisplayCen(2, "密码键盘"); PubDisplayInv(3, "打 印 机"); EA_vDelay(1); PubDisplayCen(3, "打 印 机"); PubDisplayInv(4, "通 信 口"); */ #ifdef _ECASH_ gblTranAmt = 0l; BUFCLR(gbszTermData); gbszTermData[0] = FV.EmvStru.gbcMSD;//loyes if (FV.bank.nRFReaderType == 0) ProAutoSetcBanknRFReaderType(); #endif PubDisplay(3, "按<取消>进入设置"); if (PubuiInkey(1) == EM_key_CANCEL) //如果误选通讯方式(无线),造成死机,在这里可以进行设置。 ProGetSuperOper(); PubDisplay(3, " "); while ((ucRet = PubOpenDevice((char *)"PINPAD", EM_io_IPP, &phPinpad)) != EM_SUCCESS) { PubClearAll(); PubDisplayInv(2, "打开密码键盘错"); PubDisplay(3, "请接好密码键盘%d %d", ucRet, FV.bank.cPinpadUseInside); EA_vBeepMs(50); PubuiInkey(1); } while ((PubGetPinpadVer(phPinpad, &iPinpadVer)) == 3) { PubClearAll(); PubDisplayInv(2, "请接好密码键盘"); PubDisplay(4, "[%02x]", FV.bank.cPinpadUseInside); EA_vBeepMs(50); PubuiInkey(1); } #ifdef EPT56X0 // 2007-9-18 将pinpad安全级别设置成默认级别 if (iPinpadVer == 2) { EA_pci_ucGetSecureConfig(phPinpad, EM_NULL, &uiConfigInfo); if (uiConfigInfo != EM_pin_DEFAULTCONFIG) { EA_pci_ucSetSecureConfig(phPinpad, EM_NULL, EM_pin_DEFAULTCONFIG); } } #endif PubSetPinTimer(phPinpad, 50); // liudy 将密码键盘超时时间设置为120秒 while ((ucRet = PubResetPinpad(phPinpad)) != EM_SUCCESS) { PubClearAll(); PubDisplayInv(2, "请接好密码键盘"); PubDisplay(3, "[%d][%02x]", ucRet, ucRet); EA_vBeepMs(50); PubuiInkey(1); } EA_ucCloseDevice(&phPinpad); //yinzc add below 2011-10-28 for compos #ifdef COMPOS //打开MISPOS的通讯接口 #ifdef EPT_A9L // ucRet = EA_ucOpenDevice("USBD", EM_io_PORT1, &gbhdCMDRS232); //debug // PubDisplay(2, "port[%s]", FV.szRecvPortName); // PubuiInkey(1); ucRet = EA_ucOpenDevice(FV.szRecvPortName, EM_io_PORT1, &gbhdCMDRS232); #else ucRet = EA_ucOpenDevice("COM", EM_io_PORT1, &gbhdCMDRS232); #endif if (ucRet != EM_SUCCESS) { EA_vCls(); PubDisplay(1,"无法打开通信端口!"); PubDisplay(2,"请重启设备"); EA_vBeepMs(1000); PubuiInkey(2); return EXCEPTION; } else { // ucRet = EA_ucInitRS232(gbhdCMDRS232,EM_232_9600BPS,EM_232_NOPAR ,EM_232_8DBS); ucRet = EA_ucInitRS232(gbhdCMDRS232,EM_232_115200BPS,EM_232_NOPAR ,EM_232_8DBS); ucRet = EA_ucCloseDevice(&gbhdCMDRS232); //gbhdCMDRS232 = EM_NULL; } #endif // end of above ////// #ifdef COMPOS if (FV.gbnComposType == 0)//yinzc add 2011-10-28 是否完全COMPOS模式 1--收银机通讯 0--POS通讯 PubInitComm(&CommInfo, AUTOCHECK); #endif PubRunBocccProc(CMD_IMPORTCARDBIN, NULL, 0);//091001 gbcPreState = 0; FV.gbNacInfo.cPreState = 0; // gbcPosState = NO_LOGON; //-zyf // gbcLoginState = NO_LOGON; nLoginFailCnt = 0; nSettleFailCnt = 0; cIsAutoVoid = 1; PubPreAutoVoid(); while (1) { EA_ucGetDateTime(&dtTmp); if (dtTmp.usYear != FV.gdtLastCheck.usYear || dtTmp.ucMonth != FV.gdtLastCheck.ucMonth || dtTmp.ucDay != FV.gdtLastCheck.ucDay) // 隔日重新签到,自动结算 { //linq del 20081203 中行规范未提及隔日签到的功能 // gbcPosState = NO_LOGON; // gbcLoginState = NO_LOGON; } FV.gdtLastCheck = dtTmp; if (FV.poscfg.cBatchState == YES) { EA_vCls(); PubDisplayInv(2, "请先结算再作交易"); ProAccumulate(); // 重新统计 PubuiInkey(0); } if (gbcPreState != 0) PubDialOff(&CommInfo); gbcPreState = 0; //mis不打印del by wangrm 2011-12-6 // PubJudePrintFinish(); //-zyfdel // if (gbcPosState == NO_LOGON) // { // // 重新获取菜单 // ProSetDefaultMenu(); // // if (PubLogin() != NORMAL) // continue; // else // EA_ucGetDateTime(&FV.gdtLastCheck); // } // [7/2/2013 zyf]del // // 签到失败5次则等待用户按键,防止无人值守时无谓的拨号,出现高额话费 // if (nLoginFailCnt >= 5) // { // EA_vCls(); // PubDisplay(2, "签到失败"); // PubDisplay(3, "请按任意键继续..."); // // ProucSetStopFlag(FV.bank.cDisableSave); // // PubuiInkey(0); // nLoginFailCnt = 0; // // ProucSetStopFlag(1); // // continue; // } // if (gbcLoginState == NO_LOGON) // { // if (PubBankLogin() != NORMAL) // { // nLoginFailCnt ++; // gbcPosState = NO_LOGON; // PubDialOff(&CommInfo); // PubClearAll(); // PubDisplay(3, "签到失败"); // PubuiInkey(TIPS_TIMEOUT); // continue; // } // // nLoginFailCnt = 0; // BUFCLR(szBuffer); // memcpy(szBuffer, gbszOper, OPER_NUM_LEN); // memcpy(szBuffer+OPER_NUM_LEN, gbszOperPwd, OPER_PWD_LEN); // PubRunBocccProc(CMD_SETCURRENTOPER, szBuffer, OPER_NUM_LEN + OPER_PWD_LEN); // } #ifdef COMPOS if ( nCmdLen != NULL && CMDBUF != NULL) { FV.CMDBUFLen = *nCmdLen; if (FV.CMDBUFLen >0 ) { memset(szCMDBuffer , 0 , sizeof(szCMDBuffer)); memcpy(szCMDBuffer , CMDBUF , FV.CMDBUFLen); FV.szGetCmdFlag = 15; } } #endif if (gbcPosState == LOCK) { PubLock(); continue; } switch (gbcPosCtrlCode) { case '1': // 在交易后下装参数 FV.gbcNeedDownParam = YES; gbcLoginState = NO_LOGON; gbcPosCtrlCode = 0; continue; case '2': // 强制结束批请求 保留 break; case '3': // 还有消息需要发送指示 下装参数时 终端批上送时不在此处 FV.gbcNeedDownParam = YES; gbcLoginState = NO_LOGON; continue; case '4': // 终端批号更新及签到标志 case '5': // 终端批号更新 #ifdef TMS PubTmsUpdate(2); // 在系统要求更新批次时,先做TMS更新处理 #endif PubUpdateBatchPorc(); if (strlen((char *)gbszBatchNum) > 0) { memcpy(FV.bankstate.szBatchNum, gbszBatchNum, 6); PubWriteMemFile(&FV.bankstate, sizeof(FV.bankstate)); } if (gbcPosCtrlCode == '4') gbcLoginState = NO_LOGON; gbcPosCtrlCode = 0; if (IsSupportBoccc() == YES && ( PubRunBocccProc(CMD_ISWATER_EDC,NULL,0) == NORMAL || PubRunBocccProc(CMD_ISWATER_DCC,NULL,0) == NORMAL ) )//090929卡司结账,有流水的情况才结算 { EA_vCls(); PubDisplayCen(1, "中行结账已完成"); PubDisplayCen(2, "将进行卡司结算"); PubDisplayCen(3, "请勿取消"); PubDisplayCen(4, "任意键继续"); PubuiInkey(10); PubRunBocccProc(CMD_DCCSETTLE, (char *)"\x00", 1); if (PubRunBocccProc(CMD_ISBJMODE, NULL, 0) != NORMAL) // 非北京模式 PubRunBocccProc(CMD_EDCSETTLE, (char *)"\x00", 1); } continue; case '6': // 要求终端签到标志 gbcLoginState = NO_LOGON; gbcPosCtrlCode = 0; continue; case '7': // POS终端应该提示终端操作员进行结帐动作 EA_vCls(); PubDisplay(2, "请先结算"); PubuiInkey(TIPS_TIMEOUT); break; default: break; } // 当POS上成功批准一笔基于EMV标准/基于PBOC电子现金IC卡离线消费交易后, // 如果此时POS上所保留的需要上送IST而未上送IST的交易笔数已经超过基本参数 // 中"POS中允许保存的未上送交易笔数"的值,则此时,POS必须主动拨号,将未上送交易全部上送到IST。 //add by liudy COMPOS不允许自主脱机上送 #ifndef COMPOS if ((FV.bank.nHasOfflineNum > 0) && (FV.bank.nHasOfflineNum >= FV.bank.nMaxOfflineNum)) { gbnTransType = OFFLINE_UPLOAD; PubSendOfflineTrans(); } #endif #ifdef TMS // 如果已TMS下载,进行更新处理 PubTmsUpdate(1); // 自动结账POS,若无流水,即可以进行程序更新 if (FV.gbcNeedDownloadTmsPara == YES) { // 下载TMS参数信息 if (PubDownTmsParam() == NORMAL) // 下载TMS参数 { FV.gbcNeedDownloadTms = YES; // 需要进行下载TMS FV.gbcNeedDownloadTmsPara = NO; // 不需要进行下载TMS参数 PubWriteMemFile(&FV.gbcNeedDownloadTms, sizeof(FV.gbcNeedDownloadTms)); PubWriteMemFile(&FV.gbcNeedDownloadTmsPara, sizeof(FV.gbcNeedDownloadTmsPara)); } } #endif // #ifdef EMVIC // if ((gbnNeedDownAIDParam == YES) && (memcmp(AUTHENTIC_VERSION, "\x13\x03", 2) >= 0)) // { // // 系统主动要求下载AID参数 // PubDownEmvPara(); // } // if ((gbnNeedDownCAPKey == YES) && (memcmp(AUTHENTIC_VERSION, "\x13\x03", 2) >= 0)) // { // // 系统主动要求下载认证中心公钥 // PubDownEmvCAPKey(); // } // #endif // 开机后自动发送一次冲正 // if (cIsAutoVoid == 1) // [7/2/2013 zyf]del mis不主动交易 // PubAutoVoid(); cIsAutoVoid = 0; #ifdef COMPOS FV.szCMDChangeAppFlag = 0x01; ClearCMD(); while (1) { FV.poscfg.cSettleEnd = 0; /* 设置结算结束标志 */ //EA_vCls(); // nScreen = 0 ; //chenjs20060725 add down memset(&gbTrkInfo, 0, sizeof(struct TrackInfo)); memset(&gbCardinfo, 0, sizeof(struct CardConfig)); gbTrkInfo.cDoneFlag = 0; //add by liudy 20140228增加显示余额的控制 if(iDisplayTimer == 1) { ulong passtime = 0; EA_ucGetPassTimer(gbhdlDisplayTimer,&passtime); if(passtime >= 3000) { if (iPinpadType == 1) { ClearPinpadDisp(gbPinpadHandle); if(gbPinpadHandle != NULL_HANDLE) { while (EA_ucCloseDevice(&gbPinpadHandle) != EM_SUCCESS) ; gbPinpadHandle = NULL_HANDLE; } } iDisplayTimer = 0; EA_ucCloseTimer(&gbhdlDisplayTimer); } } if (CMDCONT.Type == cmd_NONE) // CMD_NONE表示无命令 { nRet = GetCMD(); if (nRet != NORMAL) { PubDisplayInv(1, "中国银行"); PubDisplayCen(2, "等待接收数据-->"); PubDisplay(3, " "); PubDisplay(4, " "); EA_ucLKeySwitch(EM_key_ENLKEY); if (EA_ucKBHit_ped() == EM_key_HIT) { uiKey = PubuiInkey(5); if (uiKey == EM_key_FUNC) { EA_vCls(); PubDisplay (1, "1.签到2.重打印"); PubDisplay (2, "3.查询交易明细"); PubDisplay (3, "4.按流水号查询交易"); PubDisplay (4, "5.结算"); ucRet = PubuiInkey(10); switch (ucRet) { case '1': EA_vCls(); PubLogin(); break; case '2': EA_vCls(); ProPrintManageExt(1); break; case '3': EA_vCls(); PubCheckLsExt(4); break; case '4': EA_vCls(); PubCheckLsExt(2); break; case '5': EA_vCls(); ProSettle_POS(); break; default: break; } } } EA_ucLKeySwitch(EM_key_DISLKEY); continue; } } if (CMDCONT.Type != cmd_NONE) { break; } } // [6/8/2013 zyf] if (EA_ucPFOpen((uchar *) WATERFILE, &ucFd) == EM_SUCCESS) { uiCount = 0; EA_ucPFInfo(ucFd, EM_ffs_FREEREC, &uiCount); uiValidRec = 0; EA_ucPFInfo(ucFd, EM_ffs_VALIDREC, &uiValidRec); EA_ucPFClose(ucFd); if (uiCount < 5 || uiValidRec >= 300) { // [6/7/2013 zyf] 存储满自动清流水 EA_vCls(); PubDisplayInv(1, "系统报告"); PubDisplay(2, "存储满,清流水中"); NAK_info(4, (char *)"XX",(char *)"交易失败"); PubuiInkey(1); ProDelWater2(); continue; } } if (PubProcess(CMDCONT.Type) != cmd_INTERRUPT) { ClearCMD(); } #else PubDialOff(&CommInfo); // 20130107 存储满判断从前面调整到这里,避免存储满自动结算,系统返回需要重新签到时无法进入签到的问题 // 自动结算5次则等待用户按键,防止无谓的拨号,出现高额话费 if (nSettleFailCnt >= 5) { EA_vCls(); PubDisplay(2, "结算失败"); PubDisplay(3, "请按任意键继续..."); ProucSetStopFlag(FV.bank.cDisableSave); PubuiInkey(0); nSettleFailCnt = 0; ProucSetStopFlag(1); continue; } if (EA_ucPFOpen((uchar *) WATERFILE, &ucFd) == EM_SUCCESS) { uiCount = 0; EA_ucPFInfo(ucFd, EM_ffs_FREEREC, &uiCount); uiValidRec = 0; EA_ucPFInfo(ucFd, EM_ffs_VALIDREC, &uiValidRec); EA_ucPFClose(ucFd); #ifdef SGPL ///modify by kevin 20150423 if (EA_ucPFOpen((uchar *)YLSIGNWATER, &ucFd1) == EM_SUCCESS) { uiCount3 = 0; EA_ucPFInfo(ucFd, EM_ffs_VALIDREC, &uiCount3); //查询剩余笔数 } if (uiCount < 5 || uiValidRec >= 300 || uiCount3 >= FV.Other.gbnForceSettleSignNums) #else if (uiCount < 5 || uiValidRec >= 300) #endif //if (uiCount < 5 || uiValidRec >= 300) { EA_vCls(); PubDisplayInv(1, "系统报告"); PubDisplay(2, "存储满,请先结算"); PubDisplay(3, "自动结算..."); if (PubuiInkey(TIPS_TIMEOUT) != EM_key_FUNC1) { if (FV.poscfg.cBatchState == YES) // 自动结算支持披上送的断点续传 PubBatchUp(); else { if (PubSettle() == EXCEPTION) nSettleFailCnt++; else nSettleFailCnt = 0; // 结算成功的 PubRunBocccProc(CMD_DCCSETTLE, (char *)"\x00", 1); if (PubRunBocccProc(CMD_ISBJMODE, NULL, 0) != NORMAL) // 非北京模式 PubRunBocccProc(CMD_EDCSETTLE, (char *)"\x00", 1); } continue; } } #ifdef SGPL EA_ucPFClose(ucFd1); #endif } cMenuTime = FV.poscfg.cMenuTime; // linq add 20081117 重新获取菜单 ProSetDefaultMenu(); PubLoadMenu(gbszMenuResource, MenuResource); if (QUIT_APP == PubProcMenu(MenuResource, (char *)"中国银行")) { PubucUnloadAllMfVar(MODULE_FILE_NAME); return NORMAL; } #endif } }