Discussion in "Project Help" started by    sachinmm    Apr 7, 2016.
Thu Apr 07 2016, 11:57 am
#1
this is my function.h file ==>
//Description : Download fingerprint data with specified ID from host to module, then write to fingerprint template Database


unsigned char WriteTemplateData[508]= -->write command data packet
{(0x5A,0xA5,0x0B,0x01,0xF4,0x01-->write command packet),(0x01,0x00,-->Template number one i want to write on This Template)
(0x04,0x2C,0x5C,0x00,0x9D,0x02,0xF7,0xDE,0x04,0xAA,0x05,0xE7,0x59,0xE3,
0xF7,0x5B,0x86,0x79,0x36,0x28,0xAD,0xD3,0xF6,0x51,0x04,0x58,0x78,0x18,0xDE,0x33,0xF7,0xCD,0x85,0xC8,0x87,0xE8,0x95,0x34,
0xF5,0xC2,0x03,0x28,0x40,0x18,0xE1,0xE4,0xF8,0x4C,0x4D,0x09,0x05,0xD8,0xF9,0xDC,0xFA,0x3D,0x86,0xB7,0x49,0xD8,0x3D,0xE5,
0xF9,0xB8,0x85,0x47,0x36,0x27,0x25,0x95,0xF5,0xC4,0x84,0x47,0xBA,0x08,0x2A,0x4D,0xF6,0xC7,0x84,0x26,0x7A,0xE8,0x35,0x45,
0xF7,0x52,0x03,0xD8,0x05,0xEF,0x49,0x85,0xFA,0x46,0x05,0xA6,0x05,0xC8,0x79,0x0D,0xF7,0xC6,0xC3,0x56,0x40,0x00,0x79,0xCD,
0xF8,0x54,0xC6,0x89,0x05,0xE7,0xCE,0x25,0xF9,0x56,0x45,0x98,0x45,0xEF,0xAE,0x3D,0xF8,0xCB,0x04,0x57,0x76,0xEF,0xAA,0x1A,
0xF6,0x5B,0x43,0x1A,0x38,0x00,0xE5,0x6A,0xF5,0xD6,0x03,0xCA,0x03,0xE7,0x19,0xD3,0xF8,0x6F,0x8B,0x89,0x72,0x10,0x1E,0xA4,
0xFA,0x31,0x85,0x89,0xC5,0xE5,0x11,0x94,0xF5,0x4B,0x04,0x28,0x42,0x08,0x61,0x54,0xFB,0x32,0x44,0xB8,0x43,0xD8,0x31,0x35,
0xFB,0x3C,0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x22,0x75,0x35,0xA3,0x52,0x54,0x34,0x3F,0x33,0x24,0x1F,0x55,0xF4,0x2F,0x72,
0x65,0xF5,0xF4,0xF4,0x33,0x15,0x3F,0x5F,0x14,0x6F,0xF3,0x4F,0x14,0x12,0x72,0x34,0x2F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x72,0xE1,-->four nighty eight(498)bytes data of Template number six),(0x00,0x00)-->the last two byte are checksum};

int WriteTemplateDataCommandSize=507;
int WriteTemplateDataResponseCheckLength=508;

unsigned char WriteTemplate[]={0x55,0xAA,0x0B,0x01,0x02,0x00,0xF2,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02};
-->write command packet

int WriteTemplateCommandSize=23;
int WriteTemplateResponseCheckLength=24;

int writetoModule(int temp)
{
printf(" \nstart writeToModule: \n ");
int i;
WriteTemplateData[6]=temp; //put your entered template number in array of 6th position i.e.template number
char rslt=0;
do{
rs232_transfer(fp,WriteTemplate,WriteTemplateCommandSize); //this function is defined in serial.c file for transfer to module
printf("Reading Data....\n");
for(i=0;i<WriteTemplateResponseCheckLength;i++)
{
rslt=read(fp,(read_buf+i),sizeof(char));//this print the command packet send to the module
printf("%02X ", read_buf[i]);
}
}while(!rslt);
printf("response for write command packet ==> \n");
for (i=0; i<WriteTemplateResponseCheckLength; i++)
{
printf("%02X ", read_buf[i]); //this print the response packet Inform HOST has entered into template data accepting status
}
printf("\n====================================================================================\n");

chkbyte = chk(WriteTemplateData,506); //calculation of last two checksum bytes
//printf("\nmy checksum = %04X\n",chkbyte);
WriteTemplateData [506]=chkbyte;
WriteTemplateData [507]=chkbyte>>8;

do{
printf("checking for write data into module....\n");
rslt = write(fp,WriteTemplateData,508); //transfer the write data command 508
rslt=0;
rslt=read(fp,(read_buf),12); //response is 12 bytes as per datasheet
}while(!rslt);
if(read_buf[6]==0x00)
{
printf("\nresponse for write command data packet ==> \n"); //print the response of write command data packet and
for (i=0; i<rslt; i++) // Template number
{
printf("%02X ", read_buf[i]);
}
printf("\nResult : Success data written into the template\r\nTemplate No : %d",read_buf[8]);
printf("\n**********************************************************");
}
else
{
printf("\nResult : Fail or invalid template data\r\n");
}
printf("************************************************************************");
}

the two attached file is sample code for write one template into the module...i have 498 bytes data for template number "6" and i want to write on template number "1"
i have created the array of "unsigned char WriteTemplateData[508]"(in 508 bytes the first two byte is prefix-0x5A,0xA5,the second two bytes is command-0x0B,0x01,the third two bytes define length-0xF4,0x01,then template number-0x01,0x00,then 498 bytes data of template number 6,last two are checksum) as per mention in datasheet..and this code is working properly for writing any one template to the module....but if i want to write more than one template then i m stuck......

this is my main.c ==>
#include<stdio.h>
#include "function.h"
int main(void)
{
int x=0;
setUp();
ledOn();
printf("Enter the template number for writing data:\n");
scanf("%d",&x);
writetoModule(x);
}

i have text file in that following 489 bytes data is there ==>
0x04,0x2C,0x64,0x00,0xB6,0x03,0xFA,0x84,0x87,0x6A,0x74,0x18,0x01,0x64,0x79,0x13,0x09,0x6A,0xCB,0xED,
0x3D,0x9C,0x79,0x88,0x49,0x4A,0x2E,0xE8,0x89,0x24,0xF7,0xDD,0x04,0xA9,0x09,0xE7,0xE5,0x14,0xF7,0x5B,
0xC5,0x49,0x38,0x10,0xFA,0x5C,0xFA,0x99,0xC4,0x0D,0x74,0xE0,0x3A,0x45,0xE8,0x64,0xCC,0xBB,0x72,0x57,
0x31,0x63,0xF9,0x7F,0x46,0x48,0xF4,0xE8,0x91,0x5B,0xF8,0xED,0x07,0x9B,0x09,0x07,0x0D,0x64,0xF7,0x64,
0xC7,0x5A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x31,0x38,0x4A,0x0B,0x44,0x38,0x7E,0xF8,0x59,0xE8,0x49,0x8B,0xC3,0xD9,0xFF,0xEF,0x72,0xE0,0x4A,0x0C,
0xC7,0x29,0x3E,0xF8,0x45,0x33,0x7C,0x1B,0x02,0xDA,0x3F,0xF8,0xB1,0xF8,0x45,0x80,0x44,0x19,0xBE,0xE0,
0xD6,0xC8,0x45,0x04,0xC3,0xF9,0x05,0x1F,0xA1,0x6B,0x7C,0x94,0xC3,0xF7,0xFB,0x0F,0xA3,0x2F,0x3F,0x11,
0x27,0x42,0xF7,0x44,0x1F,0x65,0x62,0x52,0x42,0x4A,0x34,0x22,0x13,0x21,0x54,0x18,0x22,0x85,0xFF,0x43,
0x32,0xB8,0xA5,0xF7,0xFF,0x12,0xF2,0x1F,0xC1,0x68,0x48,0x86,0x2F,0x22,0xF8,0x26,0x23,0xFF,0x0F,0xF6,
0xFF,0x3F,0x77,0x45,0x1F,0x1F,0x17,0xF4,0x74,0x34,0x36,0x73,0x3F,0x26,0xF2,0x1F,0x6F,0x92,0x41,0xF7,
0xFF,0x77,0xA6,0xF4,0x8F,0x4F,0xF4,0xF9,0x33,0x75,0x32,0xF4,0xF1,0xF8,0xF1,0x1F,0x8F,0x46,0x36,0x06,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA2,0xE4



i want to store this data in above array [508] position from [8] to [498]....please tell me any solution
Thu Apr 07 2016, 09:49 pm
#2
Hi
Because of the way your post appears on screen, it is hard to say what is code,
what is comments, and what is your description on the problem.

Can you zip your code and re-post it as an attachment.


[ Edited Thu Apr 07 2016, 10:44 pm ]
Tue Apr 12 2016, 12:12 pm
#3
please check the file
Tue Apr 12 2016, 10:56 pm
#4
The file did not attach.
Is it a zip file ?
Wed Apr 13 2016, 07:07 am
#5
Hello,

I don't not which MCU you are working. But I have tested this code for you only on PC Based complier. But You need to learn that is some called File Handing in C .




In Hex.txt

1,2,3,4,5


Output you will see like this ..
0x1,0x2,0x3,0x4
Hope this Helps

--
Karan
www.tutorialsmax.com


[ Edited Wed Apr 13 2016, 07:12 am ]
Wed Apr 13 2016, 07:14 am
#6
Please Check Attachment ..
Wed Apr 13 2016, 07:20 am
#7
Please Check Png File.

Unable to attach/add C code .
Wed Apr 13 2016, 07:46 am
#8
HI Moderator,

I am unable to add/attachment Code C in Post Replay..

Hi sachinmm,

Please write as per image and modify as per your application ..

--
Karan
Wed Apr 13 2016, 10:40 pm
#9


HI Moderator,
I am unable to add/attachment Code C in Post Replay..

Karan123



Did you convert to a zip file ?
Fri Apr 22 2016, 02:44 am
#10
Thread closed as sachinmm has a similar thread running.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am