Remove a dummy argument in pn53x_transceive().

This commit is contained in:
Romuald Conty 2011-03-02 15:32:52 +00:00
parent 2608b3dc55
commit 7ec1080e16
5 changed files with 27 additions and 28 deletions

View file

@ -88,19 +88,19 @@ main (int argc, const char *argv[])
printf ("NFC device [%s] connected.\n", pnd->acName); printf ("NFC device [%s] connected.\n", pnd->acName);
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx, false); result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx);
if (result) { if (result) {
result = (memcmp (pncmd_diagnose_communication_line_test + 2, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 2) == 0); result = (memcmp (pncmd_diagnose_communication_line_test + 2, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 2) == 0);
} }
printf (" Communication line test: %s\n", result ? "OK" : "Failed"); printf (" Communication line test: %s\n", result ? "OK" : "Failed");
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx, false); result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx);
if (result) { if (result) {
result = ((szRx == 1) && (abtRx[0] == 0x00)); result = ((szRx == 1) && (abtRx[0] == 0x00));
} }
printf (" ROM test: %s\n", result ? "OK" : "Failed"); printf (" ROM test: %s\n", result ? "OK" : "Failed");
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx, false); result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx);
if (result) { if (result) {
result = ((szRx == 1) && (abtRx[0] == 0x00)); result = ((szRx == 1) && (abtRx[0] == 0x00));
} }

View file

@ -93,7 +93,7 @@ sam_connection (nfc_device_t * pnd, int mode)
break; break;
} }
if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRx, false)) { if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRx)) {
nfc_perror(pnd, "pn53x_transceive"); nfc_perror(pnd, "pn53x_transceive");
ERR ("%s %d", "Unable to execute SAMConfiguration command with mode byte:", mode); ERR ("%s %d", "Unable to execute SAMConfiguration command with mode byte:", mode);
return false; return false;

View file

@ -167,7 +167,7 @@ int main(int argc, const char* argv[])
printf("Tx: "); printf("Tx: ");
print_hex((byte_t*)abtTx+1,szTx-1); print_hex((byte_t*)abtTx+1,szTx-1);
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx, false)) { if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx)) {
free(cmd); free(cmd);
nfc_perror (pnd, "Rx"); nfc_perror (pnd, "Rx");
continue; continue;

View file

@ -130,9 +130,8 @@ pn53x_check_error_frame_callback (nfc_device_t * pnd, const byte_t * pbtRxFrame,
} }
bool bool
pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, bool toto) pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx)
{ {
(void) toto;
PNCMD_DBG (pbtTx[0]); PNCMD_DBG (pbtTx[0]);
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
@ -191,7 +190,7 @@ pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value)
byte_t abtRegValue[2]; byte_t abtRegValue[2];
size_t szRegValue = sizeof (abtRegValue); size_t szRegValue = sizeof (abtRegValue);
if (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRegValue, &szRegValue, true)) { if (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRegValue, &szRegValue)) {
if (((struct pn53x_data*)(pnd->chip_data))->type == PN533) { if (((struct pn53x_data*)(pnd->chip_data))->type == PN533) {
// PN533 prepends its answer by a status byte // PN533 prepends its answer by a status byte
if (abtRegValue[0] == 0x00) { if (abtRegValue[0] == 0x00) {
@ -217,10 +216,10 @@ pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16Reg, const uint8_t
if (!pn53x_read_register (pnd, ui16Reg, &ui8Current)) if (!pn53x_read_register (pnd, ui16Reg, &ui8Current))
return false; return false;
abtCmd[3] = ui8Value | (ui8Current & (~ui8SymbolMask)); abtCmd[3] = ui8Value | (ui8Current & (~ui8SymbolMask));
return (abtCmd[3] != ui8Current) ? pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false) : true; return (abtCmd[3] != ui8Current) ? pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL) : true;
} else { } else {
abtCmd[3] = ui8Value; abtCmd[3] = ui8Value;
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false); return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL);
} }
} }
@ -239,7 +238,7 @@ pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
{ {
byte_t abtCmd[] = { SetParameters, ui8Value }; byte_t abtCmd[] = { SetParameters, ui8Value };
if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false)) { if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL)) {
return false; return false;
} }
// We save last parameters in register cache // We save last parameters in register cache
@ -593,7 +592,7 @@ pn53x_InListPassiveTarget (nfc_device_t * pnd,
if (pbtInitiatorData) if (pbtInitiatorData)
memcpy (abtCmd + 3, pbtInitiatorData, szInitiatorData); memcpy (abtCmd + 3, pbtInitiatorData, szInitiatorData);
return pn53x_transceive (pnd, abtCmd, 3 + szInitiatorData, pbtTargetsData, pszTargetsData, false); return pn53x_transceive (pnd, abtCmd, 3 + szInitiatorData, pbtTargetsData, pszTargetsData);
} }
bool bool
@ -601,7 +600,7 @@ pn53x_InDeselect (nfc_device_t * pnd, const uint8_t ui8Target)
{ {
byte_t abtCmd[] = { InDeselect, ui8Target }; byte_t abtCmd[] = { InDeselect, ui8Target };
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false)); return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
} }
bool bool
@ -622,7 +621,7 @@ pn53x_SAMConfiguration (nfc_device_t * pnd, const uint8_t ui8Mode)
pnd->iLastError = DENOTSUP; pnd->iLastError = DENOTSUP;
return false; return false;
} }
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false)); return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
} }
bool bool
@ -630,7 +629,7 @@ pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target)
{ {
byte_t abtCmd[] = { InRelease, ui8Target }; byte_t abtCmd[] = { InRelease, ui8Target };
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false)); return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL));
} }
bool bool
@ -653,7 +652,7 @@ pn53x_InAutoPoll (nfc_device_t * pnd,
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
bool res = pn53x_transceive (pnd, abtCmd, szTxInAutoPoll, abtRx, &szRx, false); bool res = pn53x_transceive (pnd, abtCmd, szTxInAutoPoll, abtRx, &szRx);
if ((szRx == 0) || (res == false)) { if ((szRx == 0) || (res == false)) {
return false; return false;
@ -760,7 +759,7 @@ pn53x_get_firmware_version (nfc_device_t * pnd, char abtFirmwareText[18])
const byte_t abtCmd[] = { GetFirmwareVersion }; const byte_t abtCmd[] = { GetFirmwareVersion };
byte_t abtFw[4]; byte_t abtFw[4];
size_t szFwLen = sizeof (abtFw); size_t szFwLen = sizeof (abtFw);
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen, false)) { if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen)) {
// Failed to get firmware revision??, whatever...let's disconnect and clean up and return err // Failed to get firmware revision??, whatever...let's disconnect and clean up and return err
// FIXME: Wtf? // FIXME: Wtf?
return false; return false;
@ -831,7 +830,7 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
case NDO_ACTIVATE_FIELD: case NDO_ACTIVATE_FIELD:
{ {
byte_t abtCmd[] = { RFConfiguration, RFCI_FIELD, (bEnable) ? 0x01 : 0x00 }; byte_t abtCmd[] = { RFConfiguration, RFCI_FIELD, (bEnable) ? 0x01 : 0x00 };
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false)) if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL))
return false; return false;
} }
break; break;
@ -856,7 +855,7 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
(bEnable) ? 0xff : 0x00, // MxRtyPSL, default: 0x01 (bEnable) ? 0xff : 0x00, // MxRtyPSL, default: 0x01
(bEnable) ? 0xff : 0x00 // MxRtyPassiveActivation, default: 0xff (bEnable) ? 0xff : 0x00 // MxRtyPassiveActivation, default: 0xff
}; };
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, false)) if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL))
return false; return false;
} }
break; break;
@ -1006,7 +1005,7 @@ pn53x_InJumpForDEP (nfc_device_t * pnd,
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx); size_t szRx = sizeof (abtRx);
// Try to find a target, call the transceive callback function of the current device // Try to find a target, call the transceive callback function of the current device
if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, false)) if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx))
return false; return false;
// Make sure one target has been found, the PN53X returns 0x00 if none was available // Make sure one target has been found, the PN53X returns 0x00 if none was available
@ -1069,7 +1068,7 @@ pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const
// We have to give the amount of bytes + (the command byte 0x42) // We have to give the amount of bytes + (the command byte 0x42)
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, abtRx, &szRx, false)) if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, abtRx, &szRx))
return false; return false;
// Get the last bit-count that is stored in the received byte // Get the last bit-count that is stored in the received byte
@ -1127,7 +1126,7 @@ pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, cons
// We have to give the amount of bytes + (the two command bytes 0xD4, 0x42) // We have to give the amount of bytes + (the two command bytes 0xD4, 0x42)
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx); size_t szRx = sizeof(abtRx);
if (!pn53x_transceive (pnd, abtCmd, szTx + szExtraTxLen, abtRx, &szRx, false)) if (!pn53x_transceive (pnd, abtCmd, szTx + szExtraTxLen, abtRx, &szRx))
return false; return false;
// Save the received byte count // Save the received byte count
@ -1370,7 +1369,7 @@ pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm,
// Request the initialization as a target // Request the initialization as a target
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx); size_t szRx = sizeof (abtRx);
if (!pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx, false)) if (!pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx))
return false; return false;
// Note: the first byte is skip: // Note: the first byte is skip:
@ -1395,7 +1394,7 @@ pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBit
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx); size_t szRx = sizeof (abtRx);
// Try to gather a received frame from the reader // Try to gather a received frame from the reader
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, false)) if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx))
return false; return false;
// Get the last bit-count that is stored in the received byte // Get the last bit-count that is stored in the received byte
@ -1436,7 +1435,7 @@ pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx)
// Try to gather a received frame from the reader // Try to gather a received frame from the reader
byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; byte_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx); size_t szRx = sizeof (abtRx);
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, false)) if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx))
return false; return false;
// Save the received byte count // Save the received byte count
@ -1480,7 +1479,7 @@ pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t s
return false; return false;
// Try to send the bits to the reader // Try to send the bits to the reader
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, NULL, NULL, false)) if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, NULL, NULL))
return false; return false;
// Everyting seems ok, return true // Everyting seems ok, return true
@ -1506,7 +1505,7 @@ pn53x_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t
memcpy (abtCmd + 1, pbtTx, szTx); memcpy (abtCmd + 1, pbtTx, szTx);
// Try to send the bits to the reader // Try to send the bits to the reader
if (!pn53x_transceive (pnd, abtCmd, szTx + 1, NULL, NULL, false)) if (!pn53x_transceive (pnd, abtCmd, szTx + 1, NULL, NULL))
return false; return false;
// Everyting seems ok, return true // Everyting seems ok, return true

View file

@ -200,7 +200,7 @@ bool pn53x_check_ack_frame_callback (nfc_device_t * pnd, const byte_t * pbtRx
const size_t szRxFrameLen); const size_t szRxFrameLen);
bool pn53x_check_error_frame_callback (nfc_device_t * pnd, const byte_t * pbtRxFrame, bool pn53x_check_error_frame_callback (nfc_device_t * pnd, const byte_t * pbtRxFrame,
const size_t szRxFrameLen); const size_t szRxFrameLen);
bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx, bool toto); bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx);
bool pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value); bool pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value);
bool pn53x_write_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value); bool pn53x_write_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
bool pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Value, const bool bEnable); bool pn53x_set_parameters (nfc_device_t * pnd, const uint8_t ui8Value, const bool bEnable);