Sha256: c03bb38ec82af1feda1d7dd2b38157fce3d6526575c4d264e8ee391014a8e8cf
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
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_path}" @card_type = @options[:card_type] || :felica logger.info "Card type enabled: #{@card_type}" end def default_path "/dev/ttyAMA0" end def fetch_path if @options.has_key?(:path) path = @options[:path] else path = default_path logger.warn "No path specified. Use default path: #{path}" end path 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tamashii-agent-0.3.1 | lib/tamashii/agent/device/card_reader/pn532_uart.rb |