Receive queue was read too late

USB to CAN Interface
Post Reply
dualsbiker
Posts: 4
Joined: Fri 13. May 2022, 07:41

Receive queue was read too late

Post by dualsbiker » Wed 10. May 2023, 13:20

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.
Attachments
code.zip
(11.52 KiB) Downloaded 574 times

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

Re: Receive queue was read too late

Post by M.Maidhof » Wed 10. May 2023, 13:30

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

dualsbiker
Posts: 4
Joined: Fri 13. May 2022, 07:41

Re: Receive queue was read too late

Post by dualsbiker » Wed 10. May 2023, 13:35

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

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Receive queue was read too late

Post by F.Vergnaud » Wed 10. May 2023, 16:50

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).
Best regards,
Fabrice

Post Reply