Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:0208a671ce89, committed 2022-02-04
- Comitter:
- 18688526
- Date:
- Fri Feb 04 08:45:33 2022 +0000
- Parent:
- 0:90c64cb9db58
- Commit message:
- V1.0;
Changed in this revision
GT511C3.cpp | Show annotated file Show diff for this revision Revisions of this file |
GT511C3.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/GT511C3.cpp Fri Jan 03 16:00:00 2014 +0000 +++ b/GT511C3.cpp Fri Feb 04 08:45:33 2022 +0000 @@ -105,6 +105,32 @@ return 0; } +int GT511C3::SendData(unsigned char *data,unsigned long size) +{ + const unsigned char fixedbuf[4] = { 0x5A,0xA5,0x01,0x00 }; + unsigned short sum = 0; + int i; + + for(i = 0;i < 4;i++){ + while(!writeable()); + putc(fixedbuf[i]); + sum += fixedbuf[i]; + } + + for(i = 0;i < size;i++){ + while(!writeable()); + putc(data[i]); + sum += data[i]; + } + + while(!writeable()); + putc((unsigned char)(sum & 0xff)); + while(!writeable()); + putc((unsigned char)((sum >> 8) & 0xff)); + + return 0; +} + int GT511C3::RecvData(unsigned char *data,unsigned long size) { const unsigned char fixedbuf[4] = { 0x5A,0xA5,0x01,0x00 }; @@ -335,6 +361,30 @@ return -1; } +int GT511C3::SetTemplate(int ID, unsigned char *data, unsigned long size) +{ + unsigned long Parameter = ID; + unsigned short Response = 0; + int sts = 0; + + sts = SendRecv(CMD_SetTemplate,&Parameter,&Response); + + if ((sts != 0) || (Response != CMD_Ack)) + return -1; + + sts = SendData(data, size); + + if (sts != 0) + return -2; + + sts = RecvResponse(&Parameter, &Response); + + if ((sts != 0) || (Response != CMD_Ack)) + return -3; + + return 0; +} + int GT511C3::DeleteID(int ID) { unsigned long Parameter = ID; @@ -346,3 +396,15 @@ return 0; return -1; } + +int GT511C3::DeleteAllIDs() +{ + unsigned long Parameter = 0; + unsigned short Response = 0; + int sts = 0; + + sts = SendRecv(CMD_DeleteAll,&Parameter,&Response); + if((sts == 0) && (Response == CMD_Ack)) + return 0; + return -1; +} \ No newline at end of file
--- a/GT511C3.hpp Fri Jan 03 16:00:00 2014 +0000 +++ b/GT511C3.hpp Fri Feb 04 08:45:33 2022 +0000 @@ -97,6 +97,7 @@ int Init(void); int SendCommand(unsigned long Parameter,unsigned short Command); int RecvResponse(unsigned long *Parameter,unsigned short *Response); + int SendData(unsigned char *data,unsigned long size); int RecvData(unsigned char *data,unsigned long size); int SendRecv(unsigned short Command,unsigned long *Parameter,unsigned short *Response); int ClearLine(void); @@ -108,8 +109,10 @@ int Enroll_N(int N); int Identify(void); int Enroll(int ID,int (*progress)(int status,char *msg)); + int SetTemplate(int ID,unsigned char *data,unsigned long size); int CheckEnrolled(int ID); int DeleteID(int ID); + int DeleteAllIDs(); }; #endif //__GT511C3_HPP