clausecker / nfc

Go bindings for the libnfc
https://pkg.go.dev/github.com/clausecker/nfc/v2
GNU Lesser General Public License v3.0
101 stars 20 forks source link

Device.InitiatorSelectPassiveTarget does not work #8

Closed Lesterpig closed 8 years ago

Lesterpig commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

Lesterpig commented 8 years ago

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