Class: Smartware::Driver::CardReader::ICT3K5

Inherits:
Object
  • Object
show all
Defined in:
lib/smartware/drivers/card_reader/ict3_k5.rb

Constant Summary collapse

ERRORS =
{
  0x00 => Interface::CardReader::COMMUNICATION_ERROR, # A given command code is unidentified
  0x01 => Interface::CardReader::COMMUNICATION_ERROR, # Parameter is not correct
  0x02 => Interface::CardReader::COMMUNICATION_ERROR, # Command execution is impossible
  0x03 => Interface::CardReader::COMMUNICATION_ERROR, # Function is not implemented
  0x04 => Interface::CardReader::COMMUNICATION_ERROR, # Command data error
  0x06 => Interface::CardReader::COMMUNICATION_ERROR, # Key for decrypting is not received
  0x10 => Interface::CardReader::CARD_JAM_ERROR,
  0x11 => Interface::CardReader::CARD_ERROR,          # Shutter error
  0x13 => Interface::CardReader::CARD_ERROR,          # Long card
  0x14 => Interface::CardReader::CARD_ERROR,          # Short card
  0x15 => Interface::CardReader::HARDWARE_ERROR,      # Flash Memory Parameter Area CRC error
  0x16 => Interface::CardReader::CARD_ERROR,          # Card position move
  0x17 => Interface::CardReader::CARD_JAM_ERROR,      # Jam error at retrieve
  0x18 => Interface::CardReader::CARD_ERROR,          # Two card error
  0x20 => Interface::CardReader::MAG_READ_ERROR,      # Parity error
  0x21 => Interface::CardReader::MAG_READ_ERROR,      # Sentinel error
  0x23 => Interface::CardReader::MAG_READ_ERROR,      # No data contents
  0x24 => Interface::CardReader::MAG_READ_ERROR,      # No stripe
  0x30 => Interface::CardReader::HARDWARE_ERROR,      # Power loss
  0x31 => Interface::CardReader::COMMUNICATION_ERROR, # DTR low
  0x39 => Interface::CardReader::HARDWARE_ERROR,      # Fan failure
  0x40 => Interface::CardReader::CARD_ERROR,          # Pull out error
  0x43 => Interface::CardReader::CARD_ERROR,          # IC positioning error
  0x50 => Interface::CardReader::HARDWARE_ERROR,      # Capture counter overflow
  0x60 => Interface::CardReader::ICC_ERROR,           # Abnormal VCC condition
  0x61 => Interface::CardReader::ICC_ERROR,           # ATR error
  0x62 => Interface::CardReader::ICC_ERROR,           # Invalid ATR error
  0x63 => Interface::CardReader::ICC_ERROR,           # No response
  0x64 => Interface::CardReader::ICC_ERROR,           # Communication error
  0x65 => Interface::CardReader::ICC_ERROR,           # Not activated
  0x66 => Interface::CardReader::ICC_ERROR,           # Unsupported card
  0x69 => Interface::CardReader::ICC_ERROR,           # Unsupported card
  0x73 => Interface::CardReader::HARDWARE_ERROR,      # EEPROM error
  0xB0 => Interface::CardReader::COMMUNICATION_ERROR  # Not received initialize
}

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ICT3K5

Returns a new instance of ICT3K5.



44
45
46
47
48
49
50
51
52
53
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 44

def initialize(config)
  @ready = false
  @accepting = false

  @port = SerialPort.new(config["port"], 115200, 8, 1, SerialPort::EVEN)
  @port.flow_control = SerialPort::HARD

  @connection = EventMachine.attach @port, SankyoConnection
  @connection.initialize_device = method :initialize_device
end

Instance Method Details

#accepting=(accepting) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 71

def accepting=(accepting)
  if accepting
    set_led :green
    resp = @connection.command 0x3A, 0x30
  else
    set_led :red
    resp = @connection.command 0x3A, 0x31
  end

  translate_response resp

  @accepting = accepting
end

#accepting?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 67

def accepting?
  @accepting
end

#captureObject



92
93
94
95
96
97
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 92

def capture
  resp = @connection.command 0x33, 0x31
  translate_response resp

  self
end

#ejectObject



85
86
87
88
89
90
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 85

def eject
  resp = @connection.command 0x33, 0x30
  translate_response resp

  self
end

#modelObject



55
56
57
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 55

def model
  "ICT3K5"
end

#read_magstripObject



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 120

def read_magstrip
  [ 0x31, 0x32, 0x33, 0x34 ].map! do |track|
    resp = @connection.command 0x36, track
    translate_response resp if resp.nil?

    if resp.positive?
      resp.response[4..-1]
    else
      nil
    end
  end
end

#ready?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 63

def ready?
  @ready
end

#statusObject



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 99

def status
  return :not_ready if !ready?

  resp = @connection.command 0x31, 0x30
  translate_response resp

  case resp.response[2..3]
  when "00"
    :ready

  when "01"
    :card_at_gate

  when "02"
    :card_inserted

  else
    :not_ready
  end
end

#versionObject



59
60
61
# File 'lib/smartware/drivers/card_reader/ict3_k5.rb', line 59

def version
  ""
end