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

📄 pccomm.c

📁 指纹识别源代码,用于智能门紧,还有配合MF800卡使用
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "reg58.h"
#include "intrins.h"

#define _PCCOMM_C_
#include "pccomm.h"

#include "event.h"
#include "rxd.h"
#include "system.h"
#include "sram.h"
#include "pcrxd.h"
#include "define.h"
#include "finger.h"
#include "clock.h"
#include "lcd.h"
#include "timer.h"
#include "keypad.h"
#include "user.h"
#include "setup.h"
#include "inout.h"
#include "373.h"
#include "ts.h"
///////////////////////////////////////////////////////////
bit removeuserflag,removeeventflag;
unsigned char data getpcoktimer;
///////////////////////////////////////////////////////////
/*bit getpcok()
{
	unsigned char temptime;
	temptime=timerh;
	while((timerh-temptime)<TWAITPCOKTIME)
	{
		if(rxd0packflag)
		{
			return TRUE;
		}
	}
	return FALSE;

}*/
///////////////////////////////////////////////////////////
void pcgetstate()
{
	//idata2idata(datetime,uart0buff+PCPACKAGEPARAMP,8);
	idata2uart0(datetime,PCPACKAGEPARAMP,8);
	uart0buff[PCPACKAGEPARAMP+8]=readsecumode();
	uart0buff[PCPACKAGEPARAMP+9]=readbaudrate();
	uart0buff[PCPACKAGEPARAMP+10]=readpinkeyin();
	uart0buff[PCPACKAGEPARAMP+11]=readapbmode();
	uart0buff[PCPACKAGEPARAMP+12]=VERHIGH;
	uart0buff[PCPACKAGEPARAMP+13]=VERLOW;
	ackpccmd(PCAGETSTATE,RETOK,14);
}
///////////////////////////////////////////////////////////
void fpdatapc2fim()
{
	unsigned short i;
	unsigned char UART0DATA * pchar;

	pchar=uart0buff+499;
	for(i=0;i<480;i++)
	{
		*(pchar+24)=*pchar;
		pchar--;
	}
}
///////////////////////////////////////////////////////////
//add a new user with finger print 
void pcsetnewuser()
{
	if(uart0buff[PCPACKAGEPARAMP+7]&0XF)	//has fp data
	{
		uart02idata(PCPACKAGEPARAMP,tempbuff,8);
		if(getuserbytempid())
		{
			//ackpccmd(PCASETNEWUSER,RETUSEREXIST,0);		;050827
			//return;										;050827

			deleteuserbysn();		
			if(tempbuff[15]&0xf)
			{
				uart02idata(PCPACKAGEPARAMP,tempbuff,8);
				rdeleteuserbysn();
			}
			else
			{
				uart02idata(PCPACKAGEPARAMP,tempbuff,8);
			}
		}
		
		if(adduser())
		{
			//HERE COPY FP DATA TO THE POSITION 
			fpdatapc2fim();
			if(radduser(ADDUSERWITHFINGER))ackpccmd(PCASETNEWUSER,RETOK,0);
			else 
			{
				deleteuserbysn();
				ackpccmd(PCASETNEWUSER,RETUSERFULL,0);
			}
		}
		else
		{
			ackpccmd(PCASETNEWUSER,RETUSERFULL,0);
		}
	}
	else	//no fpdata
	{
	
		//idata2idata(uart0buff+PCPACKAGEPARAMP,tempbuff,8);
		uart02idata(PCPACKAGEPARAMP,tempbuff,8);
		if(getuserbytempid())
		{
			//ackpccmd(PCASETNEWUSER,RETUSEREXIST,0);
			//return;
			//deleteuserbysn();			
			///uart02idata(PCPACKAGEPARAMP,tempbuff,8);
			//rdeleteuserbysn();
			deleteuserbysn();		
			if(tempbuff[15]&0xf)
			{
				uart02idata(PCPACKAGEPARAMP,tempbuff,8);
				rdeleteuserbysn();
			}
			else
			{
				uart02idata(PCPACKAGEPARAMP,tempbuff,8);
			}
		}
		
		if(adduser())
		{
			ackpccmd(PCASETNEWUSER,RETOK,0);
		}
		else
		{
			ackpccmd(PCASETNEWUSER,RETUSERFULL,0);
		}
	}
}
//////////////////////////////////////////////////////////////
void fpfim2pc()
{
	unsigned short i;
	unsigned char UART0DATA* pchar;

	pchar=uart0buff+45;
	for(i=0;i<480;i++)
	{
		*(pchar-25)=*pchar;
		pchar++;
	}
}
//////////////////////////////////////////////////////////////
void pcgetalluser()
{
	unsigned short allusersn,i;

	allusersn=uart0buff[PCPACKAGEPARAMP]|(uart0buff[PCPACKAGEPARAMP+1]<<8);

	allusersn++;
	
	currentsn=0xffff;
	for(i=0;i<allusersn;i++)
	{
		if(!getusedsn(DOWNWARD))return;
	}

	tempbuff[14]=tempbuff[14]&0xf;
	if(tempbuff[15]&0xf)
	{
		if(rgetuserbysn(GETUSERWITHFINGER))
		{
			fpfim2pc();
			idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
			ackpccmd(PCAGETALLUSER,RETOK,488);
		}
		else
		{
			idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
			ackpccmd(PCAGETALLUSER,RETOK,8);
		}
	}
	else
	{
		idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
		ackpccmd(PCAGETALLUSER,RETOK,8);
	}
}
//////////////////////////////////////////////////////////////
//get a new user
void pcgetnewuser()
{
	if(getnewuser())
	{
		tempbuff[14]=tempbuff[14]&0xf;
		if(tempbuff[15]&0xf)
		{
			if(rgetuserbysn(GETUSERWITHFINGER))
			{
				fpfim2pc();
				idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
				ackpccmd(PCAGETNEWUSER,RETOK,488);
			}
			else
			{
				idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
				ackpccmd(PCAGETNEWUSER,RETUSER,8);
			}
		}
		else
		{
			idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
			ackpccmd(PCAGETNEWUSER,RETUSER,8);
		}
		//idata2idata(tempbuff+8,uart0buff+PCPACKAGEPARAMP,8);
		removeuserflag=1;
		getpcoktimer=timerh;
	}
	else
	{
		ackpccmd(PCAGETNEWUSER,RETNOUSER,0);
	}

}
//////////////////////////////////////////////////////////////
//get the specified user
void pcgetuser()
{
	//idata2idata(uart0buff+PCPACKAGEPARAMP,tempbuff,4);
	uart02idata(PCPACKAGEPARAMP,tempbuff,4);
	if(getuserbytempid())
	{
		tempbuff[14]=tempbuff[14]&0xf;
		if(tempbuff[15]&0xf)
		{
			if(rgetuserbysn(GETUSERWITHFINGER))
			{
				fpfim2pc();
				idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
				ackpccmd(PCAGETUSER,RETOK,488);
			}
			else
			{
				idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
				ackpccmd(PCAGETUSER,RETOK,8);
			}
		}
		else
		{
			idata2uart0(tempbuff+8,PCPACKAGEPARAMP,8);
			ackpccmd(PCAGETUSER,RETOK,8);
		}

		//idata2idata(tempbuff+8,uart0buff+PCPACKAGEPARAMP,8);
	}
	else
	{
		ackpccmd(PCAGETUSER,RETERR,0);
	}
	return;

	/*if(rgetuser((uart1buff[PAFIMPARAM]+uart1buff[PAFIMPARAM+1]<<8),1))
	{
	//here send the user info back to pc
	}
	else
	{
	//here report failure
	}*/
}
//////////////////////////////////////////////////////////////
void pcgetnewevent()
{
	if(getnewevent())
	{
		//idata2idata(tempbuff,uart0buff+PCPACKAGEPARAMP,16);
		idata2uart0(tempbuff,PCPACKAGEPARAMP,16);
		ackpccmd(PCAGETNEWEVENT,RETWITHDATA,16);

		//if(getpcok())removeoneevent();
		removeeventflag=1;
		getpcoktimer=timerh;

	}
	else
	{
		ackpccmd(PCAGETNEWEVENT,RETNODATA,0);
	}
}
//////////////////////////////////////////////////////////////
void pcsetdatetime()
{
	//here set the date and time
	
	clock_write(CCENTURY,uart0buff[PCPACKAGEPARAMP]);
	clock_write(CYEAR,uart0buff[PCPACKAGEPARAMP+1]);
	clock_write(CMONTH,uart0buff[PCPACKAGEPARAMP+2]);
	clock_write(CDAYOFMONTH,uart0buff[PCPACKAGEPARAMP+3]);
	clock_write(CDAYOFWEEK,uart0buff[PCPACKAGEPARAMP+4]);
	clock_write(CHOURS,uart0buff[PCPACKAGEPARAMP+5]);
	clock_write(CMINUTES,uart0buff[PCPACKAGEPARAMP+6]);
	clock_write(CSECONDS,uart0buff[PCPACKAGEPARAMP+7]);
	
	getdatetime();
	displaytime();
	
	ackpccmd(PCASETDATETIME,RETOK,0);
	
}
//////////////////////////////////////////////////////////////
void pcsetts()
{
	unsigned char tsindex;
	
	tsindex=uart0buff[PCPACKAGEPARAMP];

	//idata2idata(uart0buff+PCPACKAGEPARAMP+1,tempbuff,16);
	uart02idata(PCPACKAGEPARAMP+1,tempbuff,16);
	ram_write16(PAGETSSTART*16+tsindex,0);
	ackpccmd(PCASETTS,RETOK,0);

}
//////////////////////////////////////////////////////////////
void pcsetholiday()
{

⌨️ 快捷键说明

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