Wednesday, 23 November 2016

RFID Based Book Tracking System CHAPTER 6 APPENDIX

CHAPTER 6
    APPENDIX

6.1 Guidelines to Utilize the RFID Technology:
As libraries are implementing RFID systems, it is important to develop best practices guidelines to utilize the technology in best way and to keep the privacy concern away. The following may be the best practices guidelines for library RFID use (Berkeley Public Library n.d., Ayre 2004):
  • The Library should be open about its use of RFID technology including providing publicly available documents stating the rational for using RFID, objectives of its use and associated policies and procedure and who to contact with questions.
  • Signs should be pasted at all facilities using RFID. The signs should inform the public that RFID technology is in use, the types of usage and a statement of protection of privacy and how this technology differs from other information collection methods.
  • Only authorized personnel should have access to the RFID system.
  • No personal information should be stored on the RFID tag.
  • Information describing the tagged item should be encrypted on the tag even if the data is limited to a serial number
  • No static information should be contained on the tag (bar code, manufacturer number) that can be read by unauthorized readers
  • All communication between tag and reader should be encrypted via a unique encryption key.
  • All RFID readers in the library should be clearly marked.
  • ISO 18000 mode-2 tags should be used rather than ISO 15693


/*****************************************************************************
 Project : RfIdBook  -- Rfid Based Book Tracking system.
 Version : 1.0
 Author  : 1. N.NAGARJUNA REDDY   
2. V.SANDEEP
   3. K.RAJESH REDDY
   4. G.RAKESH REDDY
******************************************************************************/
# include <p89v51rd2.h>
# include "LcdV2.h"
# include "eeprom.h"

# define NO_OF_CARDS 5 
# define RX_BUF_SIZE    20
# define RFID_CODE_SIZE 10
# define CR_LF_SIZE     2
# define DEBUG 1

unsigned char gucBookNumber[10], gucStudNumber[10];
unsigned char gucRxCount = 0;
unsigned char gucReadFlag = 0;
unsigned char gucDisplayFlag = 0;
unsigned char gucRxBuf[RX_BUF_SIZE];
unsigned char gucWriteAddr[2];
unsigned char gucBookName[5],gucStudName[5];

void DisplayVersion();
void SerialInit(void);
unsigned char ReadCard(unsigned char *ucCardNum);
void StoreEeprom(unsigned char *ucBookNumber, unsigned char *ucStudentNumber);
void ReadEeprom(unsigned char ucPage, unsigned char ucOffSet, unsigned char *ucBookNumber, unsigned char *ucStudentNumber);
void CardName(unsigned char *ucCardNumber, unsigned char *ucCardName);
void DisplayData(void);
void ClearEeProm(void);
void external0() interrupt 0
{
 gucDisplayFlag = 1;
 P2_0 = !P2_0;
}
void serial0() interrupt 4
{
 if(RI == 1)
 {
  P2_6 = !P2_6;
  gucRxBuf[gucRxCount] = SBUF;
  gucRxCount++;
  if(gucRxCount >= (RFID_CODE_SIZE + CR_LF_SIZE))
  {
   gucRxCount = 0;
   gucReadFlag = 1;
  }
  RI = 0;
 }
}
void main(void)
{
 unsigned int i = 0;
 unsigned int j = 0;
 unsigned char ucButton = 0;
 IT0 = 1;     // Interrupt 0 on falling edge
 EX0 = 1;     // External interrupt 0
 EA = 1;      // Enabling the interrupts
 IE = 0x93;
 SerialInit();
 DisplayVersion();
 for(j = 0; j < 15; j++)
  for(i = 0; i < 40000; i++);
 if(P2_0 == 0)
 ClearEeProm();
EepromGets(0, 0, &gucWriteAddr[0], 2);
while(1)
 {
  do
  {
  LcdInit();
  LcdPuts("Show Book Card:");

  for(i = 0; i < RX_BUF_SIZE; i++)
   gucRxBuf[i] = 0x00;
  gucRxCount = 0; 

  ucButton = ReadCard(&gucBookNumber[0]);
  if(ucButton == 1)
  {
   DisplayData();
  }
  gucDisplayFlag = 0;
  } while(ucButton == 1);
  if((gucBookNumber[8] != '8') && (gucBookNumber[8] != '9'))
   continue;
  # if 1
  LcdInit();
  LcdPuts("Ur Card no.: ");
  LcdCmd(NEW_LINE);
  for(i = 0; i < 10; i++)
   LcdPutc(gucBookNumber[i]);
  for(i = 0; i < 10; i++)
   for(j = 0; j < 40000; j++);
  CardName(gucBookNumber, gucBookName);
  for(i = 0; i < 5; i++)
   LcdPutc(gucBookName[i]);
  # endif
  //while(1);
  for(i = 0; i < 10; i++)
   for(j = 0; j < 40000; j++);
  LcdInit();
  LcdPuts("Student Card:");
  do
  {
   for(i = 0; i < RX_BUF_SIZE; i++)
    gucRxBuf[i] = 0x00;
   gucRxCount = 0; 
   ReadCard(&gucStudNumber[0]);
  }while((gucBookNumber[8] == gucStudNumber[8]) && (gucBookNumber[9] == gucStudNumber[9]));

  if((gucStudNumber[8] != '8') && (gucStudNumber[8] != '9'))
   continue;
  # if 1
  LcdInit();
  LcdPuts("Ur Card no.: ");
  LcdCmd(NEW_LINE);
  for(i = 0; i < 10; i++)
   LcdPutc(gucStudNumber[i]);
  for(i = 0; i < 10; i++)
   for(j = 0; j < 40000; j++);
  CardName(gucStudNumber, gucStudName);
  for(i = 0; i < 5; i++)
   LcdPutc(gucStudName[i]);
  # endif

  StoreEeprom(gucBookNumber, gucStudNumber);
  for(j = 0; j < 10; j++)
   for(i = 0; i < 40000; i++);
 }
}

void SerialInit(void)
{
 TMOD = 0x20;
 TH1 = 0xfd;
 SCON = 0x50;
 TR1 = 1;
}

void DisplayVersion()
{
 LcdInit();
 LcdPuts("RFID Ver - 1.0");
 LcdCmd(NEW_LINE); 
 LcdPuts("S.R.Labs - Hyd.");
}

unsigned char ReadCard(unsigned char *ucCardNumber)
{
 unsigned char i = 0;
 while((gucReadFlag == 0) && (gucDisplayFlag == 0));
 
 if(gucDisplayFlag == 1)
 {
  gucDisplayFlag = 0;
  return 1;
 }
 
 for(i = 0; i < RFID_CODE_SIZE; i++)
 {
  *(ucCardNumber + i) = gucRxBuf[i];
 }
 gucReadFlag = 0;
 return 0;     }
void StoreEeprom(unsigned char *ucBookNumber, unsigned char *ucStudentNumber)
{
 EepromPuts(gucWriteAddr[0], gucWriteAddr[1], ucBookNumber, 10);
 gucWriteAddr[1] += 10;
 EepromPuts(gucWriteAddr[0], gucWriteAddr[1], ucStudentNumber, 10);
 gucWriteAddr[1] += 10;
 
 if(gucWriteAddr[1] >= 240)
 {
  gucWriteAddr[1] = 0;
  gucWriteAddr[0] = (gucWriteAddr[0] + 1);
  if(gucWriteAddr[0] >= 255)
   gucWriteAddr[0] = 0;
 }
 
EepromPuts(0, 0, &gucWriteAddr[0], 2);
}

void ReadEeprom(unsigned char ucPage, unsigned char ucOffset, unsigned char *ucBookNumber, unsigned char *ucStudentNumber)
{
 EepromGets(ucPage, ucOffset, ucBookNumber, 10);
 EepromGets(ucPage, (ucOffset + 10), ucStudentNumber, 10);
}

void CardName(unsigned char *ucCardNumber, unsigned char *ucCardName)
{
 switch(*(ucCardNumber + 8))
 {
  case '8':
   switch(*(ucCardNumber + 9))
   {
    case '1':
     *(ucCardName) = 'B';
     *(ucCardName + 1) = 'O';
     *(ucCardName + 2) = 'O';
     *(ucCardName + 3) = 'K';
     *(ucCardName + 4) = '1';
     break;
    case '2':
     *(ucCardName) = 'B';
     *(ucCardName + 1) = 'O';
     *(ucCardName + 2) = 'O';
     *(ucCardName + 3) = 'K';
     *(ucCardName + 4) = '2';
     break;
    case '6':
     *(ucCardName) = 'B';
     *(ucCardName + 1) = 'O';
     *(ucCardName + 2) = 'O';
     *(ucCardName + 3) = 'K';
     *(ucCardName + 4) = '3';
     break;
    case 'E':
    case 'e':
     *(ucCardName) = 'S';
     *(ucCardName + 1) = 'T';
     *(ucCardName + 2) = 'U';
     *(ucCardName + 3) = 'D';
     *(ucCardName + 4) = '1';
     break;
    default:
     *(ucCardName) = 'U';
     *(ucCardName + 1) = 'N';
     *(ucCardName + 2) = 'K';
     *(ucCardName + 3) = 'N';
     *(ucCardName + 4) = 'O';
     break; 
   }
   break;
  case '9':
   *(ucCardName) = 'S';
   *(ucCardName + 1) = 'T';
   *(ucCardName + 2) = 'U';
   *(ucCardName + 3) = 'D';
   *(ucCardName + 4) = '2';
   break;
  default:
   *(ucCardName) = 'U';
   *(ucCardName + 1) = 'N';
   *(ucCardName + 2) = 'K';
   *(ucCardName + 3) = 'N';
   *(ucCardName + 4) = 'O';
   break;
 }
 
}
void DisplayData(void)
{
 unsigned char ucPage  = 0,
        ucOffset  = 0;
 unsigned char ucBookNumber[10],
               ucStudNumber[10],
               ucBookName[6],
               ucStudName[6];
 unsigned int i,j;
 
 for(ucPage = 1; ucPage < gucWriteAddr[0]; ucPage++)
 {
  for(ucOffset = 0; ucOffset < 240; ucOffset += 20)
  {
   ReadEeprom(ucPage, ucOffset, &ucBookNumber[0], &ucStudNumber[0]);

   CardName(ucBookNumber, ucBookName);
   CardName(ucStudNumber, ucStudName);

   LcdInit();
   LcdPuts("Book:");
   for(i = 0; i < 5; i++)
    LcdPutc(ucBookName[i]);
   LcdCmd(NEW_LINE);
   LcdPuts("Stud:");
   for(i = 0; i < 5; i++)
    LcdPutc(ucStudName[i]);
   for(i = 0; i < 5; i++)
    for(j = 0; j < 40000; j++);
  }
 }
 for(ucOffset = 0; ucOffset < gucWriteAddr[1]; ucOffset += 20)
 {
  ReadEeprom(gucWriteAddr[0], ucOffset, &ucBookNumber[0], &ucStudNumber[0]);

  CardName(ucBookNumber, ucBookName);
  CardName(ucStudNumber, ucStudName);

  LcdInit();
  LcdPuts("Book:");
  for(i = 0; i < 5; i++)
   LcdPutc(ucBookName[i]);
  LcdCmd(NEW_LINE);
  LcdPuts("Stud:");
  for(i = 0; i < 5; i++)
   LcdPutc(ucStudName[i]);
  for(i = 0; i < 5; i++)
   for(j = 0; j < 40000; j++);
 }
}

void ClearEeProm(void)
{
 gucWriteAddr[0] = 1;
 gucWriteAddr[1] = 0;
 EepromPuts(0, 0, &gucWriteAddr[0], 2);
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.