Page 1 of 1

Receive queue was read too late

Posted: Wed 10. May 2023, 13:20
by dualsbiker
Hey,

I am working with PCAN USB adapter and I go crazy. I wrote a script in python3 based on PCANBasic example. I just receive messages of a partners device. When I start the script I receive the messages of the other device and after some seconds I get the error, "Receive queue was read too late".
When I run the receivetest.c in peak driver I do not get errors. It's running perfectly.
I attached the code of my script. I suppose that the error is in the script.
I am using BananaPI M5 with Ubuntu 20. The system is far away on a train and I cannot unplug/plug the adapter.

Re: Receive queue was read too late

Posted: Wed 10. May 2023, 13:30
by M.Maidhof
Hi,

which driver version is used (cat /proc/pcan)? Which PCANBasic API? Please check that you read the queue until you will get a PCAN_ERROR_QRCVEMPTY back.

regards

Michael

Re: Receive queue was read too late

Posted: Wed 10. May 2023, 13:35
by dualsbiker
Hey,

I'm working with linux (Ubuntu 20)

cat /proc/pcan gives the following output:

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20210505_n (8.12.0) May 9 2023 13:48:19 --------------
*---------------------- [mod] [isa] [pci] [pec] [usb] -----------------------
*--------------------- 1 interfaces @ major 498 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32 usb -NA- ffffffff 123 0x0014 000314e6 00000000 0037629c 0034bc6a 0x0002

PCANBasic API is PCAN-Basic_Linux-4.4.2

Re: Receive queue was read too late

Posted: Wed 10. May 2023, 16:50
by F.Vergnaud
Hello,

Your code uses third party module (rospy) that seems to automate calls to PCANBasic read functions.
Keep in mind that we cannot give support on how to use other libraries nor debug a full Python script.

From your main (without knowing how ROSpy really works), I'd say it periodically calls your function "Callback_data_read" every second.
Depending on the CAN bus activity and the value you may have set for the rxqsize driver's parameter (see driver's documentation and /etc/modprobe.d/pcan.conf), this can be a bit slow:
driver receives more frames than your application is able to read, so you get status flags that state that a CAN frame was discarded.

You could increase the polling of your rospy wrapper or instead implement a non-polling reading function with the help of events (see PCANBasic example 08_EventDrivenRead for instance).