Advertisement
vinifr

read_Miniate

Feb 25th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None | 0 0
  1. unsigned char * read_Miniate()
  2. {
  3.   uchar *buffer = NULL;
  4.   uchar buffer_fplength[16];
  5.   uchar status;
  6.   int lengthfp, totalrecorded;
  7.   int count, i, numblocks, j=0;
  8.   count=0;
  9.  
  10.   //reads length of Minutiae information
  11.   status = MFRC522_Auth(AUTHENTICATION_TYPE, BLOCK_CFG, pkey, serNum);
  12.   if (status == MI_OK)
  13.     status = MFRC522_Read(BLOCK_CFG,buffer_fplength);
  14.  
  15.   lengthfp = buffer_fplength[0];
  16.   lengthfp <<= 8;
  17.   lengthfp += buffer_fplength[1];
  18.   DPRINTF("READINGMINUTIAE: lengthfp: %d\n", lengthfp);
  19.   numblocks = (ceil((float)(lengthfp)/16)); //catch how many blocks will be used
  20.   DPRINTF("READINGMINUTIAE: numblocks: %d\n", numblocks);
  21.   buffer = (char*) malloc(lengthfp);
  22.  
  23.  
  24.   if(status == MI_OK){
  25.     //numblocks = buffer_fplength[0];
  26.     for (i=BLOCK_FPRINT; j<numblocks; i++)
  27.     {
  28.     if((i%4)<3)
  29.     {
  30.       status = MFRC522_Auth(AUTHENTICATION_TYPE, i, pkey, serNum);
  31.       status = MFRC522_Read(i, (uchar*)(buffer+count));
  32.       count += BLOCK_LENGTH;
  33.       j++;
  34.     }
  35.     }
  36.   }
  37.   else
  38.   {
  39.     printf("Error reading fprint length\n");
  40.   }
  41.  
  42.   DPRINTF("last block: %d\n", i);
  43.   DPRINTF("last count: %d\n", count);
  44.   fp = fopen("frameRD.xyt", "w");
  45.   if(fp == NULL)
  46.   {
  47.     printf("Cannot create file\n");
  48.     free(buffer);
  49.     fclose(fp);
  50.     return;
  51.   }
  52.   totalrecorded = fwrite(buffer, sizeof(char), lengthfp, fp);
  53.   if(totalrecorded != lengthfp)
  54.   {
  55.       printf("Error writing minutiae file\n");
  56.       free(buffer);
  57.       fclose(fp);
  58.       return;
  59.   }
  60.   printf("Minutiae read successfull\n");
  61.   free(buffer);
  62.   fclose(fp);
  63.   //return buffer;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement