Commit654ef995 by developer2

NT4H console example (NTAG 413, and NTAG 424)

parents
This diff is collapsed.Click to expand it.
language.settings.xml
*.o
/win32_debug/
/win32_release/src/
/win64_debug/
/win64_release/src/
/linux32_debug/
/linux32_release/src/
/linux64_debug/
/linux64_release/src/
[submodule "lib"]
path = lib
url = https://git.d-logic.net/nfc-rfid-reader-sdk/ufr-lib
nt4h_c_example
org.eclipse.cdt.managedbuilder.core.genmakebuilder
clean,full,incremental,
org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
full,incremental,
org.eclipse.cdt.core.cnature
org.eclipse.cdt.managedbuilder.core.managedBuildNature
org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
eclipse.preferences.version=1
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.1284259793/MINGW_HOME/delimiter=;
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.1284259793/MINGW_HOME/operation=replace
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.1284259793/MINGW_HOME/value=C\:\\mingw32
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.1284259793/append=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.1284259793/appendContributed=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.242952993/MINGW_HOME/delimiter=;
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.242952993/MINGW_HOME/operation=replace
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.242952993/MINGW_HOME/value=C\:\\mingw64
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.242952993/append=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.1203933141.242952993/appendContributed=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1810471863/MINGW_HOME/delimiter=;
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1810471863/MINGW_HOME/operation=replace
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1810471863/MINGW_HOME/value=C\:\\mingw32
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1810471863/append=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1810471863/appendContributed=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1814614570/MINGW_HOME/delimiter=;
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1814614570/MINGW_HOME/operation=replace
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1814614570/MINGW_HOME/value=C\:\\mingw64
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1814614570/append=true
environment/project/cdt.managedbuild.config.gnu.mingw.exe.release.445926757.1814614570/appendContributed=true
eclipse.preferences.version=1
encoding/=UTF-8
eclipse.preferences.version=1
line.separator=\r\n
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
# Digital Logic
# www.d-logic.net
#
# Helper Makefile
#
#$(VERBOSE).SILENT:
PRJNAME=nt4h_c_example
所有:help
help info:
echo"----------------------------------------------"
echo"Making example to test Reader opening function"
echo"Project output name:$(PRJNAME)"
echo"----------------------------------------------"
echo"For 32 bit Windows - type: 'make win32'"
echo"For 64 bit Windows - type: 'make win64'"
echo"For 32 bit Linux - type: 'make lin32'"
echo"For 64 bit Linux - type: 'make lin64'"
echo"For 64 bit Mac OS - type: 'make osx'"
echo"----------------------------------------------"
lin32 linux32:
cdlinux32_release&&gcc-m32-o$(PRJNAME)../src/*.c-I../lib/include-L../lib/linux/x86-luFCoder-x86-Wl,-R../lib/linux/x86
echo"Making done, without errors."
echo"To run the example - type:"
echo" 'cd linux32_release && ./$(PRJNAME)'"
lin64 linux64:
cdlinux64_release&&gcc-m64-o$(PRJNAME)../src/*.c-I../lib/include-L../lib/linux/x86_64-luFCoder-x86_64-Wl,-R../lib/linux/x86_64
echo"Making done, without errors."
echo"To run the example - type:"
echo" 'cd linux64_release && ./$(PRJNAME)'"
win32:
echo"If You see error like: 'skipping incompatible lib/windows/x86/uFCoder-x86.dll when searching for...'"
echo" This means You have the gcc compiler for 64 bit"
echo" type 'make win64' instead of 'make win32'"
echo""
cdwin32_release&&gcc-o$(PRJNAME)../src/*.c-I../lib/include-L../lib/windows/x86-luFCoder-x86-Wl,-Rlib/windows/x86-Wl,--enable-stdcall-fixup
echo"Making done, without errors."
echo"To run the example - type:"
echo" 'cd win32_release'"
echo" 'run_me'"
# generate run_me
echo"@echo off">win32_release\\run_me.cmd
echo"set path=..\lib\windows\x86;%path%">>win32_release\\run_me.cmd
echo"$(PRJNAME).exe">>win32_release\\run_me.cmd
win64:
echo"If You see error like: 'lib/windows/x86_64/uFCoder-x86_64.dll: file not recognized: File format not recognized'"
echo" This means You have the gcc compiler for 32 bit"
echo" type 'make win32' instead of 'make win64'"
echo""
cdwin64_release&&gcc-o$(PRJNAME)../src/*.c-I../lib/include-L../lib/windows/x86_64-luFCoder-x86_64-Wl,-Rlib/windows/x86_64
echo"Making done, without errors."
echo"You must use library from the 'lib\windows\x86_64\'"
echo""
echo"To run the example - type:"
echo" 'cd win64_release'"
echo" 'run_me'"
# generate run_me
echo"@echo off">win64_release\\run_me.cmd
echo"set path=..\lib\windows\x86_64;%path%">>win64_release\\run_me.cmd
echo"$(PRJNAME)">>win64_release\\run_me.cmd
osx:
-mkdir-pmacos-x86_64-release
gcc-omacos-x86_64-release/$(PRJNAME)-Ilib/include src/*.c-Llib/macos/x86_64-luFCoder-x86_64-Xlinker-rpathlib/macos/x86_64/
install_name_tool-change"libuFCoder-x86_64.dylib""@loader_path/../lib/macos/x86_64/libuFCoder-x86_64.dylib"macos-x86_64-release/$(PRJNAME)
echo"Making on 64-bit Intel macOS is done - without errors."
echo"Output is in macos-x86_64-release/"
echo
# running help message
echo"You must use library from the 'lib/macos/x86_64'"
echo""
echo"To run the example - type:"
echo" 'cd macos-x86_64-release && ./$(PRJNAME)'"
lib@114f2e8a
Subproject commit 114f2e8a61ea60c2825ea92a9e6f1fb3ebe2c060
/*
* conio_gnu.c
*
* Created on: 31.05.2016.
* Author: d-logic (http://www.d-logic.net/nfc-rfid-reader-sdk/)
*/
#if linux || __linux__ || __APPLE__
#include
#include
#include
#include
#include
#include
staticstructtermiosold,;
// Initialize new terminal i/o settings:
void_initTermios(intecho)
{
tcgetattr(0,&old);// grab old terminal i/o settings
=old;// make new settings same as old settings
.c_lflag&=~ICANON;// disable buffered i/o
.c_lflag&=echo?ECHO:~ECHO;// set echo mode
tcsetattr(0,TCSANOW,&);// use these new terminal i/o settings now
}
// Restore old terminal i/o settings:
void_resetTermios(void)
{
tcsetattr(0,TCSANOW,&old);
}
// Read 1 character:
char_getch(void)
{
returngetchar();
}
int_kbhit(void)
{
intbyteswaiting;
ioctl(0,FIONREAD,&byteswaiting);
returnbyteswaiting>0;
}
#endif // linux || __linux__ || __APPLE__
/*
* conio_gnu.h
*
* Created on: 31.05.2016.
* Author: d-logic (http://www.d-logic.net/nfc-rfid-reader-sdk/)
*/
#ifndef CONIO_GNU_H_
#define CONIO_GNU_H_
#if linux || __linux__ || __APPLE__
void_initTermios(intecho);
void_resetTermios(void);
char_getch(void);
int_kbhit(void);
#endif // linux || __linux__ || __APPLE__
#endif/* CONIO_GNU_H_ */
/*
* ini.h
*/
#ifndef INI_H_
#define INI_H_
#define APP_VERSION "1.1"
#define EXIT_ON_WRONG_FW_DEPENDENCY
#define MIN_DEPEND_FW_VER_MAJOR 5
#define MIN_DEPEND_FW_VER_MINOR 0
#define MIN_DEPEND_FW_VER_BUILD 32
#define EXIT_ON_WRONG_LIB_DEPENDENCY
#define MIN_DEPEND_LIB_VER_MAJOR 5
#define MIN_DEPEND_LIB_VER_MINOR 0
#define MIN_DEPEND_LIB_VER_BUILD 29
#endif/* INI_H_ */
This diff is collapsed.Click to expand it.
/*
* uFR.c
*/
#include
#include
#include
#include
#include
#include "ini.h"
#include "uFR.h"
//------------------------------------------------------------------------------
boolCheckDependencies(void){
#如果定义(EXIT_ON_WRONG_FW_DEPENDENCY) | |定义d(EXIT_ON_WRONG_LIB_DEPENDENCY)
uint8_tversion_major,version_minor,build;
boolwrong_version=false;
#endif
UFR_STATUSstatus;
#ifdef EXIT_ON_WRONG_LIB_DEPENDENCY
uint32_tdwDllVersion=0;
dwDllVersion=GetDllVersion();
// "explode" the uFCoder library version:
version_major=(uint8_t)dwDllVersion;
version_minor=(uint8_t)(dwDllVersion>>8);
// Get the uFCoder library build number.
build=(uint8_t)(dwDllVersion>>16);
if(version_major<MIN_DEPEND_LIB_VER_MAJOR){
wrong_version=true;
}elseif(version_major==MIN_DEPEND_LIB_VER_MAJOR&&version_minor<MIN_DEPEND_LIB_VER_MINOR){
wrong_version=true;
}elseif(version_major==MIN_DEPEND_LIB_VER_MAJOR&&version_minor==MIN_DEPEND_LIB_VER_MINOR&&build<MIN_DEPEND_LIB_VER_BUILD){
wrong_version=true;
}
if(wrong_version){
printf("Wrong uFCoder library version (%d.%d.%d).\n"
"Please update uFCoder library to at last %d.%d.%d version.\n",
version_major,version_minor,build,
MIN_DEPEND_LIB_VER_MAJOR,MIN_DEPEND_LIB_VER_MINOR,MIN_DEPEND_LIB_VER_BUILD);
returnfalse;
}
#endif
#ifdef EXIT_ON_WRONG_FW_DEPENDENCY
wrong_version=false;
status=GetReaderFirmwareVersion(&version_major,&version_minor);
if(status!=UFR_OK){
printf("Error while checking firmware version, status is: 0x%08X\n",status);
}
status=GetBuildNumber(&build);
if(status!=UFR_OK){
printf("Error while firmware version, status is: 0x%08X\n",status);
}
if(version_major<MIN_DEPEND_FW_VER_MAJOR){
wrong_version=true;
}elseif(version_major==MIN_DEPEND_FW_VER_MAJOR&&version_minor<MIN_DEPEND_FW_VER_MINOR){
wrong_version=true;
}elseif(version_major==MIN_DEPEND_FW_VER_MAJOR&&version_minor==MIN_DEPEND_FW_VER_MINOR&&build<MIN_DEPEND_FW_VER_BUILD){
wrong_version=true;
}
if(wrong_version){
printf("Wrong uFR NFC reader firmware version (%d.%d.%d).\n"
"Please update uFR firmware to at last %d.%d.%d version.\n",
version_major,version_minor,build,
MIN_DEPEND_FW_VER_MAJOR,MIN_DEPEND_FW_VER_MINOR,MIN_DEPEND_FW_VER_BUILD);
returnfalse;
}
#endif
returntrue;
}
//------------------------------------------------------------------------------
sz_ptrGetDlTypeName(uint8_tdl_type_code){
switch(dl_type_code){
caseDL_MIFARE_ULTRALIGHT:
return"DL_MIFARE_ULTRALIGHT";
caseDL_MIFARE_ULTRALIGHT_EV1_11:
return"DL_MIFARE_ULTRALIGHT_EV1_11";
caseDL_MIFARE_ULTRALIGHT_EV1_21:
return"DL_MIFARE_ULTRALIGHT_EV1_21";
caseDL_MIFARE_ULTRALIGHT_C:
return"DL_MIFARE_ULTRALIGHT_C";
caseDL_NTAG_203:
return"DL_NTAG_203";
caseDL_NTAG_210:
return"DL_NTAG_210";
caseDL_NTAG_212:
return"DL_NTAG_212";
caseDL_NTAG_213:
return"DL_NTAG_213";
caseDL_NTAG_215:
return"DL_NTAG_215";
caseDL_NTAG_216:
return"DL_NTAG_216";
caseDL_MIKRON_MIK640D:
return"DL_MIKRON_MIK640D";
caseNFC_T2T_GENERIC:
return"NFC_T2T_GENERIC";
caseDL_NT3H_1101:
return"DL_NT3H_1101";
caseDL_NT3H_1201:
return"DL_NT3H_1201";
caseDL_NT3H_2111:
return"DL_NT3H_2111";
caseDL_NT3H_2211:
return"DL_NT3H_2211";
caseDL_MIFARE_MINI:
return"DL_MIFARE_MINI";
caseDL_NTAG_413_DNA:
return"DL_NTAG_413_DNA";
caseDL_NTAG_424_DNA:
return"DL_NTAG_424_DNA";
caseDL_MIFARE_CLASSIC_1K:
return"DL_MIFARE_CLASSIC_1K";
caseDL_MIFARE_CLASSIC_4K:
return"DL_MIFARE_CLASSIC_4K";
caseDL_MIFARE_PLUS_S_2K_SL0:
return"DL_MIFARE_PLUS_S_2K_SL0";
caseDL_MIFARE_PLUS_S_4K_SL0:
return"DL_MIFARE_PLUS_S_4K_SL0";
caseDL_MIFARE_PLUS_X_2K_SL0:
return"DL_MIFARE_PLUS_X_2K_SL0";
caseDL_MIFARE_PLUS_X_4K_SL0:
return"DL_MIFARE_PLUS_X_4K_SL0";
caseDL_MIFARE_DESFIRE:
return"DL_MIFARE_DESFIRE";
caseDL_MIFARE_DESFIRE_EV1_2K:
return"DL_MIFARE_DESFIRE_EV1_2K";
caseDL_MIFARE_DESFIRE_EV1_4K:
return"DL_MIFARE_DESFIRE_EV1_4K";
caseDL_MIFARE_DESFIRE_EV1_8K:
return"DL_MIFARE_DESFIRE_EV1_8K";
caseDL_MIFARE_DESFIRE_EV2_2K:
return"DL_MIFARE_DESFIRE_EV2_2K";
caseDL_MIFARE_DESFIRE_EV2_4K:
return"DL_MIFARE_DESFIRE_EV2_4K";
caseDL_MIFARE_DESFIRE_EV2_8K:
return"DL_MIFARE_DESFIRE_EV2_8K";
caseDL_MIFARE_PLUS_S_2K_SL1:
return"DL_MIFARE_PLUS_S_2K_SL1";
caseDL_MIFARE_PLUS_X_2K_SL1:
return"DL_MIFARE_PLUS_X_2K_SL1";
caseDL_MIFARE_PLUS_EV1_2K_SL1:
return"DL_MIFARE_PLUS_EV1_2K_SL1";
caseDL_MIFARE_PLUS_X_2K_SL2:
return"DL_MIFARE_PLUS_X_2K_SL2";
caseDL_MIFARE_PLUS_S_2K_SL3:
return"DL_MIFARE_PLUS_S_2K_SL3";
caseDL_MIFARE_PLUS_X_2K_SL3:
return"DL_MIFARE_PLUS_X_2K_SL3";
caseDL_MIFARE_PLUS_EV1_2K_SL3:
return"DL_MIFARE_PLUS_EV1_2K_SL3";
caseDL_MIFARE_PLUS_S_4K_SL1:
return"DL_MIFARE_PLUS_S_4K_SL1";
caseDL_MIFARE_PLUS_X_4K_SL1:
return"DL_MIFARE_PLUS_X_4K_SL1";
caseDL_MIFARE_PLUS_EV1_4K_SL1:
return"DL_MIFARE_PLUS_EV1_4K_SL1";
caseDL_MIFARE_PLUS_X_4K_SL2:
return"DL_MIFARE_PLUS_X_4K_SL2";
caseDL_MIFARE_PLUS_S_4K_SL3:
return"DL_MIFARE_PLUS_S_4K_SL3";
caseDL_MIFARE_PLUS_X_4K_SL3:
return"DL_MIFARE_PLUS_X_4K_SL3";
caseDL_MIFARE_PLUS_EV1_4K_SL3:
return"DL_MIFARE_PLUS_EV1_4K_SL3";
caseDL_GENERIC_ISO14443_4:
return"DL_GENERIC_ISO_14443_4";
caseDL_MIFARE_PLUS_SE_SL0:
return"DL_MIFARE_PLUS_SE_SL0";
caseDL_MIFARE_PLUS_SE_SL1:
return"DL_MIFARE_PLUS_SE_SL1";
caseDL_MIFARE_PLUS_SE_SL3:
return"DL_MIFARE_PLUS_SE_SL3";
caseDL_MIFARE_DESFIRE_LIGHT:
return"DL_MIFARE_DESFIRE_LIGHT";
caseDL_GENERIC_ISO14443_4_TYPE_B:
return"DL_GENERIC_ISO14443_4_TYPE_B";
caseDL_GENERIC_ISO14443_3_TYPE_B:
return"DL_GENERIC_ISO14443_3_TYPE_B";
caseDL_IMEI_UID:
return"DL_IMEI_UID";
}
return"UNKNOWN CARD";
}
//------------------------------------------------------------------------------
/*
* uFR.h
*/
#ifndef UFR_H_
#define UFR_H_
#include "ini.h"
//------------------------------------------------------------------------------
typedefconstchar*sz_ptr;
//------------------------------------------------------------------------------
boolCheckDependencies(void);
sz_ptrGetDlTypeName(uint8_tdl_type_code);
//------------------------------------------------------------------------------
#endif/* UFR_H_ */
/*
* utils.c
*/
#include
#include
#include
#include "ini.h"
#include "utils.h"
//------------------------------------------------------------------------------
size_thex2bin(uint8_t*dst,constchar*src){
size_tdst_len=0;
chars_tmp[3];
s_tmp[2]='\0';
while(*src){
while(((char)*src<'0'||(char)*src>'9')
&&((char)*src<'a'||(char)*src>'f')
&&((char)*src<'A'||(char)*src>'F'))
src++;// skip delimiters, white spaces, etc.
s_tmp[0]=(char)*src++;
// Must be pair of the hex digits:
if(!(*src))
break;
// And again, must be pair of the hex digits:
if(((char)*src<'0'||(char)*src>'9')
&&((char)*src<'a'||(char)*src>'f')
&&((char)*src<'A'||(char)*src>'F'))
break;
s_tmp[1]=(char)*src++;
*dst++=strtoul(s_tmp,NULL,16);
dst_len++;
}
returndst_len;
}
//------------------------------------------------------------------------------
voidprint_ln_len(charsymbol,uint8_tcnt){
for(inti=0;i<cnt;i++)
printf("%c",symbol);
printf("\n");
}
//------------------------------------------------------------------------------
inlinevoidprint_ln(charsymbol){
print_ln_len(symbol,DEFAULT_LINE_LEN);
}
//------------------------------------------------------------------------------
voidprint_hex(constuint8_t*data,uint32_tlen,constchar*delimiter){
for(inti=0;i<len;i++){
printf("%02X",data[i]);
if((delimiter!=NULL)&&(i<(len-1)))
printf("%c",*delimiter);
}
}
//------------------------------------------------------------------------------
voidprint_hex_ln(constuint8_t*data,uint32_tlen,constchar*delimiter){
print_hex(data,len,delimiter);
printf("\n");
}
//==============================================================================
/*
* utils.h
*/
#ifndef UTILS_H_
#define UTILS_H_
#define DEFAULT_LINE_LEN 60
size_thex2bin(uint8_t*dst,constchar*src);
voidprint_ln_len(charsymbol,uint8_tcnt);
voidprint_ln(charsymbol);
voidprint_hex(constuint8_t*data,uint32_tlen,constchar*delimiter);
voidprint_hex_ln(constuint8_t*data,uint32_tlen,constchar*delimiter);
#endif/* UTILS_H_ */
@echo off
set path=..\lib\windows\x86_64;%path%
nt4h_c_example
    Markdownis supported
    0%or
    You are about to add0peopleto the discussion. Proceed with caution.
    Finish editing this message first!
    Pleaseregisterorto comment
    Baidu
    map