Hi Mario,
you are right.
Yes, I created the erase function using the nfcTag_formatTag function of the linux_libnfc-nct-master library.
Reading never had a problem.
Src/services/linux_nfc_api.c
…
int nfcTag_formatTag(unsigned int handle)
{
int ret;
ret = nativeNfcTag_doFormatTag(handle);
return ret;
}
Src/services/interface/nativelNfcTag.cpp
I think there is a problem with the „gSyncMutex“
…..
INT32 nativeNfcTag_doFormatTag(UINT32 tagHandle)
{
NXPLOG_API_D ("%s: enter", __FUNCTION__);
tNFA_STATUS status = NFA_STATUS_FAILED;
UINT32 handle = sCurrentConnectedHandle;
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
isMifare = FALSE;
#endif
gSyncMutex.lock();
if (!nativeNfcManager_isNfcActive())
{
NXPLOG_API_E ("%s: Nfc not initialized.", __FUNCTION__);
goto End;
}
if (tagHandle != sCurrentConnectedHandle)
{
NXPLOG_API_E ("%s: Wrong tag handle!\n)", __FUNCTION__);
goto End;
}
// Do not try to format if tag is already deactivated.
if (NfcTag::getInstance ().isActivated () == FALSE)
{
NXPLOG_API_D ("%s: tag already deactivated(no need to format)", __FUNCTION__);
goto End;
}
sem_init (&sFormatSem, 0, 0);
sFormatOk = FALSE;
if (NfcTag::getInstance ().mTechLibNfcTypes[handle] == NFA_PROTOCOL_MIFARE)
{
status = nativeNfcTag_doReconnect ();
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
isMifare = TRUE;
NXPLOG_API_D("Format with First Key");
status = EXTNS_MfcFormatTag(key1,sizeof(key1));
#endif
}
else
{
status = NFA_RwFormatTag ();
}
if (status == NFA_STATUS_OK)
{
NXPLOG_API_D ("%s: wait for completion", __FUNCTION__);
sem_wait (&sFormatSem);
status = sFormatOk ? NFA_STATUS_OK : NFA_STATUS_FAILED;
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
if(sFormatOk == TRUE && isMifare == TRUE)
{
NXPLOG_API_D ("Format with First Key Success");
}
#endif
}
else
{
NXPLOG_API_E ("%s: error status=%u", __FUNCTION__, status);
}
sem_destroy (&sFormatSem);
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
if(isMifare == TRUE && sFormatOk != TRUE)
{
NXPLOG_API_D ("Format with First Key Failed");
sem_init (&sFormatSem, 0, 0);
status = nativeNfcTag_doReconnect ();
NXPLOG_API_D ("Format with Second Key");
status = EXTNS_MfcFormatTag(key2,sizeof(key2));
if (status == NFA_STATUS_OK)
{
NXPLOG_API_D ("%s:2nd try wait for completion", __FUNCTION__);
sem_wait (&sFormatSem);
status = sFormatOk ? NFA_STATUS_OK : NFA_STATUS_FAILED;
}
else
{
NXPLOG_API_E ("%s: error status=%u", __FUNCTION__, status);
}
sem_destroy (&sFormatSem);
if(sFormatOk)
{
NXPLOG_API_D ("Format with Second Key Success");
}
else
{
NXPLOG_API_D ("Format with Second Key Failed");
}
}
#endif
if (NfcTag::getInstance ().mTechLibNfcTypes[handle] == NFA_PROTOCOL_ISO_DEP)
{
nativeNfcTag_doReconnect ();
}
End:
gSyncMutex.unlock();
NXPLOG_API_D ("%s: exit", __FUNCTION__);
return sFormatOk ? NFA_STATUS_OK : NFA_STATUS_FAILED;
}
Regards
Dieter
Von: mario_castaneda <admin@community.nxp.com>
Gesendet: Mittwoch, 29. Januar 2020 19:55
An: Dieter Rudolph <Dieter.Rudolph@truetzschler.de>
Betreff: Re: - Re: linux_libnfc-nci-master - with PN7150 - nativeNfcTag_doFormatTag
NXP Community <https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>
Re: linux_libnfc-nci-master - with PN7150 - nativeNfcTag_doFormatTag
reply from Mario Ignacio Castaneda Lopez<https://community.nxp.com/people/mario_castaneda?et=watches.email.thread> in NFC - View the full discussion<https://community.nxp.com/message/1261673?commentID=1261673&et=watches.email.thread#comment-1261673>