ACR1281U-C8 – Application Programming Interface
Version 1.00
www.acs.com.hk
Page 51 of 52
Appendix D. Standard Program Flow
1. Before any card commands, get the Reader Handle first.
2. Select the TAG.
3. Login the TAG.
4. Access the TAG.
5. Close the Reader Handle.
// ACR120_Sample.c; a very simple program
#include “acr120.h”
void main(void)
{
INT16 hReader;
UINT8 Length, SN[10], Data[16], Type;
// Open a communication channel (USB Interface)
hReader=ACR120_Open(ACR120_USB1);
if(hReader<0){ // error happened!!! };
// Assume the Reader Handle is ready, then “Select a TAG”
ACR120_Select(hReader, &Type, &Length, SN);
// Assume a TAG is selected, then “Login Sector 0x00”
ACR120_Login(hReader, 0x00, AC_MIFARE_LOGIN_KEYTYPE_DEFAULT_A,0,NULL);
// Assume the Sector is authorized, then “Read data from Block 0x02 of
Sector 0x00”
ACR120_Read(hReader, 0x02, Data);
/*
Some operations.
*/
ACR120_Close(hReader); // Close the port and quit the program
return;
}