Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device.InitiatorSelectPassiveTarget does not work #8

Closed
Lesterpig opened this issue Jan 14, 2016 · 4 comments
Closed

Device.InitiatorSelectPassiveTarget does not work #8

Lesterpig opened this issue Jan 14, 2016 · 4 comments

Comments

@Lesterpig
Copy link

  • In v2.0, the second parameter of Device.InitiatorSelectPassiveTarget is not used
  • In v2.0, the libnfc return code is not considered correctly: if the value if negative, then its an error, else it returns the number of selected tags

Reference: http://www.libnfc.org/api/group__initiator.html#gacbe0fa197206cac99c83ed0152174811

The dev version is not working, but I can purpose a PR for a fix in 2.0 if needed :)

@clausecker
Copy link
Owner

Thank you for reporting this issue. Currently investigating the problem and looking for a fix.

To your first point, the call to C.nfc_initiator_select_passive_target looks like this:

   n := C.nfc_initiator_select_passive_target(
            *d.d,
            C.nfc_modulation{C.nfc_modulation_type(m.Type), C.nfc_baud_rate(m.BaudRate)},
            (*C.uint8_t)(&initData[0]),
            C.size_t(len(initData)),
            &pnt)

where initData is the second parameter of (*Device).InitiatorSelectPassiveTarget. It's used twice in the appropriate places. Could you elaborate with what you mean by “the second parameter of Device.InitiatorSelectPassiveTarget is not used?” There is a possible nil pointer dereference (which I'm fixing right now).

The second error is already fixed locally on my machine.

@Lesterpig
Copy link
Author

Thank you for your answer!

It's used twice in the appropriate places

My mistake, I had a "hotfix" version on my computer to handle the null case... Sorry for that.
There is still a tiny bug here you underlined with the null default value, or in case of empty slice.

clausecker added a commit that referenced this issue Jan 14, 2016
 B Fix error handling in (*Device).InitiatorSelectPassiveTarget()
 B Fix initData handling (ibid.), these fix issue #8
 R Improve documentation (ibid.)
@clausecker
Copy link
Owner

Closing this. Please tell me if the issue persists and reopen if it does.

@Lesterpig
Copy link
Author

Now works like a charm, thank you very much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants