#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <windows.h>
#include <conio.h>
#ifdef __BORLANDC__
#pragma argsused
#endif
char CANCHANNEL_OPMODE_TEXT[5][20] = {"Unknown","None","Infrastructure","Reserved","AdHoc"};
void Usage(int argc, char* argv[])
{
printf("\nCANLIB Channel Enumeration & Data\n");
printf("\nA Part of the CANLIB SDK - see www.kvaser.com for more info.\n");
printf("\n");
printf("\nUsage: channeldata \n");
exit(1);
}
{
if (stat != canOK) {
char buf[50];
buf[0] = '\0';
printf("%s: failed, stat=%d (%s)\n", id, (int)stat, buf);
}
}
void main(int argc, char* argv[])
{
int i, chanCount;
printf("Starting...\n");
Check("canGetNumberOfChannels", stat);
if (chanCount<0 || chanCount > 1000) {
printf("ChannelCount = %d but I don't believe it.\n", chanCount);
exit(1);
} else {
printf("%d channels.\n", chanCount);
}
for (i=0; i<chanCount; i++) {
DWORD tmp;
DWORD quad[2];
DWORD64 quad64[2];
char name[64];
unsigned long ean[2];
DWORD flags;
DWORD drivertype;
char cust_channel_name[64];
printf("== Channel %d ===============================\n", i);
Check("canGetChannelData", stat);
Check("canGetChannelData", stat);
printf("Channel Capabilities Ex = 0x%I64x ", quad64[0]);
printf("Channel Capabilities = 0x%08lx ", tmp);
if (tmp & canCHANNEL_CAP_CAN_FD) printf("Fd ");
if (quad64[0] & canCHANNEL_CAP_EX_BUSPARAMS_TQ) printf ("BusParamsTQ ");
printf("\n");
Check("canGetChannelData", stat);
printf("DRVcan Capabilities = 0x%08lx ", tmp);
printf("\n");
Check("canGetChannelData", stat);
printf("Channel Flags = 0x%08lx ", tmp);
printf("\n");
if (tmp & canCHANNEL_IS_CANFD)
else
Check("canReadStatus", stat);
printf("Channel Status Flags = 0x%08lx ", flags);
printf("\n");
Check("canGetBusOutputControl", stat);
printf("Drivertype = 0x%08lx ", drivertype);
printf("Silent ");
else
printf("Normal ");
printf("\n");
Check("canCHANNELDATA_BUS_TYPE", stat);
printf("Bustype = 0x%08lx\n", tmp);
Check("canCHANNELDATA_CARD_NUMBER", stat);
printf("Board Number = 0x%08lx\n", tmp);
Check("canCHANNELDATA_CHAN_NO_ON_CARD", stat);
printf("Channel no on board = 0x%08lx\n", tmp);
Check("canCHANNELDATA_CARD_SERIAL_NO", stat);
printf("Board S/N = 0x%08lx 0x%08lx\n", quad[0], quad[1]);
Check("canCHANNELDATA_TRANS_SERIAL_NO", stat);
printf("DRVcan S/N = 0x%08lx 0x%08lx\n", quad[0], quad[1]);
Check("canCHANNELDATA_CARD_FIRMWARE_REV", stat);
printf("Board F/W version = 0x%08lx 0x%08lx\n", quad[0], quad[1]);
Check("canCHANNELDATA_CARD_HARDWARE_REV", stat);
printf("Board H/W version = 0x%08lx 0x%08lx\n", quad[0], quad[1]);
Check("canCHANNELDATA_CARD_UPC_NO", stat);
printf("Board UPC/EAN = 0x%08lx 0x%08lx\n", ean[1], ean[0]);
Check("canCHANNELDATA_TRANS_UPC_NO", stat);
printf("DRVcan UPC/EAN = 0x%08lx 0x%08lx\n", ean[1], ean[0]);
Check("canCHANNELDATA_CHANNEL_NAME", stat);
printf("Channel name = '%s'\n", name);
sizeof(cust_channel_name));
if (stat == canOK) {
printf("Cust. Channel name = '%s'\n", cust_channel_name);
}
Check("canCHANNELDATA_REMOTE_OPERATIONAL_MODE", stat);
printf("Operational mode = %lu (%s)\n", tmp, CANCHANNEL_OPMODE_TEXT[tmp]);
Check("canCHANNELDATA_REMOTE_PROFILE_NAME", stat);
printf("Profile name = '%s'\n", name);
Check("canCHANNELDATA_REMOTE_HOST_NAME", stat);
printf("Remote host name = '%s'\n", name);
Check("canCHANNELDATA_REMOTE_MAC", stat);
printf("MAC = '%s'\n", name);
} else {
printf("Device is not capable of acting in remote operational mode\n");
}
printf("\n");
}
}