hexdigest / ruby-nfc

NFC library for Ruby programming language
MIT License
34 stars 8 forks source link

Unknown mifare tag (Mifare::Error) #3

Open paulomcnally opened 8 years ago

paulomcnally commented 8 years ago
D, [2016-06-08T17:12:17.454115 #9944] DEBUG -- : Library version: 1.7.0-rc7
D, [2016-06-08T17:12:17.683679 #9944] DEBUG -- : Available readers: [#<NFC::Reader:0x005613904b5ec0 @name="acr122_usb:001:016", @ptr=nil>, #<NFC::Reader:0x005613904b5e98 @name="acr122_pcsc:ACS ACR122U PICC Interface 00 00", @ptr=nil>]
/home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/tags/mifare/tag.rb:42:in `initialize': Unknown mifare tag (Mifare::Error)
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/tags/mifare/classic.rb:38:in `initialize'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:65:in `new'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:65:in `block (3 levels) in poll'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:63:in `each'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:63:in `block (2 levels) in poll'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:57:in `upto'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:57:in `block in poll'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:52:in `loop'
    from /home/polin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-nfc-1.3/lib/ruby-nfc/reader.rb:52:in `poll'
    from app.rb:15:in `<main>'
hexdigest commented 8 years ago

Hi, What version of libfreefare do you use? And how did you install it?

nomisoft commented 7 years ago

Hi,

I'm seeing the same error as above on a project i've inherited. Any ideas of how I can go about fixing it?

I've tried installing libnfc and libfreefare via apt-get on ubuntu 16.04 and also tried compiling the latest versions and versions from about a year ago of both libraries from the their code on github

IsoDep seems to work but I get the 'Unknown mifare tag' error for any mifare cards/tags

hexdigest commented 7 years ago

@nomisoft

Can you please dump target variable (line 40 of tags/mifare/tag.rb) and paste it here? I've seen this error when I tried wrong version of libfreefare.

nomisoft commented 7 years ago

I'm not sure if i'm doing this correctly as i'm new to ruby but i get the following: p target

p target.to_yaml --- !ruby/object:LibNFC::Target {}

hexdigest commented 7 years ago

@nomisoft it didn't help, please print value of target[:nti][:nai][:btSak]

nomisoft commented 7 years ago

I get: p target[:nti][:nai][:btSak] D, [2017-03-18T15:11:46.953329 #6644] DEBUG -- : 0

p target[:nti][:nai][:btSak].to_yaml D, [2017-03-18T15:11:46.953839 #6644] DEBUG -- : --- 0

hexdigest commented 7 years ago

It seems like you're using wrong version of libfreefare, please try to remove libfreefare installed via apt-get and then try to re-install libfreefare from github.

nomisoft commented 7 years ago

Got it working!

I was still getting the same errors using the latest code from the master branches on github but managed to get it working by compiling libnfc 1.7.0 and libfreefare 0.4.0 releases

Thanks for your help!

hexdigest commented 7 years ago

@nomisoft you're welcome. The last version of libnfc I've tried without any issues was 1.7.1