Sha256: 3f0594d73ee3981845b2c3bad853452c59d9fb765fa3b494d1982c8b31e73591
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'mfrc522' require 'tamashii/agent/device/card_reader/base' module Tamashii module Agent module Device module CardReader class Mfrc522Spi < Base def initialize(*args) super @reader = MFRC522.new(fetch_option(:reset_pin, default_reset_pin)) end def default_reset_pin 24 end def poll_uid # check antenna return nil unless @reader.picc_request(MFRC522::PICC_REQA) # read uid uid = nil begin uid, sak = @reader.picc_select rescue CommunicationError, UnexpectedDataError => e logger.error "Error when selecting card: #{e.message}" uid = :error rescue => e uid = :error logger.error "GemError when selecting card: #{e.message}" ensure @reader.picc_halt end uid end def shutdown @reader.shutdown end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems