Use DEBUG define instead of _LIBNFC_VERBOSE_ to enable debug messages. Add --enable-debug option to ./configure

This commit is contained in:
Romuald Conty 2009-05-27 08:54:50 +00:00
parent 7203015ed9
commit 8b2ca5da1c
4 changed files with 30 additions and 17 deletions

View file

@ -32,6 +32,19 @@ fi
AC_SUBST(LIBPCSCLITE_LIBS)
AC_SUBST(LIBPCSCLITE_CFLAGS)
# --enable-debug support
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Debug flags]),[enable_debug=$enableval],[enable_debug="no"])
AC_MSG_CHECKING(debug)
AC_MSG_RESULT($enable_debug)
if test "x$enable_debug" = "xyes"
then
CFLAGS="$CFLAGS -g -Wall -DDEBUG"
fi
AC_SUBST([DEBUG_CFLAGS])
AC_CONFIG_FILES([
Makefile
src/Makefile

View file

@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _LIBNFC_DEFINES_H_
#define _LIBNFC_DEFINES_H_
// #define _LIBNFC_VERBOSE_
// #define DEBUG
typedef unsigned char byte;
typedef unsigned char ui8;

View file

@ -80,7 +80,7 @@ dev_info* dev_acr122_connect(const ui32 uiIndex)
// Retrieve the string array of all available pcsc readers
if (SCardListReaders(dsa.hCtx,null,acList,(void*)&ulListLen) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Found the following PCSC device(s)\n");
printf("- %s\n",acList);
#endif
@ -105,7 +105,7 @@ dev_info* dev_acr122_connect(const ui32 uiIndex)
uiReaderCount++;
// Debug info
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("- %s\n",acList+uiPos+1);
#endif
}
@ -185,7 +185,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
// Prepare and transmit the send buffer
memcpy(abtTxBuf+5,pbtTx,uiTxLen);
ulRxBufLen = sizeof(abtRxBuf);
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Tx: ");
print_hex(abtTxBuf,uiTxLen+5);
#endif
@ -211,7 +211,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtRxCmd,uiRxCmdLen,null,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false;
}
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Rx: ");
print_hex(abtRxBuf,ulRxBufLen);
#endif
@ -244,7 +244,7 @@ char* dev_acr122_firmware(const dev_spec ds)
uiResult = SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtGetFw,sizeof(abtGetFw),null,(byte*)abtFw,(void*)&ulFwLen);
}
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
if (uiResult != SCARD_S_SUCCESS)
{
printf("No ACR122 firmware received, Error: %08x\n",uiResult);

View file

@ -57,7 +57,7 @@ void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
// Test if we dealing with a bulk IN endpoint
if((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_IN)
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Bulk endpoint in : 0x%02X\n", uiEndPoint);
#endif
pdsp->uiEndPointIn = uiEndPoint;
@ -66,7 +66,7 @@ void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
// Test if we dealing with a bulk OUT endpoint
if((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_OUT)
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Bulk endpoint in : 0x%02X\n", uiEndPoint);
#endif
pdsp->uiEndPointOut = uiEndPoint;
@ -112,7 +112,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
uiDevIndex--;
continue;
}
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Found PN531 device\n");
#endif
@ -122,7 +122,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
get_end_points(dev,&dsp);
if(usb_set_configuration(dsp.pudh,1) < 0)
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Setting config failed\n");
#endif
usb_close(dsp.pudh);
@ -131,7 +131,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
if(usb_claim_interface(dsp.pudh,0) < 0)
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Can't claim interface\n");
#endif
usb_close(dsp.pudh);
@ -188,7 +188,7 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
// End of stream marker
buffer[uiTxLen+6] = 0;
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Tx: ");
print_hex((byte*)buffer,uiTxLen+7);
#endif
@ -196,7 +196,7 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_write(pdsp->pudh, pdsp->uiEndPointOut, buffer, uiTxLen+7, USB_TIMEOUT);
if( ret < 0 )
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("usb_bulk_write failed with error %d\n", ret);
#endif
return false;
@ -205,13 +205,13 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_read(pdsp->pudh, pdsp->uiEndPointIn, buf, BUFFER_LENGTH, USB_TIMEOUT);
if( ret < 0 )
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf( "usb_bulk_read failed with error %d\n", ret);
#endif
return false;
}
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Rx: ");
print_hex((byte*)buf,ret);
#endif
@ -221,13 +221,13 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxL
ret = usb_bulk_read(pdsp->pudh, pdsp->uiEndPointIn, buf, BUFFER_LENGTH, USB_TIMEOUT);
if( ret < 0 )
{
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("usb_bulk_read failed with error %d\n", ret);
#endif
return false;
}
#ifdef _LIBNFC_VERBOSE_
#ifdef DEBUG
printf("Rx: ");
print_hex((byte*)buf,ret);
#endif