Problem reading and writing register to a pn532 with an arduino board

162 views
Skip to first unread message

Pascal Marois

unread,
Jul 26, 2016, 8:37:02 AM7/26/16
to nfc-tools developers group
I've coded this part to read xram register of pn532 with libnfc 1.7.1

case 0x06: { //ReadRegister Page 76 
int address;
uint8_t value;
int j = 0;
for (int i = 0; i <= 10; i += 2) {

memcpy(&address, (int*) abtRxBuf + 7 + i, 2);

pn532_packetbuffer[0/*1*/] = address >> 8;
pn532_packetbuffer[1/*2*/] = address & 0xff;

Wire.write(pn532_packetbuffer, 2);

// read data packet
Wire.requestFrom(PN532_I2C_ADDRESS, 0x05);

j = 0;
while (Wire.available() && j < 6) {
answerSamConfig[j]/*value*/= Wire.read(); //pn532_packetbuffer[0];
//answerSamConfig[j] = value;
//Wire.write(value); Serial.write(value);
j++;
}
}
Wire.write(answerSamConfig, 5);
Serial.write(answerSamConfig, 5);

uint8_t dataSum = btDCS - sum_array(answerSamConfig, 5); //0x24;
writePostStuff(dataSum);
//        writeCommand(answerSamConfig, sizeof(answerSamConfig));
break;
}


I got this bad answer.


debug   libnfc.chip.pn53x       ReadRegister
debug   libnfc.bus.uart_win32   TX: 00 00 ff 06 fa d4 06 63 1e 63 1f 23 00
debug   libnfc.driver.pn532_uart        Read ACK
debug   libnfc.bus.uart_win32   Timeouts are set to 350 ms
debug   libnfc.bus.uart_win32   ReadFile
debug   libnfc.bus.uart_win32   RX: 00 00 ff 00 ff 00
debug   libnfc.chip.pn53x       PN53x ACKed
debug   libnfc.bus.uart_win32   Timeouts are set to 350 ms
debug   libnfc.bus.uart_win32   ReadFile
debug   libnfc.bus.uart_win32   RX: 00 00 ff 07 f9
debug   libnfc.driver.pn532_uart        Frame preamble+start code
debug   libnfc.driver.pn532_uart        Check Checksum Normal Frame, 07, f9
debug   libnfc.driver.pn532_uart        Get len from abtRxBf[3] - 2, 05
debug   libnfc.driver.pn532_uart        TFI + PD0 (CC+1)
debug   libnfc.bus.uart_win32   Timeouts are set to 350 ms
debug   libnfc.bus.uart_win32   ReadFile
debug   libnfc.bus.uart_win32   RX: d5 07
debug   libnfc.driver.pn532_uart        Check TFI d5
debug   libnfc.driver.pn532_uart        Check Command  07
debug   libnfc.driver.pn532_uart        Get len 05
debug   libnfc.bus.uart_win32   Timeouts are set to 350 ms
debug   libnfc.bus.uart_win32   ReadFile
debug   libnfc.bus.uart_win32   RX: 00 80 80 80 80
debug   libnfc.driver.pn532_uart        Wait 2 more bytes
debug   libnfc.bus.uart_win32   Timeouts are set to 350 ms
debug   libnfc.bus.uart_win32   ReadFile
debug   libnfc.bus.uart_win32   RX: 24 00
debug   libnfc.driver.pn532_uart        Check btDCS  24
debug   libnfc.driver.pn532_uart        Check Postamble  00
Received bits:

Found tag with
 UID: 00000000
ATQA: 0000
 SAK: 00

My question is : how to access pn532 register with an arduino ?
Many other command are working well in my code, this part is critical
Thank you
Reply all
Reply to author
Forward
0 new messages