Hi,
following is a small debugging routine embedded in some working sample source code provided by a hardware supplier. I am just going through their sample source code to get a better understanding of how their API works. However, I just can't make sense of how the parameters of DEBUG(x, outp) are being passed to dbg_p (char i, char *fmt, ...). What does "..." in dbg_p (char i, char *fmt, ...) mean?
Would really appreciate if someone can enlighten me.
Thanks in advance.
Code:
/* defines for debugging */
#define DEBUG_OFF 99
#define DEBUG_BASIC 03
#define DEBUG_ADV 02
#define DEBUG_EXP 01
static int can_debug = DEBUG_EXP;
// debug version
#ifdef _DEBUG
#define DEBUG(x, outp) ( dbg_p(x, outp ) )
_inline void dbg_p (char i, char *fmt, ...)
{
char tmp[100];
if (i>=can_debug){
sprintf (tmp, "xlCANcontrol: %s", fmt);
OutputDebugString (tmp);
}
}
// release version.
#else
#define DEBUG(x, outp)
#endif
Following is a portion of the main routine that calls the debugging routine:
Code:
XLstatus CCANFunctions::canGetChannelMask()
{
XLstatus xlStatus = XL_ERROR;
char tmp[100];
// default values
unsigned int hwType = 0;
unsigned int hwIndex = 0;
unsigned int hwChannel = 0;
unsigned int appChannel = 0;
unsigned int busType = XL_BUS_TYPE_CAN;
unsigned int i;
XLdriverConfig xlDrvConfig;
//check for hardware:
xlStatus = xlGetDriverConfig(&xlDrvConfig);
if (xlStatus) return xlStatus;
// we check only if there is an application registered or not.
xlStatus = xlGetApplConfig("xlCANcontrol", CHAN01, &hwType, &hwIndex, &hwChannel, busType);
// Set the params into registry (default values...!)
if (xlStatus) {
DEBUG(DEBUG_ADV,"set in VHWConf");
for (i=0; i < xlDrvConfig.channelCount; i++) {
sprintf (tmp, "hwType: %d, bustype: %d, hwChannel: %d, cap: 0x%x",
xlDrvConfig.channel[i].hwType,
xlDrvConfig.channel[i].connectedBusType,
xlDrvConfig.channel[i].hwChannel,
xlDrvConfig.channel[i].channelBusCapabilities);
DEBUG(DEBUG_ADV,tmp);
// we search not the first CAN cabs
if ( (xlDrvConfig.channel[i].channelBusCapabilities & XL_BUS_ACTIVE_CAP_CAN) && (appChannel < 2) ) {
hwType = xlDrvConfig.channel[i].hwType;
hwIndex = xlDrvConfig.channel[i].hwIndex;
hwChannel = xlDrvConfig.channel[i].hwChannel;
.
.
.