#ifndef _PROTOCOL_H_
#define _PROTOCOL_H_
///////////////////错误返回码////////////////////
#define PS_OK 0x00 //执行成功
#define PS_COMM_ERR 0x01 //数据包接收错误
#define PS_NO_FINGER 0x02 //传感器上没有手指
#define PS_GET_IMG_ERR 0x03 //录取指纹图像失败
#define PS_FP_TOO_DRY 0x04 //指纹太淡
#define PS_FP_TOO_WET 0x05 //指纹太模糊
#define PS_FP_DISORDER 0x06 //指纹太乱
#define PS_LITTLE_FEATURE 0x07 //指纹特征点太少
#define PS_NOT_MATCH 0x08 //指纹不匹配
#define PS_NOT_SEARCHED 0x09 //没搜索到指纹
#define PS_MERGE_ERR 0x0a //特征合并失败
#define PS_ADDRESS_OVER 0x0b //地址号超出指纹范围
#define PS_READ_ERR 0x0c //从指纹库读取模块出错
#define PS_UP_TEMP_ERR 0x0d //上传特征失败
#define PS_RECV_ERR 0x0e //模块不能接收后续数据包
#define PS_UP_IMG_ERR 0x0f //上传图像失败
#define PS_DEL_TEMP_ERR 0x10 //删除模版失败
#define PS_CLEAR_TEMP_ERR 0x11 //清空指纹库失败
#define PS_SLEEP_ERR 0x12 //不能进入休眠
#define PS_INVALID_PASSWORD 0x13 //口令不正确
#define PS_RESET_ERR 0x14 //系统复位失败
#define PS_INVALID_IMAGE 0x15 //无效指纹图像
#define PS_HANGOVER_UNREMOVE 0X17 //
#ifdef _OT_CPP_
extern "C"
{
#endif
//1
int WINAPI ZAZOpenDeviceEx(HANDLE* pHandle, int nDeviceType,int iCom,int iBaud,int nPackageSize/*=2*/,int iDevNum/*=0*/);
//2
int WINAPI ZAZCloseDeviceEx(HANDLE hHandle);
//3
int WINAPI ZAZVfyPwd(HANDLE hHandle,int nAddr,unsigned char* pPassword);
//4
int WINAPI ZAZGetImage(HANDLE hHandle,int nAddr);
//5
int WINAPI ZAZGenChar(HANDLE hHandle,int nAddr,int iBufferID);
//6
int WINAPI ZAZMatch(HANDLE hHandle,int nAddr,int* iScore);
//7
int WINAPI ZAZSearch(HANDLE hHandle,int nAddr,int iBufferID, int iStartPage,
int iPageNum, int *iMbAddress,int *iscore/*=NULL*/);
//8
int WINAPI ZAZHighSpeedSearch(HANDLE hHandle,int nAddr,int iBufferID,
int iStartPage, int iPageNum, int *iMbAddress,int *iscore/*=NULL*/);
//9
int WINAPI ZAZRegModule(HANDLE hHandle,int nAddr);
//10
int WINAPI ZAZStoreChar(HANDLE hHandle,int nAddr,int iBufferID, int iPageID);
//11
int WINAPI ZAZDelChar(HANDLE hHandle,int nAddr,int iStartPageID,int nDelPageNum);
//12
int WINAPI ZAZEmpty(HANDLE hHandle,int nAddr);
//13
int WINAPI ZAZReadParTable(HANDLE hHandle,int nAddr,unsigned char* pParTable);
//14
int WINAPI ZAZReadInfPage(HANDLE hHandle,int nAddr, unsigned char* pInf);
//15
int WINAPI ZAZTemplateNum(HANDLE hHandle,int nAddr,int *iMbNum);
//16
int WINAPI ZAZGetRandomData(HANDLE hHandle,int nAddr,unsigned char* pRandom);
//17
int WINAPI ZAZReadIndexTable(HANDLE hHandle,int nAddr,int nPage,unsigned char* UserContent);
//18
int WINAPI ZAZDoUserDefine(HANDLE hHandle,int nAddr,int GPIO,int STATE);
//19
int WINAPI ZAZSetledsound(HANDLE hHandle,int nAddr,unsigned char red, unsigned char green,
unsigned char sound, unsigned char moveflag,int timecount);
//20
int WINAPI ZAZSetCharLen( int nLen);
//21
int WINAPI ZAZGetCharLen(int *pnLen);
//22
int WINAPI ZAZLoadChar(HANDLE hHandle,int nAddr,int iBufferID,int iPageID);
//23
int WINAPI ZAZUpChar(HANDLE hHandle,int nAddr,int iBufferID, unsigned char* pTemplet, int* iTempletLength);
//24
int WINAPI ZAZDownChar(HANDLE hHandle,int nAddr,int iBufferID, unsigned char* pTemplet, int iTempletLength);
//25
int WINAPI ZAZSetIMGLen( int img_x,int img_y);
//26
int WINAPI ZAZGetIMGLen(int *img_x,int *img_y);
//27
int WINAPI ZAZUpImage(HANDLE hHandle,int nAddr,unsigned char* pImageData, int* iImageLength);
//28
int WINAPI ZAZDownImage(HANDLE hHandle,int nAddr,unsigned char *pImageData, int iLength);
//29
int WINAPI ZAZImgData2BMP(unsigned char* pImgData,const char* pImageFile);
//30
int WINAPI ZAZGetImgDataFromBMP(HANDLE hHandle,const char *pImageFile,unsigned char *pImageData,int *pnImageLen);
//31
int WINAPI ZAZReadInfo(HANDLE hHandle,int nAddr,int nPage,unsigned char* UserContent);
//32
int WINAPI ZAZWriteInfo(HANDLE hHandle,int nAddr,int nPage,unsigned char* UserContent);
//33
int WINAPI ZAZSetBaud(HANDLE hHandle,int nAddr,int nBaudNum);
//34
int WINAPI ZAZSetSecurLevel(HANDLE hHandle,int nAddr,int nLevel);
//35
int WINAPI ZAZSetPacketSize(HANDLE hHandle,int nAddr,int nSize);
//36
int WINAPI ZAZSetBLS(HANDLE hHandle,int nAddr,int nBaudNum,int nLevel,int nSize);
//37
int WINAPI ZAZWriteFile(unsigned char* pTemplate, int iTempletLength,const char* pFileName);
//38
int WINAPI ZAZReadFile(unsigned char* pTemplate, int iTempletLength,const char* pFileName);
//39
int WINAPI ZAZByteTOBase64(unsigned char* pInput, int inputLen,char * pOutput);
//40
int WINAPI ZAZBase64TOByte( char* pInput, int *inputLen,unsigned char * pOutput);
//41
int WINAPI ZAZByteToHexstr(unsigned char* pInput, int inputLen,char * pOutput);
//42
int WINAPI ZAZHexstrToByte(char *pInput, int *inputLen,unsigned char * pOutput);
//43
int WINAPI ZAZSetPwd(HANDLE hHandle,int nAddr,unsigned char* pPassword);
//44
int WINAPI ZAZBurnCode(HANDLE hHandle,int nAddr,int nType,unsigned char *pImageData, int iLength);
//45
int WINAPI ZAZClear5xxFLAG( HANDLE hHandle, int nAddr );
//46
int WINAPI ZAZShowFingerData(HWND hWnd,unsigned char *pFingerData);
//47
int WINAPI ZAZUpChar2File(HANDLE hHandle,int nAddr,int iBufferID, const char* pFileName);
//48
int WINAPI ZAZDownCharFromFile(HANDLE hHandle,int nAddr,int iBufferID, const char* pFileName);
//49
void WINAPI ZAZErr2Str(int nErrCode, char* g_sErrorString );
//CString WINAPI ZAZErr2Str(int nErrCode);
//50
int WINAPI ZAZColorBMP(const char *filedst,const char *BMPSRC, int DISPCOLOR);
#ifdef _OT_CPP_
}
#endif
#endif
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <Windows.h>
#include "FingerProtocol.h"
#pragma comment(lib,"Finger/ZAZAPIt.lib")
using namespace std;
int main()
{
HANDLE handle = NULL;
int nAddress = 0xffffffff;
int timeOut = 0;
int imgLen = 0;
unsigned char imgData[256 * 288];//256x288
//打开指纹设备
int ret = ZAZOpenDeviceEx(&handle,2,0,9600,2,0);
cout << "指纹模块打开结果:" << ret << endl;
if(ret != 0)
{
return 0;
}
ret = PS_NO_FINGER;
while (ret == PS_NO_FINGER)
{
//获取图像
ret = ZAZGetImage(handle, nAddress);
cout << "ZAZGetImage:" << ret << endl;
timeOut++;
if (timeOut > 100)
{
return 0;
//break;
}
}
//上传设备采集到的指纹数据
ret = ZAZUpImage(handle, nAddress, imgData, &imgLen);
cout << "ZAZUpImage:" << ret << endl;
//指纹数据转 BMP 格式保存
ret = ZAZImgData2BMP(imgData,"C:\finger.bmp");
cout << "ZAZImgData2BMP:" << ret << endl;
//关闭设备
ret = ZAZCloseDeviceEx(handle);
cout << "ZAZCloseDeviceEx:" << ret << endl;
system("pause");
return 0;
}