ruby-nfc icon indicating copy to clipboard operation
ruby-nfc copied to clipboard

Unknown mifare tag (Mifare::Error)

Open paulomcnally opened this issue 8 years ago • 9 comments

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>'

paulomcnally avatar Jun 08 '16 23:06 paulomcnally

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

hexdigest avatar Jun 09 '16 17:06 hexdigest

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

nomisoft avatar Mar 17 '17 21:03 nomisoft

@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.

hexdigest avatar Mar 18 '17 06:03 hexdigest

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

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

nomisoft avatar Mar 18 '17 15:03 nomisoft

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

hexdigest avatar Mar 18 '17 15:03 hexdigest

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

nomisoft avatar Mar 18 '17 15:03 nomisoft

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.

hexdigest avatar Mar 18 '17 16:03 hexdigest

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!

nomisoft avatar Mar 18 '17 18:03 nomisoft

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

hexdigest avatar Mar 18 '17 19:03 hexdigest