Sha256: 2866756c5265b85d95f107e373cd1a2457feb6f781f197f6be46a02185d29044
Contents?: true
Size: 977 Bytes
Versions: 3
Compression:
Stored size: 977 Bytes
Contents
require 'nfc' require 'tamashii/agent/device/card_reader/base' module Tamashii module Agent module Device module CardReader class Pn532Uart < Base def initialize(*args) super @ctx = NFC::Context.new @dev = @ctx.open "pn532_uart:#{fetch_option(:path, default_path)}" @card_type = @options[:card_type] || :felica logger.info "Card type enabled: #{@card_type}" end def default_path "/dev/ttyAMA0" end def poll_uid tag = @dev.poll(@card_type) if tag && !tag.is_a?(Integer) return tag.uid else return nil end rescue => e logger.error "Error when reading card: #{e.message}" return :error end def shutdown @dev.close @dev = nil end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems