⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcsample.cpp

📁 深圳远望谷804读写器DEMO 深圳远望谷804读写器DEMO
💻 CPP
字号:
// VCsample.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "VCsample.h"
#include "VCsampleDlg.h"
#include "XCRFAPI.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CVCsampleApp

BEGIN_MESSAGE_MAP(CVCsampleApp, CWinApp)
	//{{AFX_MSG_MAP(CVCsampleApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVCsampleApp construction

CVCsampleApp::CVCsampleApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CVCsampleApp object

CVCsampleApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CVCsampleApp initialization

BOOL CVCsampleApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	CVCsampleDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

CString  CVCsampleApp::Error_800 ( int errorNO )
{
	CString szTemp ;

	if ( errorNO <= 0 && errorNO >= - 20 )
	{
		switch ( errorNO )
		{
		case 0: 
			szTemp = "Return value error!";
			break;
			
		case -1:
			szTemp = "Communication port handle error!";
			break;
			
		case -2: 
			szTemp = "The length of user data error!";
			break;
			
		case -3:
			szTemp = "The address of  user data error!";
			break;
			
		case -4: 
			szTemp = "The length of receive data error!";
			break;
			
		case -5:
			szTemp = "Data format error!";
			break;
			
		case -6: 
			szTemp = "Failed to send command!";
			break;
			
		case -7:
			szTemp = "Failed to read or write data!";
			break;
			
		case -8: 
			szTemp =  "Failed to identify Tag ID!";
			break;
			
		case -9:
			szTemp = "Tag type is unknown!";
			break;
			
		case -10: 
			szTemp = "Communication port have been opened. The port handle is INVALID_HANDLE_VALUE!";
			break;
			
		case -11:
			szTemp = "Not find Configuration file. Cannot initiate the main parameters!";
			break;
			
		case -12: 
			szTemp = "Failed to connect!";
			break;
			
		case -13:
			szTemp = "Failed to open the communicate port!";
			break;
			
		case -14: 
			szTemp = "Failed to close the communicate port!";
			break;
			
		case -15:
			szTemp = "Length of the query/configuration parameter data is over!";
			break;
			
		case -16: 
			szTemp = "Failed to query/Set parameter!";
			break;
			
		case -17:
			szTemp = "Invalid reader type!";
			break;

		case -20: 
			szTemp = "Other error!";
			break;
			
		default:
			szTemp = "Other unknow error!";
			break;
		}
	}
	else if ( errorNO <= 4013 && errorNO >= 1001 )
	{
		switch ( errorNO )
		{
		case ERROR_Reader_01H:
			szTemp = "Reader FPGA/DSP software Version Error!";
			break;
			
		case ERROR_Reader_02H:
			szTemp = "Reader base band hardware Error!";
			break;
			
		case ERROR_Reader_03H:
			szTemp = "radio-frequency  board hardware Error!";
			break;
			
		case ERROR_Reader_04H:
			szTemp = "Reader system parameter table Error!";
			break;
			
		case ERROR_Reader_05H:
			szTemp = "Reader FPGA Self Test Error!";
			break;
			
		case ERROR_Reader_06H:
			szTemp = "Reader radio-frequency  board Self Test Error!";
			break;
			
		case ERROR_Reader_07H:
			szTemp = "Reader Ethernet Test Error!";
			break;
			
		case ERROR_Reader_08H:
			szTemp = "Reader Real Time Clock Error!";
			break;
			
		case ERROR_Reader_09H:
			szTemp = "Reader external memory Test Error!";
			break;
			
		case ERROR_Reader_11H:
			szTemp = "Reader Operation password Error!";
			break;
			
		case ERROR_Reader_12H:
			szTemp = "Antenna Numbe Error!";
			break;

		case ERROR_Reader_13H:
			szTemp = "Reader is on test mode!";
			break;
			
		case ERROR_Reader_14H:
			szTemp = "Reader internal flash fail!";
			break;
			
		case ERROR_Reader_15H:
			szTemp = "Reader is on tag operation !";
			break;
			
		case ERROR_Reader_16H:
			szTemp = "Reader operation error!";
			break;
						
		case ERROR_CommandData_20H:
			szTemp = "received command or data is incomplete!";
			break;
			
		case ERROR_CommandData_21H:
			szTemp = "received command or data CRC check error!";
			break;
			
		case ERROR_CommandData_22H:
			szTemp = "Command type is not correspond to current reader type!";
			break;
			
		case ERROR_CommandData_23H:
			szTemp = "Command type is not correspond to protocol of current tags!";
			break;
			
		case ERROR_CommandData_24H:
			szTemp = "Command parameter table error!";
			break;

		case ERROR_CommandData_25H:
			szTemp ="Command data structure error!";
			break;
			
		case ERROR_CommandData_26H:
			szTemp = "Command error!";
			break;
			
		case ERROR_EPCTag_60H:
			szTemp = "No tag response,or the tag is absent!";
			break;
			
		case ERROR_EPCTag_61H:
			szTemp = "operation storage is inexistent!";
			break;
			
		case ERROR_EPCTag_62H:
			szTemp = "Tag operation address overflow!";
			break;
			
		case ERROR_EPCTag_63H:
			szTemp = "operation storage is locked!";
			break;
			
		case ERROR_EPCTag_64H:
			szTemp = "Tag Access password error!";
			break;
			
		case ERROR_EPCTag_65H:
			szTemp = "Tag destroy password error!";
			break;

		case ERROR_EPCTag_66H:
			szTemp = "Operation is ended error!";
			break;
			
		case ERROR_EPCTag_67H:
			szTemp = "Operation is error!";
			break;
			
		case ERROR_EPCTag_68H:
			szTemp = "Tag is not initialized";
			break;
			
		case ERROR_EPCTag_69H:
			szTemp = "Tag return unknown error!";
			break;

		case ERROR_ISO6BTag_90H:
			szTemp = "No tag response,or the tag is absent!";
			break;
			
		case ERROR_ISO6BTag_91H:
			szTemp = "Not support this command!";
			break;
			
		case ERROR_ISO6BTag_92H:
			szTemp = "The command can not be recognised.Maybe the command format is error!";
			break;
			
		case ERROR_ISO6BTag_93H:
			szTemp = "Not support this option!";
			break;
			
		case ERROR_ISO6BTag_94H:
			szTemp = "Unknow error!";
			break;
			
		case ERROR_ISO6BTag_95H:
			szTemp = "Can not access specified  block!";
			break;
			
		case ERROR_ISO6BTag_96H:
			szTemp = "The block is locked.It can not be locked again!";
			break;
			
		case ERROR_ISO6BTag_97H:
			szTemp = "The block is locked.The content cannot be changed!";
			break;
			
		case ERROR_ISO6BTag_98H:
			szTemp = "Block programme failed!";			
			break;
			
		case ERROR_ISO6BTag_99H:
			szTemp = "Lock block failed!";			
			break;
		
		case ERROR_ISO6BTag_9AH:
			szTemp = "Operation is not finished!";			
			break;
			
		case ERROR_ISO6BTag_9BH:
			szTemp = "Operation is not finished!";
			break;
			
		case ERROR_ISO6BTag_9CH:
			szTemp = "CRC error!";
			break;

		default:
			szTemp = "Other unknow error!";   
			break;
		}
	}
	else
	{
		szTemp = "Other unknow error!";     
	}

	return szTemp;
}

char CVCsampleApp::_atoi_j(char ch)
{
	if ( ch >= 48 && ch <= 57 )
	{
		return ( ch - 48 );
	}
	if ( ch >= 65 && ch <= 70  )
	{
		return ( ch - 55 );
	}
	if ( ch >= 97 && ch <= 102  )
	{
		return ( ch - 87 );
	}
	return -1;
}

long CVCsampleApp::sz20x(CString *szIn, char *chOut)
{
	long lLen = szIn->GetLength ( );

	if ( lLen % 2 != 0 )
	{
		return -1;
	}
	
	char ch [ 512 ];
	memset ( ch, 0, 512 );

	for ( int i = 0; i < ( int ) ( lLen / 2 ); i++ )
	{
		if ( ( _atoi_j ( szIn -> GetAt ( 2 * i ) ) == -1 ) 
			|| ( _atoi_j ( szIn->GetAt ( 2 * i + 1 ) ) == -1 ) )
		{
			return -1;
		}
		ch [ i ] = ( (  ( _atoi_j ( szIn->GetAt( 2 * i ) ) ) << 4 ) & 0xF0 )
					| ( (  _atoi_j ( szIn->GetAt ( 2 * i + 1 ) ) ) & 0x0F );
	}

	if ( chOut == NULL)
	{
		return -1;
	}

	memcpy ( chOut, ch, lLen / 2 + 1 );
	return  lLen / 2;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -