Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (72 sloc) 2 KB
Package acr122u is a library for the ACR122U USB NFC Reader
ACR122U USB NFC Reader
Middleware to access a smart card using SCard API (PC/SC)
Under macOS pcsc-lite can be installed using homebrew: brew install pcsc-lite
The Go bindings to the PC/SC API
You can install the acr122u package using go get
go get -u
A minimal usage example
package main
import (
func main() {
ctx, err := acr122u.EstablishContext()
if err != nil {
ctx.ServeFunc(func(c acr122u.Card) {
fmt.Printf("%x\n", c.UID())
package acr122u
import (
// ShareMode is the share mode type
type ShareMode uint32
// Share modes
var (
ShareExclusive ShareMode = 0x1
ShareShared ShareMode = 0x2
// Protocol is the protocol type
type Protocol uint32
// Protocols
var (
ProtocolUndefined Protocol = 0x0
ProtocolT0 Protocol = 0x1
ProtocolT1 Protocol = 0x2
ProtocolAny = ProtocolT0 | ProtocolT1
// Commands that can be transmitted to a *scard.Card
var (
cmdGetUID = []byte{0xFF, 0xCA, 0x00, 0x00, 0x04}
// Response codes
var (
rcOperationSuccess = []byte{0x90, 0x00}
rcOperationFailed = []byte{0x63, 0x00}
// scardContext is the interface used to communicate
// with one or more ACR122U USB NFC Readers.
type scardContext interface {
Connect(string, scard.ShareMode, scard.Protocol) (*scard.Card, error)
ListReaders() ([]string, error)
Release() error
IsValid() (bool, error)
GetStatusChange(readerStates []scard.ReaderState, timeout time.Duration) error
// scardCard is the interface used by a *card to
// communicate with the underlying *scard.Card
type scardCard interface {
Transmit([]byte) ([]byte, error)
Status() (*scard.CardStatus, error)
You can’t perform that action at this time.