1 (edited by skgsergio 2016-07-15 11:02:37)

Topic: Change error level or disable error printing in code

Hello,

I'm writing a small code for reading an specific type of application.

The thing is when I'm selecting the application (sending the apdu with nfc_initiator_transceive_bytes) it fails if you use an incorrect type of card.

When there is an error it gets auto-printed by libnfc, for example:

error    libnfc.driver.pn53x_usb    Application level error detected

But I want to do my own error check using nfc_device_get_last_error and only print it if I feel that is needed, removing the libnfc error from the output displayed to the user. Is this possible?


Also I have another problem, when a buffer size error is triggered the nfc_device_get_last_error and the other functions from the error reporting family returns NFC_SUCCESS.

Example using nfc_perror:

error    libnfc.chip.pn53x    Buffer size is too short: 50 available(s), 51 needed
SELECT_APP_APDU: Success

Currently I check the count of bytes returned by nfc_initiator_transceive_bytes and if it is less than 0 I assume there is an error although the errors functions return NFC_SUCCESS... but I find this behavior inconsistent.

Regards,
Sergio.

Re: Change error level or disable error printing in code

I found a dirty hack for disabling the libnfc log printing... add the LIBNFC_LOG_LEVEL to the env from my code, it works but is a very dirty way...

putenv("LIBNFC_LOG_LEVEL=0");