This example shows how to open a channel in CAN and CAN FD mode. See Open Channel for more information.
------------------------------------------------------------------------------
#include <stdio.h>
static void check(
const char*
id,
canStatus stat)
{
char buf[50];
buf[0] = '\0';
printf("%s: failed, stat=%d (%s)\n", id, (int)stat, buf);
}
}
canHandle open_channel_as_can(
int channel_number)
{
if (hnd < 0) {
return hnd;
}
check("canSetBusParams", stat);
return hnd;
}
canHandle open_channel_as_canfd(
int channel_number)
{
if (hnd < 0) {
return hnd;
}
check("canSetBusParams", stat);
check("canSetBusParamsFD", stat);
return hnd;
}