nfc-tools / libfreefare

A convenience API for NFC cards manipulations on top of libnfc.
Other
402 stars 105 forks source link

Introduce timeout on DESfire operations #97

Closed manu0401 closed 5 years ago

manu0401 commented 5 years ago

There are a few reasons why an NFC operation may timeout, including the pn533 USB toggle bit bug. In that case it helps to report the problem to calling process so that it can retry operation, instead of hanging forever.

For instance, mifare_desfire_format_picc() may make the chip unresponsive (see commit 91d3ff9cc4d3b59573c2301e0dc4c8f034ba13f2), but if calling process gets ETIMEDOUT, it can select_application, authenticate and format_picc again, with some success.

smortex commented 5 years ago

Yes, this looks reasonable. Can you rebase / squash your changes on top of this project's master so that the PR has only a single commit @manu0401 ? Thanks!

manu0401 commented 5 years ago

@smortex: I rebased and made a new pullup, but I am not completely sure this is what you were looking for. If it is not, please be more precise (git commands!)

smortex commented 5 years ago

@manu0401 git is a pain :-)

Assuming your git repo has two remotes, origin and manu0401 and you are in the master branch of manu0401:

git fetch --all          # Gather all commits in all remotes locally
git rebase origin/master # Move all commits on top of the the master branch of origin
# You may have to fix conflicts here
vim libfreefare/mifare_desfire.c
git add libfreefare/mifare_desfire.c
git rebase --continue
# Repeat to fix each conflict

You will end with two commits "above" the master branch of this repository. Now combine them into a single commit:

git rebase -i origin/master

This will open your editor listing all commits between origin/master and manu0401/master. On the second line, replace "pick" with "fixup", save and exit.

Now that the commit have been rewritten, push your changes (-f is required since you changed the history):

git push -f manu0401 master

I let you try this as an exercise :smiley: If you don't make it, no worry, I'll merge outside of GitHub

manu0402 commented 5 years ago

@smortex: it is not a pain, it is a nasty mess.

I could not get it done, the thing would always complain about conflicts. I restarted it from scratch and made pull request #98

smortex commented 5 years ago

Close in favor of #98.