I want to use a PCAN Router FD as a 1to1-gateway to split a topology with error frames into smaller parts to detect, on which side error frames are produced.
I have used the example "01_ROUTING" as a base and it seems, that I'm not able to receive individual frames with error flags set (to count them) ?
"CAN_Read" will never return a frame with "bufftype == CAN_BUFFER_ERROR_FRAME" (see code below) but the CAN-Controller will switch to BUSOFF and I will get "bufftype == CAN_BUFFER_STATUS" (producing error frames on the desk with very lausy cabling

The only significant change I have made to "can.h", "can_user.h/c" is the addition of the bittimings, that we use in our company ...
Is there something that must be enabled to receive erroneous frames or am I only to stupid to read the examples and do it the right way

Code: Select all
while (1)
{
// process messages from CAN1
// if (CAN_ERR_OK == CAN_UserRead(CAN_BUS1, &tRxBuf1))
if (CAN_ERR_OK == CAN_Read(CAN_BUS1, (CANBuffer_t*) &tRxBuf1))
{
switch (tRxBuf1.bufftype)
{
case CAN_BUFFER_INVALID:
++g_tStatistics[CAN_BUS1].uiErrors;
break;
case CAN_BUFFER_RX_MSG:
++g_tStatistics[CAN_BUS1].uiRxFrames;
if (CAN_ERR_OK == CAN_Write(CAN_BUS2, &tRxBuf1))
{
++g_tStatistics[CAN_BUS2].uiTxFrames;
}
break;
case CAN_BUFFER_ERROR_FRAME:
++g_tStatistics[CAN_BUS1].uiErrFrames;
break;
case CAN_BUFFER_STATUS:
if (((CANBuffer_t*) &tRxBuf1)->status.bus_status)
{
++g_tStatistics[CAN_BUS1].uiErrors;
CAN_ReInit(CAN_BUS1);
}
break;
case CAN_BUFFER_CRITICAL:
++g_tStatistics[CAN_BUS1].uiErrors;
break;
}
}
Stefan