[email protected]
Joined: 08 Jul 2015 Posts: 1
|
not getting package length and receiving exact data |
Posted: Thu Jul 09, 2015 5:23 am |
|
|
#include <16f877a.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20M)
#use rs232 (baud = 9600, xmit=PIN_A1,rcv=PIN_A0,stream=ID12)
#include <LCD1.c>
#INCLUDE <INPUT.C>
#define KEYHIT_DELAY 500 // in milliseconds
char timed_getc() {
unsigned int16 timeout;
char retval;
timeout=0;
while(!kbhit() && (++timeout< (KEYHIT_DELAY*100)))
delay_us(10);
if(kbhit())
retval = getc();
else
retval = 0;
return(retval);
}
void main()
{
unsigned char enroll[13]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X08,0X04,0x01,0X05}; // ok
char rfidnum1[12];
byte read[11]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X0003,0X1d,0X02};
byte cmd[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x01,0x00,0x05}; //register first print
byte ack[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x03,0x00,0x00,0x0A};
unsigned char identify[17]={0xef,0x01,0xff,0xff,0xff,0xff,0x01,0x00,0x08,0x1b,0x01,0x00,0x00,0x01,0x01,0x00,0x27};
unsigned int8 status;
char value;
char temp[15];
int i,j;
lcd_init();
lcd_putc("\f");
lcd_gotoxy(1,1);
lcd_putc(" Swagath Gadde \n");
lcd_putc(" testing 7");
delay_ms(1000);
memset(temp,'\0',sizeof(temp));
while(TRUE)
{
j=0;
status=1;
for(i=0;i<sizeof(enroll);i++)
{
putc(enroll[i]);
}
while(!kbhit());
while(status==1)
{
value=timed_getc();
if(value==0)
status=0;
else
{
status=1;
}
temp[j++]=value;
}
lcd_putc("\f");
lcd_gotoxy(1,1);
PRINTF(lcd_putc,"%x%x%x%x%x%x%x%x\n",TEMP[0],TEMP[1],TEMP[2],TEMP[3],TEMP[4],TEMP[5],TEMP[6],TEMP[7]);
PRINTF(lcd_putc,"%x%x%x%x%x%x\n",TEMP[8],TEMP[9],TEMP[10],TEMP[11],TEMP[12],TEMP[13]);
delay_ms(100);
memset(temp,'\0',sizeof(temp));
}
} |
|