Reset pnd->iLastError in nfc.c.

This commit is contained in:
Romain Tartiere 2010-08-24 10:30:18 +00:00
parent 9b44e3b2b7
commit f8ed119d1b
2 changed files with 24 additions and 31 deletions

View file

@ -622,8 +622,6 @@ pn53x_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool bEn
byte_t btValue; byte_t btValue;
byte_t abtCmd[sizeof(pncmd_rf_configure)]; byte_t abtCmd[sizeof(pncmd_rf_configure)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_rf_configure,sizeof(pncmd_rf_configure)); memcpy(abtCmd,pncmd_rf_configure,sizeof(pncmd_rf_configure));
// Make sure we are dealing with a active device // Make sure we are dealing with a active device
@ -698,8 +696,6 @@ bool pn53x_initiator_select_dep_target(nfc_device_t* pnd, const nfc_modulation_t
size_t offset; size_t offset;
byte_t abtCmd[sizeof(pncmd_initiator_jump_for_dep)]; byte_t abtCmd[sizeof(pncmd_initiator_jump_for_dep)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_initiator_jump_for_dep,sizeof(pncmd_initiator_jump_for_dep)); memcpy(abtCmd,pncmd_initiator_jump_for_dep,sizeof(pncmd_initiator_jump_for_dep));
if(nmInitModulation == NM_ACTIVE_DEP) { if(nmInitModulation == NM_ACTIVE_DEP) {
@ -749,8 +745,6 @@ bool pn53x_initiator_transceive_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx
size_t szRxLen; size_t szRxLen;
byte_t abtCmd[sizeof(pncmd_initiator_exchange_data)]; byte_t abtCmd[sizeof(pncmd_initiator_exchange_data)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_initiator_exchange_data,sizeof(pncmd_initiator_exchange_data)); memcpy(abtCmd,pncmd_initiator_exchange_data,sizeof(pncmd_initiator_exchange_data));
// We can not just send bytes without parity if while the PN53X expects we handled them // We can not just send bytes without parity if while the PN53X expects we handled them
@ -786,8 +780,6 @@ bool pn53x_initiator_transceive_bits(nfc_device_t* pnd, const byte_t* pbtTx, con
uint8_t ui8Bits = 0; uint8_t ui8Bits = 0;
byte_t abtCmd[sizeof(pncmd_initiator_exchange_raw_data)]; byte_t abtCmd[sizeof(pncmd_initiator_exchange_raw_data)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_initiator_exchange_raw_data,sizeof(pncmd_initiator_exchange_raw_data)); memcpy(abtCmd,pncmd_initiator_exchange_raw_data,sizeof(pncmd_initiator_exchange_raw_data));
// Check if we should prepare the parity bits ourself // Check if we should prepare the parity bits ourself
@ -844,8 +836,6 @@ bool pn53x_initiator_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, co
size_t szRxLen; size_t szRxLen;
byte_t abtCmd[sizeof(pncmd_initiator_exchange_raw_data)]; byte_t abtCmd[sizeof(pncmd_initiator_exchange_raw_data)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_initiator_exchange_raw_data,sizeof(pncmd_initiator_exchange_raw_data)); memcpy(abtCmd,pncmd_initiator_exchange_raw_data,sizeof(pncmd_initiator_exchange_raw_data));
// We can not just send bytes without parity if while the PN53X expects we handled them // We can not just send bytes without parity if while the PN53X expects we handled them
@ -876,9 +866,6 @@ bool pn53x_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* ps
byte_t abtRx[MAX_FRAME_LEN]; byte_t abtRx[MAX_FRAME_LEN];
size_t szRxLen; size_t szRxLen;
pnd->iLastError = 0;
// Try to gather a received frame from the reader // Try to gather a received frame from the reader
if (!pn53x_transceive(pnd,pncmd_target_get_data,2,abtRx,&szRxLen)) return false; if (!pn53x_transceive(pnd,pncmd_target_get_data,2,abtRx,&szRxLen)) return false;
@ -896,8 +883,6 @@ bool pn53x_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const s
{ {
byte_t abtCmd[sizeof(pncmd_target_set_data)]; byte_t abtCmd[sizeof(pncmd_target_set_data)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_target_set_data,sizeof(pncmd_target_set_data)); memcpy(abtCmd,pncmd_target_set_data,sizeof(pncmd_target_set_data));
// We can not just send bytes without parity if while the PN53X expects we handled them // We can not just send bytes without parity if while the PN53X expects we handled them
@ -923,8 +908,6 @@ bool pn53x_target_init(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits)
bool bPar = pnd->bPar; bool bPar = pnd->bPar;
byte_t abtCmd[sizeof(pncmd_target_init)]; byte_t abtCmd[sizeof(pncmd_target_init)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_target_init,sizeof(pncmd_target_init)); memcpy(abtCmd,pncmd_target_init,sizeof(pncmd_target_init));
// Clear the target init struct, reset to all zeros // Clear the target init struct, reset to all zeros
@ -975,9 +958,6 @@ bool pn53x_target_receive_bits(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBi
size_t szFrameBits; size_t szFrameBits;
uint8_t ui8Bits; uint8_t ui8Bits;
pnd->iLastError = 0;
// Try to gather a received frame from the reader // Try to gather a received frame from the reader
if (!pn53x_transceive(pnd,pncmd_target_receive,2,abtRx,&szRxLen)) return false; if (!pn53x_transceive(pnd,pncmd_target_receive,2,abtRx,&szRxLen)) return false;
@ -1008,9 +988,6 @@ bool pn53x_target_receive_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxL
byte_t abtRx[MAX_FRAME_LEN]; byte_t abtRx[MAX_FRAME_LEN];
size_t szRxLen; size_t szRxLen;
pnd->iLastError = 0;
// Try to gather a received frame from the reader // Try to gather a received frame from the reader
if (!pn53x_transceive(pnd,pncmd_target_receive,2,abtRx,&szRxLen)) return false; if (!pn53x_transceive(pnd,pncmd_target_receive,2,abtRx,&szRxLen)) return false;
@ -1031,8 +1008,6 @@ bool pn53x_target_send_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t
uint8_t ui8Bits = 0; uint8_t ui8Bits = 0;
byte_t abtCmd[sizeof(pncmd_target_send)]; byte_t abtCmd[sizeof(pncmd_target_send)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_target_send,sizeof(pncmd_target_send)); memcpy(abtCmd,pncmd_target_send,sizeof(pncmd_target_send));
// Check if we should prepare the parity bits ourself // Check if we should prepare the parity bits ourself
@ -1067,8 +1042,6 @@ bool pn53x_target_send_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_
{ {
byte_t abtCmd[sizeof(pncmd_target_send)]; byte_t abtCmd[sizeof(pncmd_target_send)];
pnd->iLastError = 0;
memcpy(abtCmd,pncmd_target_send,sizeof(pncmd_target_send)); memcpy(abtCmd,pncmd_target_send,sizeof(pncmd_target_send));
// We can not just send bytes without parity if while the PN53X expects we handled them // We can not just send bytes without parity if while the PN53X expects we handled them

View file

@ -238,6 +238,8 @@ void nfc_disconnect(nfc_device_t* pnd)
*/ */
bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool bEnable) bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool bEnable)
{ {
pnd->iLastError = 0;
return pn53x_configure(pnd, ndo, bEnable); return pn53x_configure(pnd, ndo, bEnable);
} }
@ -253,7 +255,6 @@ bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool
*/ */
bool nfc_initiator_init(nfc_device_t* pnd) bool nfc_initiator_init(nfc_device_t* pnd)
{ {
pnd->iLastError = 0; pnd->iLastError = 0;
// Make sure we are dealing with a active device // Make sure we are dealing with a active device
@ -286,6 +287,8 @@ bool nfc_initiator_init(nfc_device_t* pnd)
*/ */
bool nfc_initiator_select_dep_target(nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtPidData, const size_t szPidDataLen, const byte_t* pbtNFCID3i, const size_t szNFCID3iDataLen, const byte_t *pbtGbData, const size_t szGbDataLen, nfc_target_info_t* pnti) bool nfc_initiator_select_dep_target(nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtPidData, const size_t szPidDataLen, const byte_t* pbtNFCID3i, const size_t szNFCID3iDataLen, const byte_t *pbtGbData, const size_t szGbDataLen, nfc_target_info_t* pnti)
{ {
pnd->iLastError = 0;
return pn53x_initiator_select_dep_target(pnd, nmInitModulation, pbtPidData, szPidDataLen, pbtNFCID3i, szNFCID3iDataLen, pbtGbData, szGbDataLen, pnti); return pn53x_initiator_select_dep_target(pnd, nmInitModulation, pbtPidData, szPidDataLen, pbtNFCID3i, szNFCID3iDataLen, pbtGbData, szGbDataLen, pnti);
} }
@ -317,7 +320,6 @@ nfc_initiator_select_passive_target(nfc_device_t* pnd,
pnd->iLastError = 0; pnd->iLastError = 0;
// Make sure we are dealing with a active device // Make sure we are dealing with a active device
if (!pnd->bActive) return false; if (!pnd->bActive) return false;
// TODO Put this in a function // TODO Put this in a function
@ -412,7 +414,6 @@ nfc_initiator_list_passive_targets(nfc_device_t* pnd, const nfc_modulation_t nmI
pnd->iLastError = 0; pnd->iLastError = 0;
// Let the reader only try once to find a target // Let the reader only try once to find a target
nfc_configure (pnd, NDO_INFINITE_SELECT, false); nfc_configure (pnd, NDO_INFINITE_SELECT, false);
@ -443,7 +444,6 @@ nfc_initiator_list_passive_targets(nfc_device_t* pnd, const nfc_modulation_t nmI
*/ */
bool nfc_initiator_deselect_target(nfc_device_t* pnd) bool nfc_initiator_deselect_target(nfc_device_t* pnd)
{ {
pnd->iLastError = 0; pnd->iLastError = 0;
return (pn53x_InDeselect(pnd, 0)); // 0 mean deselect all selected targets return (pn53x_InDeselect(pnd, 0)); // 0 mean deselect all selected targets
@ -485,6 +485,8 @@ nfc_initiator_poll_targets(nfc_device_t* pnd,
*/ */
bool nfc_initiator_transceive_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar) bool nfc_initiator_transceive_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar)
{ {
pnd->iLastError = 0;
return pn53x_initiator_transceive_bits (pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar); return pn53x_initiator_transceive_bits (pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar);
} }
@ -496,6 +498,8 @@ bool nfc_initiator_transceive_bits(nfc_device_t* pnd, const byte_t* pbtTx, const
*/ */
bool nfc_initiator_transceive_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) bool nfc_initiator_transceive_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{ {
pnd->iLastError = 0;
return pn53x_initiator_transceive_dep_bytes(pnd, pbtTx, szTxLen, pbtRx, pszRxLen); return pn53x_initiator_transceive_dep_bytes(pnd, pbtTx, szTxLen, pbtRx, pszRxLen);
} }
@ -514,6 +518,8 @@ bool nfc_initiator_transceive_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx,
*/ */
bool nfc_initiator_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) bool nfc_initiator_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{ {
pnd->iLastError = 0;
return pn53x_initiator_transceive_bytes (pnd, pbtTx, szTxLen, pbtRx, pszRxLen); return pn53x_initiator_transceive_bytes (pnd, pbtTx, szTxLen, pbtRx, pszRxLen);
} }
@ -527,6 +533,8 @@ bool nfc_initiator_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, cons
*/ */
bool nfc_target_init(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits) bool nfc_target_init(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits)
{ {
pnd->iLastError = 0;
return pn53x_target_init(pnd, pbtRx, pszRxBits); return pn53x_target_init(pnd, pbtRx, pszRxBits);
} }
@ -538,6 +546,8 @@ bool nfc_target_init(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits)
*/ */
bool nfc_target_receive_bits(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar) bool nfc_target_receive_bits(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar)
{ {
pnd->iLastError = 0;
return pn53x_target_receive_bits (pnd, pbtRx, pszRxBits, pbtRxPar); return pn53x_target_receive_bits (pnd, pbtRx, pszRxBits, pbtRxPar);
} }
@ -549,6 +559,8 @@ bool nfc_target_receive_bits(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits
*/ */
bool nfc_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen) bool nfc_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen)
{ {
pnd->iLastError = 0;
return pn53x_target_receive_dep_bytes (pnd, pbtRx, pszRxLen); return pn53x_target_receive_dep_bytes (pnd, pbtRx, pszRxLen);
} }
@ -560,6 +572,8 @@ bool nfc_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszR
*/ */
bool nfc_target_receive_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen) bool nfc_target_receive_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen)
{ {
pnd->iLastError = 0;
return pn53x_target_receive_bytes(pnd, pbtRx, pszRxLen); return pn53x_target_receive_bytes(pnd, pbtRx, pszRxLen);
} }
@ -571,6 +585,8 @@ bool nfc_target_receive_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen
*/ */
bool nfc_target_send_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar) bool nfc_target_send_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar)
{ {
pnd->iLastError = 0;
return pn53x_target_send_bits(pnd, pbtTx, szTxBits, pbtTxPar); return pn53x_target_send_bits(pnd, pbtTx, szTxBits, pbtTxPar);
} }
@ -583,6 +599,8 @@ bool nfc_target_send_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
*/ */
bool nfc_target_send_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen) bool nfc_target_send_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen)
{ {
pnd->iLastError = 0;
return pn53x_target_send_bytes (pnd, pbtTx, szTxLen); return pn53x_target_send_bytes (pnd, pbtTx, szTxLen);
} }
@ -594,6 +612,8 @@ bool nfc_target_send_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t
*/ */
bool nfc_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen) bool nfc_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen)
{ {
pnd->iLastError = 0;
return pn53x_target_send_dep_bytes(pnd, pbtTx, szTxLen); return pn53x_target_send_dep_bytes(pnd, pbtTx, szTxLen);
} }