NFC Learning Notes--three (install LIBNFC on Windows operating system)

Source: Internet
Author: User
Tags doxygen regex replace win32 installer intel core 2 duo

This article translation:

This article is primarily about how to install, configure, and use LIBNFC on a Windows operating system.

I. Basic INFORMATION 1. Operating system:

Windows Vista Home Premium SP 2

2. Hardware information:

System:dell Inspiron 1720
Processor:intel Core 2 Duo CPU T9300 @ 2.5GHz 2.5GHz
System Type:32-bit Operating System

3. Required Software:

The following software and library files are required to install the software on the Windows operating system:

    • TDM-GCC MinGW Compiler
    • Libusb-win32
    • PCRE for Windows
    • CMake
    • Doxygen (not required)
If Doxygen is not installed, you will encounter the following warning: Could not find Doxygen (missing:doxygen_executable), this is negligible.

II. installation process 1. Installing TDM

Download TDM-GCC MinGW compiler at http://sourceforge.net/projects/tdm-gcc/, this download version is: Tdm64-gcc-4.7.1-3.exe

For more information about the TDM compiler, see the introduction in http://tdm-gcc.tdragon.net/.

Note: MinGW = the smallest GNU above the Windows system

1) Double click to open the execution file, press the Confirm button


2) Select Mingw-w64/tdm64 Experimental (32-bit and 64-bit) and press Next

Note:

You need to install "MINGW/TDM" version, "mingw-w64/tdm64 experimental" version will run on 32, 64-bit operating system


3) Select the TDM-GCC installation directory, for example: D:/PROGRAMFILES/MINGW64


4) Select the download server closest to you, click Next


5) Select "TDM-GCC recormmended,all Packages" and press Next


6) Wait for TDM-GCC installation to complete, click Next


7) Click the Finish button to complete the TDM-GCC installation


For information about TDM-GCC, refer to Readme-gcc-tdm64.txt file

2. Installing Libusb-win32

Download the Libusb-win32 software in http://sourceforge.net/projects/libusb-win32/, you can download the version: Libusb-win32-bin-1.2.6.0.zip. More information about this library can be found at: Http://sourceforge.net/apps/trac/libusb-win32/wiki

Download and unzip the Libusb-win32-bin-1.2.6.0zip file to your designated directory, no further action is required.

3. Installing Pcre

Download the Pcre installation package (perl-compatible regular-expression) at http://sourceforge.net/projects/gunwin32/files/pcre/7.0/, More information about Pcre can be found at: http://www.pcre.org

1. Double click to run the executable file and click Next


2) receive the agreement, click Next


3) Select the Pcre installation directory, for example: D:/programfiles/gnuwin32, click Next


4) Select "Full Installation" and press Next


5) Enter the Start menu shortcut in the Start menu and press Next


6) Select additional options and click Next


7) Click Install


8) Click Finish


4. Installing CMake

Download the CMake Windows platform Binary distribution package (Win32 installer) in http://www.cmake.org/. CMake is an open source connection library that can be cross-platform. Can download version: Cmake-2.8.11.2-win32-x86.exe

1) Double click on the executable file and click the I agree button


2) Select Add CMake to Current user system path and click Next


3) Select the CMake installation directory, for example: D:/programfiles/development/cmake, click Next


4) Select the Start menu and click Install


5) Wait for cmake installation to complete, click Next


6) Click the Finish button to complete the installation


5. Installing Doxygen

Download Doxygen in http://www.doxygen.org, such as download version: Doxygen-1.8.4.-setup.exe

Note: Installation of Doxygen is not required, and if not installed, a warning is displayed when configuring LIBNFC with CMake, but you can ignore this warning.

1) Double click on the executable file and click Next


2) receive the agreement, click Next


3) Select the Doxygen installation directory, such as: D:/programfiles/developmenttoos/doxygen


4) Select "Full Installation" and click Next


5) Enter Start menu Doxygen shortcut, click Next


6) Click Install


7) Doxygen is installing


8) Read Doxygen information and click Next


9) Click Finish


6. Installing LIBNFC

Download the Near Field Communication library file in HTTP://CODE.GOOGLE.COM/P/LIBNFC, such as: libnfc-1.7.0-rc7.tar.gz, unzip to the corresponding directory

More information about this library can be seen in: http://nfc-tools.org

7. Configure LIBNFC

LIBNFC currently only supports UART communication using the simple USB-to-UART adapter tool FTDI. You need to configure LIBNFC to support the UART and PN532 instruction sets before compiling.

The following modifications need to be made:

1) The following error message will appear when using Mingw32-make "c:\libnfc-build\windows\libnfc.rc:25:37:warning:missing terminating" character [ Enabled by default] ", edit the Libnfc-1.7.0-rc7/cmakelists.txt file to:

MACRO (get_current_year RESULT)   execute_process (COMMAND "cmd" "/C date/t" output_variable ${result})   STRING ( REGEX REPLACE ". * (..) /(..) /(....). * "" "\\3" ${result} ${${result}) Endmacro (get_current_year)

Modified to:

MACRO (Get_current_year RESULT)
Execute_process (COMMAND "cmd" "/C date/t" output_variable ${result})
STRING (REGEX REPLACE "\ n" "" ${result} ${${result}})
STRING (REGEX REPLACE ". * (..) /(..) /(....). * "" "\\3" ${result} ${${result})
Endmacro (Get_current_year)

2) Unless the driver is attached, the pn532 default time-out is not sufficient, and the NFC reader is unreadable. It takes a long time to wait to PN532 wake up this is necessary. It is therefore necessary to follow the 30 0x00 after sending the 0x55

Will:

Const uint8_t pn532_wakeup_preamble[] = {0x55, 0x55, 0x00, 0x00, 0x00};

Modified to:

Const uint8_t pn532_wakeup_preamble[] = {0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x -XX, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

3) If copy libnfc-1.7.0-rc7\libnfic.config.sample is libnfc.conf, this file will not be read. Do not copy libnfc.conf.sample, there is another way to modify the Libnfc-1.7.0-rc7/libnfc/nfc-internal.c file, will:

Res->allow_intrusive_scan = False

Modified to:

Res->allow_intrusive_scan = true;

8. Set the system path

To open the System Properties window:

Right-click on "Computer"

Select "Properties"

Click "Advanced System Settings", open the "Advanced" window, click "Environment Variables"


In the System Change Quantum window, select, click Edit


Edit the system environment variable "path" and add the following path (if not added)

D:\ProgramFiles\DevelopmentTools\doxygen\bin; (If you installed Doxygen)
D:\ProgramFiles\DevelopmentTools\MinGW64\bin;
D:\ProgramFiles\DevelopmentTools\MinGW64\x86_64-w64-mingw32\lib32;
D:\ProgramFiles\DevelopmentTools\MinGW64\x86_64-w64-mingw32\include;
D:\ProgramFiles\DevelopmentTools\CMake\bin;
D:\ProgramFiles\DevelopmentTools\GnuWin32\bin;

To test whether the required software and libraries are installed and the system variables are configured correctly, open the DOS window and run the CMake command:


9. Configure CMake LIBNFC Project

1) Create Libnfc-build folder

2. Open the DOS window to enter the Libnfc-build folder and enter the Cmake-gui command

The cmake is used to configure and produce the compilation files required for software engineering. The basic steps for configuring a project are as follows:

A. Select the project source directory, this directory should include CMakeLists.txt file, in this article LIBNFC source directory is D:\ProgramFiles\DevelopmentToos\libnfc-1.7.0-rc7

B. Select the compilation directory for the project. This directory is a project compiled directory, it can be a directory with the source directory, or it can be a different directory. It is recommended to use a separate directory for easy cleaning. If the directory does not exist, CMake will automatically create the directory. The compilation directory in this article is Libnfc-build


After selecting the source and binary directories, click "Configure" to install, open the configuration window:

A. Select the "MinGW makefiles" producer

B. Select "Use default native compilers"

C. Click the Finish button


This allows the cmake to read all the input files and discover the variables that are used by all the projects. The first variable will be shown on a red background and we need to modify the detected red variable correctly. For some engineering configuration to be done several times, so continue to click the Configure button, know that there is no red so far.


Fix these errors:

A. Click Pcre_include_dirs, fill in: D:/programfiles/developmenttools/gunwin32/include

B. Click Pcre_libraries, fill in: D:/PROGRAMFILES/DEVELOPMENTTOOLS//GUNWIN32LIB/LIBPCRE.DLL.A

C. Click the Configure button


Modification Error:

A. Click Libusb_include_dirs variable, fill in: D:/programfiles/developmenttools/libusb-win32-bin-1.2.6.0/include

B. Click the libusb_libraries variable and select file: D:/PROGRAMFILES/DEVELOPMENTTOOLSLIBUSB-WIN32-BIN-1.2.6.0/LIB/GCC/LIBUSB.A

With the above steps, you can compile a 32-bit program. For 64-bit systems, 32-bit, 64-bit applications can run, but 64-bit programs run only on 64-bit operating systems.

a.32 bit MinGW GCC

Libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a

b.64 bit MinGW GCC

Connect directly to Libusb0.dll or create your own import Lib

c.32 bit MSVC (=microsoft Visual C + +)

Libusb-win32-bin-1.2.6.0\lib\msvc\libusb.lib

d.64 bit MSVC

Libusb-win32-bin-1.2.6.0\lib\msvc_x64\libusb.lib

c.64 bit MSVC for IA64

Libusb-win32-bin-1.2.6.0\lib\bcc\libusb.lib

D.borland C (32-bit only)

Libusb-win32-bin-1.2.6.0/lib/bcc/libusb.lib

E. Other compilers, using dynamic

Libusb-win32-bin-1.2.6.0\lib\dynamic\libusb-dyn.c

Click the Configure button again


Configure the LIBNFC according to your needs and know that there is no red warning. In my environment I will connect Adafruit PN532 RFID/NFC through the FTDI panel to Windows Vista. Since LIBNFC currently only supports communication via the UART, I have made the following changes:

A. Setting Cmake_build_type=debug

B. Set Cmake_isntall_prefix=c:/program files/libnfc/

C. Setting Libnfc_debug_mode=on

D. Setting Libnfc_driver_pn532_uart=on

E. Set all Libnfc_driver_nnn=OFF

F. Setting Libnfc_sysconfdir=c:/program Files/libnfc/config

Click the Configure button and then click the Generate button

It will generate files in the Libnfc-build directory

10. Compile window execution files and libnfc.dll files with Mingw32-make

Enter the Libnfc-build directory, enter Mingw32-make, and the execution file is created:

Libnfc-build\utils directory: Nfc-emulate-forum-tag4.exe, Nfc-list.ext, Nfc-mfclassic.exe, Nfc-mfultralight.exe, Nfc-read-forum-tag3.exe, Nfc-relay-picc.exe, Nfc-scan-devicxe.exe

Libnfc-build\examples directory: Nfc-anticol.exe, Nfc-dep-initator.exe, Nfc-dep-target.exe, Nfc-emulate-forum-tag2.exe, Nfc-emulate-tag.exe, Nfc-emulate-uid.exe, Nfc-mfsetuid.exe, Nfc-poll.exe, Nfc-relay.exe

Libnfc.dll was also generated.

11. Copy Libnfc.dll to C:\Windows\System32

With the above steps, running Nfc-list.exe will report the following error:

This application have failed to start because Libnfc.dll is not found. Re-installing the application may fix this problem.

After you copy the Libnfc.dll file to System32, fix the error.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.