Hi,
I'm testing my program using two CAN PEAK adapters connected to each other with termination resistance on both ends. I'm trying to write frames on one adapter and read them on the other one. Unfortunately, the CAN_Write function always returns an error. The error is usually 22 (which if I understand correctly means OVERRUN BUSLIGHT BUSOFF), or sometimes the error is 74 (OVERRUN BUSHEAVY QOVERRUN).
I installed the peak-linux-driver-8.16.0 and am using the associated libpcan.
I can successfully write frames with pcapview and read the reception on the other adapter on my program using LINUX_CAN_Read_Timeout.
I tested Ubuntu 22.04, 20.04 and 18.04 (VMs).
What could be the cause of those errors?
Thanks!
Regards,
Maxime
PCAN CAN_Write error 22 (OVERRUN BUSLIGHT BUSOFF)
Re: PCAN CAN_Write error 22 (OVERRUN BUSLIGHT BUSOFF)
Hi Maxime,
is this a hex or dec return value from CAN_Write? Can you please post your code here, to see what your application is doing?
regards
Michael
is this a hex or dec return value from CAN_Write? Can you please post your code here, to see what your application is doing?
regards
Michael
Re: PCAN CAN_Write error 22 (OVERRUN BUSLIGHT BUSOFF)
This a dec return value from CAN_Write. I ended up finding my issue on that: the length of the message was wrong. The conversion from our CAN frame struct to TPCANMsg was buggy.
Now I have a different issue. When reading frames (with LINUX_CAN_Read_Timeout), I always get the same first frame that was sent, over and over with an updated timestamp. But that frame was only sent once and the other frames cannot be read.
I noticed if I open the adapter with pcanview before starting my program, the frames are read correctly (and if I open pcanview after my program I have the same issue in pcanview). I guess I'm doing something wrong with the initialization, but I'm not sure what.
Here's a pseudocode of my reader:
And my writer:
I can't share the full code but if needed I can make a minimal example to reproduce this.
Is there an acknowledge process that I missed? I'm still a beginner with CAN.
Thanks a lot for your support!
Best regards,
Now I have a different issue. When reading frames (with LINUX_CAN_Read_Timeout), I always get the same first frame that was sent, over and over with an updated timestamp. But that frame was only sent once and the other frames cannot be read.
I noticed if I open the adapter with pcanview before starting my program, the frames are read correctly (and if I open pcanview after my program I have the same issue in pcanview). I guess I'm doing something wrong with the initialization, but I'm not sure what.
Here's a pseudocode of my reader:
Code: Select all
hHandle = LINUX_CAN_Open("/dev/pcan32",0);
CAN_Init(hHandle, CAN_BAUD_100K, MSGTYPE_STANDARD);
TPCANRdMsg myMsgRx;
while (running)
{
DWORD res = LINUX_CAN_Read_Timeout(hHandle, &myMsgRx, m_timeout);
// Either res == CAN_ERR_QRCVEMPTY or the same frame is read (~66 times per second, as I send 1 random frame per second)
}
Code: Select all
hHandle = LINUX_CAN_Open("/dev/pcan33",0);
CAN_Init(hHandle, CAN_BAUD_100K, MSGTYPE_STANDARD);
while (running)
{
TPCANMsg msg = GetRandomFrameToSend();
ret = CAN_Write(hHandle,&msg);
// It seems to work
}
Is there an acknowledge process that I missed? I'm still a beginner with CAN.
Thanks a lot for your support!
Best regards,
Re: PCAN CAN_Write error 22 (OVERRUN BUSLIGHT BUSOFF)
Well, forget what I posted. Turns out we tweaked CAN_Init to enable listen_only mode on the reader. That seems to cause our issue, when disabling it reading works properly. As I read on another thread, listen_only mode disables acknowledgements so that explains our issue...
Sorry to have bothered you.
Thanks!
Sorry to have bothered you.
Thanks!
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: PCAN CAN_Write error 22 (OVERRUN BUSLIGHT BUSOFF)
Yes, that is exact the answer.
Sending a CAN Frame on a CAN Bus where no other activ node is connected, ends up that the sending CAN Controller repeat endless this single CAN message.
If you are connected in LO (Listen Only Mode) which do not ACK, you read the same CAN Frame from the other node in loops...endless...
Sending a CAN Frame on a CAN Bus where no other activ node is connected, ends up that the sending CAN Controller repeat endless this single CAN message.
If you are connected in LO (Listen Only Mode) which do not ACK, you read the same CAN Frame from the other node in loops...endless...
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------