第一行数据是
单片机发送的,第二行数据是利用串口助手发送红框3的数据后,指纹模块上传的数据,同一条指令,为什么串口助手发送就有用,单片机就没用呢
#include <reg51.h>
unsigned char flag,a,i;
unsigned char code FP_Pack_Head[6] = {0xef,0x01,0xff,0xff,0xff,0xff}; //ÐÒé°üÍ·
unsigned char code FP_Get_Img[6] = {0x01,0x00,0x03,0x01,0x00,0x05}; //»ñµÃÖ¸ÎÆͼÏñ
unsigned char code FP_Templete_Num[6] ={0x01,0x00,0x03,0x1D,0x00,0x21 }; //»ñµÃÄ£°å×ÜÊý
unsigned char code FP_Search[11]={0x01,0x00,0x08,0x04,0x01,0x0,0x0,0x03,0xA1,0x0,0xB2}; //Ö¸ÎÆËÑË÷·¶Î§0 - 929
unsigned char code FP_Search_0_9[11]={0x01,0x00,0x08,0x04,0x01,0x0,0x0,0x0,0x13,0x0,0x21}; //ËÑË÷0-9ºÅÖ¸ÎÆ
unsigned char code FP_Img_To_Buffer1[7]={0x01,0x00,0x04,0x02,0x01,0x0,0x08}; //½«Í¼Ïñ·ÅÈëBUFFER1
unsigned char code FP_Img_To_Buffer2[7]={0x01,0x00,0x04,0x02,0x02,0x0,0x09}; //½«Í¼Ïñ·ÅÈëBUFFER2
unsigned char code FP_Reg_Model[6]={0x01,0x00,0x03,0x05,0x0,0x09}; //½«BUFFER1ºÍBUFFER2ºÏ³ÉÌØÕ÷Ä£°å
unsigned char code FP_Delet_All_Model[6]={0x01,0x00,0x03,0x0d,0x00,0x11};//ɾ³ýÖ¸ÎÆ¿âÖÐËùÓеÄÄ£°å
volatile unsigned char FP_Save_Finger[9]={0x01,0x00,0x06,0x06,0x01,0x00,0x0B,0x00,0x19};//½«BUFFER1ÖеÄÌØÕ÷Âë´æ·Åµ½Ö¸¶¨Î»ÖÃ
volatile unsigned char FP_Delete_Model[10]={0x01,0x00,0x07,0x0C,0x00,0x00,0x00,0x01,0x00,0x00}; //ɾ³ýÖ¸¶¨µÄÄ£°å
volatile unsigned char UART1_FINGERPRINT_RECEVICE_BUFFER[24];
void Delay_Ms(int t)
{
int a,b;
for(a=5*t;a>0;a--)
{
for(b=22;b>0;b--)
{
;
}
}
}
void UART_init_9600(void) //9600bps@12.000MHz
{
TMOD=0X20;
TH1=0XFD;
TL1=0XFD;
TR1=1;
REN=1;
SM0=0; //´®¿Ú·½Ê½1
SM1=1;
EA=1;
ES=1;
}
void UART1_Send_Byte(unsigned char c)//·¢ËÍÒ»¸ö×Ö½Ú
{
TI=0;
SBUF = c;
while(!TI);
TI = 0;
}
unsigned char UART1_Receive_Byte()//½ÓÊÕÒ»¸ö×Ö½Ú
{
unsigned char dat;
while(!RI);
RI = 0;
dat = SBUF;
return (dat);
}
//FINGERPRINT»ñÈ¡Ö¸ÎÆͼÏñÃüÁî
void FINGERPRINT_Cmd_Get_Img(void)
{
unsigned char i;
ES=0;
for(i=0;i<6;i++)
UART1_Send_Byte(FP_Pack_Head); //
for(i=0;i<6;i++)
UART1_Send_Byte(FP_Get_Img);
ES=1;
}
////½«Í¼Ïñת»»³ÉÌØÕ÷Âë´æ·Åµ½Buffer1ÖÐ
//void FINGERPRINT_Cmd_Img_To_Buffer1(void)
//{
// unsigned char i;
//
// for(i=0;i<6;i++)
// {
// UART1_Send_Byte(FP_Pack_Head);
// }
//
// for(i=0;i<7;i++)
// {
// UART1_Send_Byte(FP_Img_To_Buffer1);
// }
//}
////½«Í¼Ïñת»»³ÉÌØÕ÷Âë´æ·Åµ½Buffer2ÖÐ
//void FINGERPRINT_Cmd_Img_To_Buffer2(void)
//{
// unsigned char i;
// for(i=0;i<6;i++)
// {
// UART1_Send_Byte(FP_Pack_Head);
// }
//
// for(i=0;i<7;i++)
// {
// UART1_Send_Byte(FP_Img_To_Buffer2);
// }
//}
////½«BUFFER1 ºÍ BUFFER2 ÖеÄÌØÕ÷ÂëºÏ²¢³ÉÖ¸ÎÆÄ£°æ
//void FINGERPRINT_Cmd_Reg_Model(void)
//{
// unsigned char i;
// for(i=0;i<6;i++)
// {
// UART1_Send_Byte(FP_Pack_Head);
// }
// for(i=0;i<6;i++)
// {
// UART1_Send_Byte(FP_Reg_Model);
// }
//}
////ɾ³ýÖ¸ÎÆÄ£¿éÀïËùÓеÄÖ¸ÎÆÄ£°å
//void FINGERPRINT_Cmd_Delete_All_Model(void)
//{
// unsigned char i;
// for(i=0;i<6;i++)
// UART1_Send_Byte(FP_Pack_Head);
// for(i=0;i<6;i++)
// UART1_Send_Byte(FP_Delet_All_Model);
//}
////ɾ³ýÖ¸ÎÆÄ£¿éÀïÖ¸¶¨µÄÖ¸ÎÆÄ£°å
//void FINGERPRINT_Cmd_Delete_Model(unsigned int uiID_temp)
//{
// volatile unsigned int uiSum_temp = 0;
// unsigned char i;
//
// FP_Delete_Model[4]=(uiID_temp&0xFF00)>>8;
// FP_Delete_Model[5]=(uiID_temp&0x00FF);
//
// for(i=0;i<8;i++)
// uiSum_temp = uiSum_temp + FP_Delete_Model;
//
// //UART0_Send_Byte(uiSum_temp);
//
// FP_Delete_Model[8]=(uiSum_temp&0xFF00)>>8;
// FP_Delete_Model[9]=uiSum_temp&0x00FF;
//
// for(i=0;i<6;i++) //
// UART1_Send_Byte(FP_Pack_Head);
// for(i=0;i<10;i++) //????????
// UART1_Send_Byte(FP_Delete_Model);
//}
////»ñÈ¡Ö¸ÎÆÄ£°åÊýÁ¿
//void FINGERPRINT_Cmd_Get_Templete_Num(void)
//{ unsigned int i;
// // unsigned char temp[14];
// for(i=0;i<6;i++)
// UART1_Send_Byte(FP_Pack_Head);
// for(i=0;i<6;i++)
// UART1_Send_Byte(FP_Templete_Num);
//}
////ËÑË÷È«²¿Óû§999ö
//void FINGERPRINT_Cmd_Search_Finger(void)
//{
// unsigned char i;
// for(i=0;i<6;i++)
// {
// UART1_Send_Byte(FP_Pack_Head);
// }
// for(i=0;i<11;i++)
// {
// UART1_Send_Byte(FP_Search);
// }
//}
////ËÑË÷È«²¿Óû§999ö
//void FINGERPRINT_Cmd_Search_Finger_Admin(void)
//{
// unsigned char i;
// for(i=0;i<6;i++) //?????????
// {
// UART1_Send_Byte(FP_Pack_Head);
// }
// for(i=0;i<11;i++)
// {
// UART1_Send_Byte(FP_Search_0_9);
// }
//}
////½«BUFFER1ÖеÄÌØÕ÷Âë´æ·Åµ½Ö¸¶¨Î»ÖÃ
//void FINGERPRINT_Cmd_Save_Finger( unsigned char ucH_Char,unsigned char ucL_Char )
//{
// unsigned long temp = 0;
// unsigned char i;
//// SAVE_FINGER[9]={0x01,0x00,0x06,0x06,0x01,0x00,0x0B,0x00,0x19};//?BUFFER1?????????????
// FP_Save_Finger[5] = ucH_Char;
// FP_Save_Finger[6] = ucL_Char;
//
// for(i=0;i<7;i++) //¼ÆËã¼ìÑéºÍ
// temp = temp + FP_Save_Finger;
//
// FP_Save_Finger[7]=(temp & 0x00FF00) >> 8; //´æ·Å¼ìÑéÊý¾Ý
// FP_Save_Finger[8]= temp & 0x0000FF;
//
// for(i=0;i<6;i++)
// UART1_Send_Byte(FP_Pack_Head);
// for(i=0;i<9;i++)
// UART1_Send_Byte(FP_Save_Finger);
//}
////½ÓÊÕ·µÀ¡Êý¾Ý»º³å
//void FINGERPRINT_Recevice_Data(unsigned char ucLength)
//{
// unsigned char i;
// for (i=0;i<ucLength;i++)
// UART1_FINGERPRINT_RECEVICE_BUFFER = UART1_Receive_Byte();
//}
////Ìí¼ÓÓû§
//unsigned char FP_add_new_user(unsigned char ucH_user,unsigned char ucL_user)
//{
//
// do {
// FINGERPRINT_Cmd_Get_Img(); //»ñµÃÖ¸ÎÆͼÏñ
// FINGERPRINT_Recevice_Data(12); //½ÓÊÕ12¸ö³¤¶ÈµÄ·´À¡Âë
// }
// while ( UART1_FINGERPRINT_RECEVICE_BUFFER[9]!=0x0 ); //¼ì²âÊÇ·ñ³É¹¦µÄ°´ÁËÖ¸ÎÆ
// FINGERPRINT_Cmd_Img_To_Buffer1(); //½«Í¼Ïñת»»Âë´æ·ÅÔÚBuffer1ÖÐ
// FINGERPRINT_Recevice_Data(12); //½ÓÊÕ12¸ö³¤¶ÈµÄ·´À¡Âë
// do{
// FINGERPRINT_Cmd_Get_Img(); //»ñÈ¡Ö¸ÎÆͼÏñ
// FINGERPRINT_Recevice_Data(12); //½ÓÊÕ12¸ö³¤¶ÈµÄ·´À¡Âë
// }
// while( UART1_FINGERPRINT_RECEVICE_BUFFER[9]!=0x0 );
//
// FINGERPRINT_Cmd_Img_To_Buffer2(); //½«Í¼Ïñת»»Âë´æ·ÅÔÚBuffer2ÖÐ
// FINGERPRINT_Recevice_Data(12); //½ÓÊÕ12¸ö³¤¶ÈµÄ·´À¡Âë
// FINGERPRINT_Cmd_Reg_Model();//ת»»³ÉÌØÕ÷Âë
// FINGERPRINT_Recevice_Data(12);
//
// FINGERPRINT_Cmd_Save_Finger(ucH_user,ucL_user);
// FINGERPRINT_Recevice_Data(12);
//
// return 0;
//}
void main(void)
{
unsigned char temp_char = 0;
UART_init_9600();
Delay_Ms(500);
Delay_Ms(500);
Delay_Ms(500);
Delay_Ms(500);
Delay_Ms(500);
FINGERPRINT_Cmd_Get_Img();
while(1)
{
}
}
一周热门 更多>