I'm actually using libnfc with JNI, so I can use it in Processing . I've compiled a simple library that can check if an RFID reader is connected, and which tag (ISO14443A) is present on the reader. Everything was working fine and solidly.
Reading the lsnfc.c was assurance enough that reading multiple tags was simple enough. I changed the method that returns a string with the tag ID, so now it would return an array with tag IDs.
The problem is that my application in Processing crashes if I check for tags more than once. The structure of my application is as follows:
1. I check if the reader is connected.
2. If it is, I pick up the array with the tag IDs from the tags at the reader.
3. If the array is empty I draw a small white box on the screen.
4. If the array is not empty, I draw a different shape for each of the tags present.
If I have the RFID reader with no tags present, Processing keeps drawing the white box, meaning that the library can check continuously for tags, returning an empty array. If I have a tag on the reader (or place one after the application has launched), everything crashes, but only after drawing the correct shapes once.
It must mean that the library crashes when I try to re-generate a new array with tag ids (but only if the length of the array is more than 0), but I really don't know why. On the previous version I could check which tag was present at any time - the only major difference is this piece of code (from lsnfc.c):
do {
// Reads the Tag from the RFID Reader
if (nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti)) {
// Converts the Tag ID from hex to String
strcpy(tagId,"");
for (uiPos=0; uiPos < ti.tia.uiUidLen; uiPos++) {
sprintf(temp,"%02x",ti.tia.abtUid[uiPos]);
strcat(tagId,temp);
}
strcpy(tagsTmp[tag_count], tagId);
tag_count++;
nfc_initiator_deselect_tag(pdi);
} else {
no_more_tags = true;
}
} while (no_more_tags != true);
Any help would be great, if it helps I can post the rest of the code
Last edited by Rorsch (2010-03-14 20:21:42)