AnsweredAssumed Answered

PN7120 raw transceive command doesn't work

Question asked by Michal Grosicki on Jan 17, 2017
Latest reply on Feb 7, 2017 by Michal Grosicki

Hello everyone,

We're trying to utilize linux_libnfc-nci library to read/write ISO 15693 tags (concretely ICODE SLIX). We are using OM5577 development kit with raspberry pi and linux image provided on the kit's site. Demo app included with the code works fine. We are able to poll, read and write NDEF messages to various types of tags (aforementioned SLIXes, but also NTags for example). Problems start when we try to use the library in our own code. Below is a very simple code we are running (in this instance we try to get system informations, but we tried several other commands like read single block or read multiple blocks):

#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "linux_nfc_api.h"

void arrival_callback(nfc_tag_info_t * tag_info) {
   int tx_len = 2;
   unsigned char tx[2] = {0x00, 0x2B};
   unsigned char rx[255];
   int result;
   int i;
   memset(rx, 0, 255);
   printf("Hello\n");
   for (i = 0; i < tag_info->uid_length; i++) {
      printf("%02X", tag_info->uid[i]);
   }
   printf("\nIs it me you're looking for?\n");
   result = nfcTag_transceive(tag_info->handle, tx, tx_len, rx, 255, 500);
   printf("Result: %d\nData: [%s]\nHandle: %d\n", result, rx, tag_info->handle);

}

void departure_callback(void) {
   printf("Bye\n");
}

int main(void) {
   nfcTagCallback_t callback;
   callback.onTagArrival = arrival_callback;
   callback.onTagDeparture = departure_callback;
   nfcManager_doInitialize();
   nfcManager_registerTagCallback(&callback);
   nfcManager_enableDiscovery(0xef, 0, 0, 0);
   printf("NFC status: %d\n", nfcManager_isNfcActive());
   getchar();
   nfcManager_disableDiscovery();
   nfcManager_doDeinitialize();
   return 0;
}

After running above code we can see, that the tag is detected by the reader, we get correct tag ID, but nfcTag_transceive function always returns 0. Looking at the provided API guide it seems like it should work, but maybe we're missing something.

 

Looking forward for suggestions.

Best regards,

Michał

Outcomes