Closed choongyong closed 7 years ago
Hi @choongyong
Thank you for your PR! Where did you get a source code of libfreefare you're using? At the time when I was working on this gem there were few different and incompatible versions of libfreefare. I'm afraid that this change may affect other users of this gem because they may use different version of libfreefare.
Hi, @hexdigest, I checked out libfreefare from this repository: https://github.com/nfc-tools/libfreefare
@choongyong
Here is what I found in libfreefare-dev Ubuntu's package (freefare.h):
struct mifare_tag;
typedef struct mifare_tag *MifareTag;
MifareTag freefare_tag_new (nfc_device *device, nfc_iso14443a_info nai);
Here is what I found in the repository I pointed out in the documentation: https://github.com/nfc-tools/libfreefare/blob/master/libfreefare/freefare.h:
struct freefare_tag;
typedef struct freefare_tag *FreefareTag;
FreefareTag freefare_tag_new(nfc_device *device, nfc_target target);
I believe at the point I was writing the documentation everything worked but at since then repositories diverged. Current ruby-nfc implementation works for Ubuntu users but doesn't work for those who install libfreefare from the git repository. I think ubuntu's version of libfreefare is outdated so let me check other functions signatures before I merge this PR.
@hexdigest Thanks for checking :)
Thanks!
On 1 Jul 2017, 02:18 +0800, Maxim Chechel notifications@github.com, wrote:
Merged #5. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@choongyong thank you! I also removed reference to Ubuntu's version of libfreefare from the install doc and I'm going to update the gem today.
When I run the example script, after fixing it with the change in https://github.com/hexdigest/ruby-nfc/pull/4, I get the following error:
After tracing the code, I found that in libfreefare/libfreefare/freefare.c, the method
freefare_tag_new
is defined as:However in `ruby-nfc/lib/tags/mifare/tag.rb, the following is defined:
And the method call is:
The pointer type defined and pointer type passed in is not what C the code expects. I applied the changes in this PR, and the reader is able to read the cards properly now.