📄 reader.cpp
字号:
// Reader.cpp: implementation of the CReader class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//#include "cos.h"
#include "Reader.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CReader::CReader()
{
//m_portstate=FALSE;
//m_rfstate=FALSE;
m_comm=AfxGetApp()->GetProfileString("Interface option","COM PORT","COM1");
m_baud=AfxGetApp()->GetProfileString("Interface option","BAUD","9600");
m_data=AfxGetApp()->GetProfileString("Interface option","DATA","8");
m_parity=AfxGetApp()->GetProfileString("Interface option","PARITY","odd");
m_stop=AfxGetApp()->GetProfileString("Interface option","STOP","1");
}
CReader::~CReader()
{
}
/*
void CCOSDlg::OnOk()
{
// TODO: Add your control notification handler code here
m_bslf9000on=FALSE;
//close_con(ICC_CONNECTOR);
FWRC m_rfoff;
m_rfoff = rf_off();
if(m_rfoff==COD_E_GENERAL)
{
MessageBox("RF is problem to off!",NULL,MB_ICONERROR);
}
if(CODCloseSerialInterface()==FALSE)
{
MessageBox("Can't close COM port",NULL,MB_ICONERROR);
}
OnOK();
}
void CCOSDlg::OnSetupInterfacesettingCom()
{
// TODO: Add your command handler code here
if(m_ComDlg.DoModal()==IDOK)
{
if(m_bslf9000on)
{
m_bslf9000on=FALSE;
FWRC m_rfoff;
m_rfoff = rf_off();
if(m_rfoff==COD_E_GENERAL)
{
MessageBox("RF is problem to off!",NULL,MB_ICONERROR);
}
if(m_rfoff==COD_S_OK)
{
MessageBox("RF is off!",NULL,MB_ICONERROR);
}
if(CODCloseSerialInterface()==FALSE)
{
MessageBox("Can't close COM port",NULL,MB_ICONERROR);
}
}
m_csCOM=m_ComDlg.m_csCOM;
m_iBaudRate=(atoi(m_ComDlg.m_csBaudRate));
m_csCOM=AfxGetApp()->GetProfileString("Interface option","COM PORT","COM1");
m_pchcom=(LPCTSTR)m_csCOM;
m_csBaudRate=AfxGetApp()->GetProfileString("Interface option","BAUD RATE","9600");
m_pchBaudRate=(LPCTSTR)m_csBaudRate;
CODInitSerialInterface((char*)m_pchcom,(char*)m_pchBaudRate,"odd","8","1");
if(CODOpenSerialInterface()==FALSE)
{
MessageBox("Can't open COM port",NULL,MB_ICONERROR);
}
else
{
FWRC m_fwrcreset;
m_fwrcreset=slf9000_soft_reset();
if(m_fwrcreset==COD_E_GENERAL)
{
MessageBox("Reader cannot reset!",NULL,MB_ICONERROR);
}
if(m_fwrcreset==COD_S_OK)
{
m_bslf9000on=TRUE;
MessageBox("Reader resetOK!",NULL,MB_ICONERROR);
}
}
}
}
void CCOSDlg::OnCloseupChipselCombo()
{
// TODO: Add your control notification handler code here
m_pChipSel=(CComboBox*)GetDlgItem(IDC_CHIPSEL_COMBO);
m_iChipSelIndex=m_pChipSel->GetCurSel();
m_pChipSel->GetLBText(m_iChipSelIndex,m_csChipSel);
AfxGetApp()->WriteProfileString("Chip Card Select","Chip Card",m_csChipSel);
AfxGetApp()->WriteProfileInt("Chip Card Select","index",m_iChipSelIndex);
}
void CCOSDlg::OnResetButton()
{
// TODO: Add your control notification handler code her
CODCloseSerialInterface();
Sleep(1000);
CODOpenSerialInterface();
int i;
for(i=0;i<ValidPiccNo;i++)
{
picc_param[i].m_csPupi="";
picc_param[i].m_byCID=1;
}
m_iCID = 1;
m_iValidPicc=0;
ValidPiccNo=0;
m_iPupi=0;
TimeofCollision=0;
G=0;
}
void CCOSDlg::OnTypeB()
{
// TODO: Add your command handler code here
wr_cll_reg(0x12,0x20);
wr_cll_reg(0x18,0xA2);
wr_cll_reg(0x19,0x07);
wr_cll_reg(0x1B,0xA1);
wr_cll_reg(0x11,0x01);
wr_cll_reg(0x0E,0xFF);
wr_cll_reg(0x0F,0xFF);
}
*/
BOOL CReader::opencomm()
{
initcomm();
return CODOpenSerialInterface();
}
BOOL CReader::closecomm()
{
return CODCloseSerialInterface();
}
void CReader::initcomm()
{
const char* stop;
const char* datanumber;
const char* parity;
const char* comm;
const char* baud;
stop=(LPCSTR)m_stop;
datanumber=(LPCSTR)m_data;
parity=(LPCSTR)m_parity;
comm=(LPCSTR)m_comm;
baud=(LPCSTR)m_baud;
CODInitSerialInterface((char*)comm,(char*)baud,(char*)parity,(char*)datanumber,(char*)stop);
}
BOOL CReader::rfon()
{
if(rf_on()==COD_S_OK)
{
return TRUE;
}
else
{
return FALSE;
}
}
BOOL CReader::rfoff()
{
if(rf_off()==COD_S_OK)
{
return TRUE;
}
else
{
return FALSE;
}
}
void CReader::typeBmode()
{
wr_cll_reg(0x12,0x20);
wr_cll_reg(0x18,0xA2);
wr_cll_reg(0x19,0x07);
wr_cll_reg(0x1B,0xA1);
wr_cll_reg(0x0E,0xFF);
wr_cll_reg(0x0F,0xFF);
wr_cll_reg(0x01,0x60);
wr_cll_reg(0x05,0x00);
wr_cll_reg(0x03,0x00);
wr_cll_reg(0x06,0x00);
wr_cll_reg(0x02,0xC4);
wr_cll_reg(0x11,0x01);
}
BOOL CReader::readerreset()
{
closecomm();
Sleep(3000);
if (!opencomm())
{
AfxMessageBox("Reader setup Error!",MB_OK);
return FALSE;
}
if(!rfon())
{
AfxMessageBox("RF On Error!",MB_OK);
return FALSE;
}
typeBmode();
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -