1. What type of tags are you using? Because the answer may be different.
2. If your application is similar to inventory tracking ICODE tags are OK in the 13.56MHz band, you can read about 500-700 tags/s. But normally to track goods the right tags are UCODE working in UHF band because their range is in the order of ~10m.
3. If your application does not require the encryption features of the Mifare tags, I suggest using ISO 15693. The anticollision is more robust, but resolving collisions in every configuration will be tough, especially in the cases where tags are stacked and/or oriented 90 degrees to the reader antenna.
4. The general idea (that always works) to readall the tags in the reader range is this:
1) start to read (because the anti collision algorithm you will read the UUID of the "winner" tag)
2) turn off (halt) the "winner" tag
3) repeat from point 1) until yu will read a new UUID
4) when you will read no new tag you can turn on all the tags you turn off before
4b. If your tags support CID you can communicate with multiple tags without halting them using CID to distinguish them.
5. Anyway you can download NXPRdLib to see how manage anti collision in ISO14443. This is just a copy and paste of an example you may find there (so no need to copy and paste code from here):
static void ScanTags(void)
{
uint8_t bMoreCardsAvailable;
uint8_t bSak[1];
uint8_t numTags = 0;
bLastUidLength = 0;
/* Activate the communication layer part 3 of the ISO 14443A standard. */
status = phpalI14443p3a_Sw_ActivateCard(&I14443p3a, NULL, 0x00, bUid,
&bUidLength, bSak, &bMoreCardsAvailable);
numTags = 1;
while(PH_ERR_SUCCESS == status)
{
bLastUidLength = bUidLength;
memcpy(bSelectedUid,bUid,bUidLength);
debug_printf_msg("Tag number:");
debug_printf_hex_msg(&numTags, 1);
debug_printf_msg("UID:");
debug_printf_hex_msg(bUid, bUidLength);
//halt the tag
status = phpalI14443p3a_Sw_HaltA(&I14443p3a);
/* move on to activating the next card */
status = phpalI14443p3a_Sw_ActivateCard(&I14443p3a, NULL, 0x00,bUid,
&bUidLength, bSak, &bMoreCardsAvailable);
if(status != PH_ERR_SUCCESS)
debug_printf_msg("No more tags detected");
else
numTags++;
}
}