Closed cpeppler01 closed 6 years ago
I went back through my notes, and discovered this:
=================
**Note that nfc-poll with a PN532 will not detect the barcode.
nfc-poll on PN532 is using the internal InAutoPoll coded in its firmware and is limited to the hardcoded protocols.**
On a PN533 it is possible if NMT_BARCODE is added to the searched moculations (nfc-poll.c line 104).
The solution would be to fall back to the same manual polling for the PN532 but at the moment it doesn't work for a reason I've to investigate.
Do you really need nfc-poll + barcode + pn532 at the moment?
================ So, nvm. It's not happening, and has an explanation.
Philippe Teuwen was kind enough to add support for the Thinfilm NFC tag around May of last year. I've picked up development using this tag again, and have found a problem that I cannot resolve.
According to the attached source file (which is a derivative of the generic nfc-poll.c example), I have made very minor modifications to the nmModulations array, providing instructions for the poll target about which modulations to poll.
If I simply change from an existing modulation (such as NMT_ISO14443B) to the new modulation (NMT_BARCODE), I consistently get a failure upon attempting to initiate the poll target using nfc_initiator_poll_target():
pi@raspi:~/dev/C/nfcd $ ./nfc-poll ./nfc-poll uses libnfc libnfc-1.7.1-191-g216145f NFC reader: Capnetix Adafruit - ttyS0 opened NFC device will poll during 12000 ms (20 pollings of 300 ms for 2 modulations) nfc_initiator_poll_target: Invalid argument(s)
If I remove the NMT_BARCODE, it works fine.
`#ifdef HAVE_CONFIG_H
include "config.h"
endif // HAVE_CONFIG_H
include
include
include
include
include
include
include
include <nfc/nfc.h>
include <nfc/nfc-types.h>
include "utils/nfc-utils.h"
define MAX_DEVICE_COUNT 16
static nfc_device pnd = NULL; static nfc_context context;
static void stop_polling(int sig) { (void) sig; if (pnd != NULL) nfc_abort_command(pnd);
nfc_exit(context); exit(EXIT_FAILURE); }
static void print_usage(const char *progname) { printf("usage: %s [-v]\n", progname); printf(" -v\t verbose display\n"); }
int main(int argc, const char *argv[]) { bool verbose = false;
signal(SIGINT, stop_polling); signal(SIGHUP, stop_polling);
// Display libnfc version const char *acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion); if (argc != 1) { if ((argc == 2) && (0 == strcmp("-v", argv[1]))) { verbose = true; } else { print_usage(argv[0]); exit(EXIT_FAILURE); } }
const uint8_t uiPollNr = 20; const uint8_t uiPeriod = 2; / orig const nfc_modulation nmModulations[5] = { { .nmt = NMT_ISO14443A, .nbr = NBR_106 }, { .nmt = NMT_ISO14443B, .nbr = NBR_106 }, { .nmt = NMT_FELICA, .nbr = NBR_212 }, { .nmt = NMT_FELICA, .nbr = NBR_424 }, { .nmt = NMT_JEWEL, .nbr = NBR_106 }, }; const size_t szModulations = 5; /
const nfc_modulation nmModulations[2] = { { .nmt = NMT_ISO14443A, .nbr = NBR_106 }, // { .nmt = NMT_BARCODE, .nbr = NBR_106 }, { .nmt = NMT_ISO14443B, .nbr = NBR_106 }, }; const size_t szModulations = 2;
nfc_target nt; int res = 0;
nfc_init(&context); if (context == NULL) { ERR("Unable to init libnfc (malloc)"); exit(EXIT_FAILURE); }
pnd = nfc_open(context, NULL);
if (pnd == NULL) { ERR("%s", "Unable to open NFC device."); nfc_exit(context); exit(EXIT_FAILURE); }
if (nfc_initiator_init(pnd) < 0) { nfc_perror(pnd, "nfc_initiator_init"); nfc_close(pnd); nfc_exit(context); exit(EXIT_FAILURE); }
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd)); printf("NFC device will poll during %ld ms (%u pollings of %lu ms for %" PRIdPTR " modulations)\n", (unsigned long) uiPollNr szModulations uiPeriod 150, uiPollNr, (unsigned long) uiPeriod 150, szModulations); if ((res = nfc_initiator_poll_target(pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) { nfc_perror(pnd, "nfc_initiator_poll_target"); nfc_close(pnd); nfc_exit(context); exit(EXIT_FAILURE); } `