Receiving ErrorFrames (frames with error flags)

Universal Programmable Converter for CAN FD and CAN
Post Reply
StZell
Posts: 2
Joined: Mon 25. Sep 2023, 14:21

Receiving ErrorFrames (frames with error flags)

Post by StZell » Mon 25. Sep 2023, 14:53

Hello,

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;
			}
		}

Best regards,
Stefan

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: Receiving ErrorFrames (frames with error flags)

Post by M.Maidhof » Tue 26. Sep 2023, 12:41

Hi,

at the moment the errorframe handling is not directly available in the library of the PCAN-Router FD. But we will check that issue with our developers. In such an application the detection of errorframes in the PCAN-Router makes sense.

regards

Michael

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: Receiving ErrorFrames (frames with error flags)

Post by M.Maidhof » Thu 28. Sep 2023, 12:22

Hi,

good news. Our developers updated the lib to be able to also read error frames with the PCAN-Router FD. If you are interested to get that lib (beta) and an example, please send an email to our support email address with a reference to that forum post.

regards

Michael

StZell
Posts: 2
Joined: Mon 25. Sep 2023, 14:21

Re: Receiving ErrorFrames (frames with error flags)

Post by StZell » Thu 28. Sep 2023, 13:54

Hi Michael,

I would be pleased to test the new lib. The mail to your support-team is out :D

Thank you very much ...

Best regards,
Stefan

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: Receiving ErrorFrames (frames with error flags)

Post by M.Maidhof » Thu 28. Sep 2023, 15:14

Hi Stefan,

we have answered your email. Hope the new lib will do the job.

regards

Michael

Post Reply