Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/xblaz3kx/nfc-reader-go-example

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/xblaz3kx/nfc-reader-go-example

  • v0.0.0-20240410201532-72308c89d9a7
  • Source
  • Go
  • Socket score

Version published
Created
Source

Go NFC library example code

This is an example code for reading a NFC/RFID tag with a reader using NFC library for Go. The NFC library requires to have libnfc 1.8.0+ installed on your device.

I was using a Raspberry Pi with PN532 and followed the instructions from Adafruit: Building libnfc on Raspberry Pi .

Building libnfc for PN532

  1. Get and extract the libnfc:

     cd ~
     mkdir libnfc && cd libnfc/
     wget https://github.com/nfc-tools/libnfc/releases/download/libnfc-1.8.0/libnfc-1.8.0.tar.bz2
     tar -xvjf libnfc-1.8.0.tar.bz2
    

    Next two steps depend on your reader and it's configuration of libnfc

  2. Create PN532 configuration:

     cd libnfc-1.8.0
     sudo mkdir /etc/nfc
     sudo mkdir /etc/nfc/devices.d
     sudo cp contrib/libnfc/pn532_uart_on_rpi.conf.sample /etc/nfc/devices.d/pn532_uart_on_rpi.conf 
     sudo nano /etc/nfc/devices.d/pn532_uart_on_rpi.conf
    
  3. Update the pn532_uart_on_rpi.conf:

    allow_intrusive_scan = true
    
  4. Install dependencies for building:

     sudo apt-get install autoconf
     sudo apt-get install libtool
     sudo apt-get install libpcsclite-dev libusb-dev
     autoreconf -vis
     ./configure --with-drivers=pn532_uart --sysconfdir=/etc --prefix=/usr
    
  5. Build the library:

    sudo make clean
    sudo make install all
    

Running the code:

Clone the repo:

git clone https://github.com/xBlaz3kx/nfc-reader-go-example/

Install the libnfc, then run:

go run nfc-reader-example.go 

or

 go build nfc-reader-example.go && ./nfc-reader-example

FAQs

Package last updated on 10 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc