python QOVERRUN

The free CAN Software API (Application Programming Interface) for Windows®
Locked
tuttoaldoc
Posts: 24
Joined: Fri 15. Mar 2019, 14:44

python QOVERRUN

Post by tuttoaldoc » Tue 14. May 2024, 14:57

Hi,
I'm trying to develop a CAN monitoring application in python.
I tried using the provided classes but I have the problem that if the bus is loaded after a while the device goes in read overrun error.

I checked online and I found that python is not very well suited to manage thread priorities.
I tried to manage the problem building a dll in c based on PCANBasic dll: in my dll I create the thread that frees the PCAN device internal queue and copies the data in a larger queue.
Even this solution goes in overrun. I built the c dll as a standalone exe and it runs fine without any problem.
I checked online and as far as I understood launching the dll from python affects the priority and execution of the thread I create so it doens't work.
Do you have any suggestion?
thanks
Michele

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: python QOVERRUN

Post by M.Heidemann » Tue 14. May 2024, 15:21

Hello,

You want to handle messages as soon as they arrive, preferably using the receive-event to
do so, a timer also works. Reading inside a thread doesn't necessarily cause issues if implemented correctly.
Our GUI example uses threading as well for reading (Check Samples/GUI/PYthon), without any
issues. If you don't want to read either A) don't initialize the channel yet or B) set a Filter (PCAN_MESSAGE_FILTER),
that will not accept any messages until necessary, then open the filter to read (PCAN_FILTER_OPEN /PCAN_FILTER_CLOSE).
Otherwise messages will run into queue, regardless if you actively read them or not. So once you are initialized and filters
are open, you will have to read enough to make sure the queue doesn't fill up. Use the PCANStatus of "PCAN_ERROR_QRCVEMPTY"
to ensure all messages in queue are read, wether you work event or timer-based.

If you can give us a short description how you application works we may have some more specific advise for you.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

tuttoaldoc
Posts: 24
Joined: Fri 15. Mar 2019, 14:44

Re: python QOVERRUN

Post by tuttoaldoc » Tue 14. May 2024, 17:22

Hi,
thank you very much. I tested your GUI and effectively it works fine. Mine goes in overrun after a while .. I guess it's maybe linked to some extra-process I do .. I'm investigating.
Thank you very much to point me out your solution
Michele

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: python QOVERRUN

Post by M.Heidemann » Wed 15. May 2024, 08:54

Hi Michele,

Thank you for letting us know!

If you have any questions, fee free to open up a new topic anytime!

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Locked