For the sake of consistency, rename all szRxLen to szRx and szTxLen to szTx

This commit is contained in:
Romuald Conty 2010-10-12 14:56:42 +00:00
parent 5d753827c1
commit c34be50ef1
22 changed files with 195 additions and 195 deletions

View file

@ -21,7 +21,7 @@ bool
nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp)
{
byte_t abtRx[265];
size_t szRxLen;
size_t szRx;
size_t szParamLen;
byte_t abtCmd[265];
@ -68,14 +68,14 @@ nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t
memcpy (abtCmd + 2, (byte_t *) pmp, szParamLen);
// Fire the mifare command
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRxLen)) {
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx)) {
if (pnd->iLastError != 0x14)
nfc_perror (pnd, "nfc_initiator_transceive_bytes");
return false;
}
// When we have executed a read command, copy the received bytes into the param
if (mc == MC_READ) {
if (szRxLen == 16) {
if (szRx == 16) {
memcpy (pmp->mpd.abtData, abtRx, 16);
} else {
return false;

View file

@ -44,7 +44,7 @@
static byte_t abtRx[MAX_FRAME_LEN];
static size_t szRxBits;
static size_t szRxLen;
static size_t szRx;
static byte_t abtUid[10];
static size_t szUidLen = 4;
static nfc_device_t *pnd;
@ -81,21 +81,21 @@ transmit_bits (const byte_t * pbtTx, const size_t szTxBits)
static bool
transmit_bytes (const byte_t * pbtTx, const size_t szTxLen)
transmit_bytes (const byte_t * pbtTx, const size_t szTx)
{
// Show transmitted command
if (!quiet_output) {
printf ("Sent bits: ");
print_hex (pbtTx, szTxLen);
print_hex (pbtTx, szTx);
}
// Transmit the command bytes
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTxLen, abtRx, &szRxLen))
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx))
return false;
// Show received answer
if (!quiet_output) {
printf ("Received bits: ");
print_hex (abtRx, szRxLen);
print_hex (abtRx, szRx);
}
// Succesful transfer
return true;

View file

@ -58,22 +58,22 @@
#define MAX_FRAME_LEN 264
static byte_t abtRx[MAX_FRAME_LEN];
static size_t szRxLen;
static size_t szRx;
static nfc_device_t *pnd;
static bool quiet_output = false;
#define SYMBOL_PARAM_fISO14443_4_PICC 0x20
bool send_bytes (const byte_t * pbtTx, const size_t szTxLen)
bool send_bytes (const byte_t * pbtTx, const size_t szTx)
{
// Show transmitted command
if (!quiet_output) {
printf ("Sent data: ");
print_hex (pbtTx, szTxLen);
print_hex (pbtTx, szTx);
}
// Transmit the command bytes
if (!nfc_target_send_bytes(pnd, pbtTx, szTxLen)) {
if (!nfc_target_send_bytes(pnd, pbtTx, szTx)) {
nfc_perror (pnd, "nfc_target_send_bytes");
exit(EXIT_FAILURE);
}
@ -83,7 +83,7 @@ bool send_bytes (const byte_t * pbtTx, const size_t szTxLen)
bool receive_bytes (void)
{
if (!nfc_target_receive_bytes(pnd,abtRx,&szRxLen)) {
if (!nfc_target_receive_bytes(pnd,abtRx,&szRx)) {
nfc_perror (pnd, "nfc_target_receive_bytes");
exit(EXIT_FAILURE);
}
@ -91,7 +91,7 @@ bool receive_bytes (void)
// Show received answer
if (!quiet_output) {
printf ("Received data: ");
print_hex (abtRx, szRxLen);
print_hex (abtRx, szRx);
}
// Succesful transfer
return true;
@ -120,7 +120,7 @@ main (int argc, char *argv[])
.nti.nai.szAtsLen = 0,
};
if (!nfc_target_init (pnd, NTM_ISO14443_4_PICC, nt, abtRx, &szRxLen)) {
if (!nfc_target_init (pnd, NTM_ISO14443_4_PICC, nt, abtRx, &szRx)) {
nfc_perror (pnd, "nfc_target_init");
ERR("Could not come out of auto-emulation, no command was received");
return EXIT_FAILURE;
@ -128,7 +128,7 @@ main (int argc, char *argv[])
if (!quiet_output) {
printf ("Received data: ");
print_hex (abtRx, szRxLen);
print_hex (abtRx, szRx);
}
//Receiving data: e0 40

View file

@ -44,7 +44,7 @@
#define MAX_FRAME_LEN 264
static byte_t abtRx[MAX_FRAME_LEN];
static size_t szRxLen;
static size_t szRx;
static nfc_device_t *pnd;
static bool quiet_output = false;
static bool init_mfc_auth = false;
@ -107,13 +107,13 @@ nfc_target_emulate_tag(nfc_device_t* pnd, const nfc_target_t nt)
byte_t abtTx[MAX_FRAME_LEN];
bool loop = true;
if (!nfc_target_init (pnd, NTM_PASSIVE, nt, abtRx, &szRxLen)) {
if (!nfc_target_init (pnd, NTM_PASSIVE, nt, abtRx, &szRx)) {
nfc_perror (pnd, "nfc_target_init");
return false;
}
while ( loop ) {
loop = target_io( nt, abtRx, szRxLen, abtTx, &szTx );
loop = target_io( nt, abtRx, szRx, abtTx, &szTx );
if (szTx) {
if (!nfc_target_send_bytes(pnd, abtTx, szTx)) {
nfc_perror (pnd, "nfc_target_send_bytes");
@ -125,7 +125,7 @@ nfc_target_emulate_tag(nfc_device_t* pnd, const nfc_target_t nt)
nfc_configure (pnd, NDO_HANDLE_CRC, false);
init_mfc_auth = false;
}
if (!nfc_target_receive_bytes(pnd, abtRx, &szRxLen)) {
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx)) {
nfc_perror (pnd, "nfc_target_receive_bytes");
return false;
}

View file

@ -45,7 +45,7 @@ main (int argc, const char *argv[])
bool result;
byte_t abtRx[MAX_FRAME_LEN];
size_t szRxLen;
size_t szRx;
const byte_t pncmd_diagnose_communication_line_test[] = { 0xD4, 0x00, 0x00, 0x06, 'l', 'i', 'b', 'n', 'f', 'c' };
const byte_t pncmd_diagnose_rom_test[] = { 0xD4, 0x00, 0x01 };
const byte_t pncmd_diagnose_ram_test[] = { 0xD4, 0x00, 0x02 };
@ -78,21 +78,21 @@ main (int argc, const char *argv[])
printf ("NFC device [%s] connected.\n", pnd->acName);
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRxLen);
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx);
if (result) {
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");
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRxLen);
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx);
if (result) {
result = ((szRxLen == 1) && (abtRx[0] == 0x00));
result = ((szRx == 1) && (abtRx[0] == 0x00));
}
printf (" ROM test: %s\n", result ? "OK" : "Failed");
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRxLen);
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx);
if (result) {
result = ((szRxLen == 1) && (abtRx[0] == 0x00));
result = ((szRx == 1) && (abtRx[0] == 0x00));
}
printf (" RAM test: %s\n", result ? "OK" : "Failed");
}

View file

@ -63,7 +63,7 @@ sam_connection (nfc_device_t * pnd, int mode)
size_t szCmd = 0;
byte_t abtRx[MAX_FRAME_LEN];
size_t szRxLen;
size_t szRx;
pncmd_sam_config[2] = mode;
@ -82,7 +82,7 @@ sam_connection (nfc_device_t * pnd, int mode)
break;
}
if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRxLen)) {
if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRx)) {
nfc_perror(pnd, "pn53x_transceive");
ERR ("%s %d", "Unable to execute SAMConfiguration command with mode byte:", mode);
return false;
@ -195,7 +195,7 @@ main (int argc, const char *argv[])
case DUAL_CARD_MODE:
{
byte_t abtRx[MAX_FRAME_LEN];
size_t szRxLen;
size_t szRx;
nfc_target_t nt = {
.ntt = NTT_MIFARE,
@ -207,7 +207,7 @@ main (int argc, const char *argv[])
};
printf ("Now both, NFC device (configured as target) and SAM are readables from an external NFC initiator.\n");
printf ("Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
if (!nfc_target_init (pnd, NTM_NORMAL, nt, abtRx, &szRxLen)) {
if (!nfc_target_init (pnd, NTM_NORMAL, nt, abtRx, &szRx)) {
nfc_perror(pnd, "nfc_target_init");
return EXIT_FAILURE;
}

View file

@ -51,8 +51,8 @@ int main(int argc, const char* argv[])
nfc_device_t* pnd;
byte_t abtRx[MAX_FRAME_LEN];
byte_t abtTx[MAX_FRAME_LEN] = { 0xD4 };
size_t szRxLen;
size_t szTxLen;
size_t szRx;
size_t szTx;
// Try to open the NFC reader
pnd = nfc_connect(NULL);
@ -98,7 +98,7 @@ int main(int argc, const char* argv[])
free(cmd);
break;
}
szTxLen = 0;
szTx = 0;
for(int i = 0; i<MAX_FRAME_LEN-10; i++) {
int size;
byte_t byte;
@ -110,29 +110,29 @@ int main(int argc, const char* argv[])
break;
}
abtTx[i+1] = byte;
szTxLen++;
szTx++;
if (cmd[offset+1] == 0) { // if last hex was only 1 symbol
break;
}
offset += 2;
}
if ((int)szTxLen < 1) {
if ((int)szTx < 1) {
free(cmd);
continue;
}
szTxLen++;
szTx++;
printf("Tx: ");
print_hex((byte_t*)abtTx+1,szTxLen-1);
print_hex((byte_t*)abtTx+1,szTx-1);
if (!pn53x_transceive (pnd, abtTx, szTxLen, abtRx, &szRxLen)) {
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx)) {
free(cmd);
nfc_perror (pnd, "Rx");
continue;
}
printf("Rx: ");
print_hex(abtRx, szRxLen);
print_hex(abtRx, szRx);
free(cmd);
}