Hi.
I'm wondering if you have any good advice to me.
I'm writing a program for a Linux-computer which should read data from 12 USB-CAN channels (2x PCAN-USB FDx6).
I'm ready with my code and it works perfect.
BUT,, I have coded using threads in C .
That has resulted in 100% loaded CPU-cores (all six of them.)
Is there a better way to catch data from several can-busses?
Next for me is to test with separate processes. Not sure if it helps.
But I guess somebody out there has got it working.
The Select command sit there and waits for data.Is there a memory queue in the drivers?
Or is it possible to check several channels within on select command? Probably not since it require a handle.
/Terje.
Multi-CAN interface
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: Multi-CAN interface
Hello Terje,
What does Linux-computer mean in your case?
Can you give us some hardware-specs to see if you might some ceiling in terms of whats possible?
Furthermore, which API are you using?
Best Regards
Marvin
What does Linux-computer mean in your case?
Can you give us some hardware-specs to see if you might some ceiling in terms of whats possible?
Furthermore, which API are you using?
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: Multi-CAN interface
Linux can driver 8.10.2 64-Bit.
PEAK Basic API 4.4.0 .
Ubuntu 20.04.1 LTS 64-Bit
The computer is an Intel i5. with 6 cores.
8MB of memory. 480GB MM2 drive.
Two PCAN-USB x 6 IPEH-004064.
Is there any input cache in the PCAN-USBx6 Device?
Does the drivers have any cache? or queue?
/Terje.
PEAK Basic API 4.4.0 .
Ubuntu 20.04.1 LTS 64-Bit
The computer is an Intel i5. with 6 cores.
8MB of memory. 480GB MM2 drive.
Two PCAN-USB x 6 IPEH-004064.
Is there any input cache in the PCAN-USBx6 Device?
Does the drivers have any cache? or queue?
/Terje.
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: Multi-CAN interface
Hello Terje,
Thank you for the information.
Yes, the driver does use a queue, those queues are also referenced quite a few times in the PCAN-Linux Driver Documentation:
Most likely you are reading constantly, which of course will drive CPU usage up.
A recommendation here is to use event-driven reading instead of a constant call of read within a loop.
For this you can take a look at the example "pcaneventread" to see how events can be used to initiate a read. You can find this example in.
Please report back to me if this approach was able to resolve your issue.
Best Regards
Marvin
Thank you for the information.
Yes, the driver does use a queue, those queues are also referenced quite a few times in the PCAN-Linux Driver Documentation:
Most likely you are reading constantly, which of course will drive CPU usage up.
A recommendation here is to use event-driven reading instead of a constant call of read within a loop.
For this you can take a look at the example "pcaneventread" to see how events can be used to initiate a read. You can find this example in.
Code: Select all
peak-linux-driver-8.10.2\libpcanbasic\examples\c++\src
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: Multi-CAN interface
Hi.
Thanks for a quick answer.
I based my code on your program example pcan event read.
Anyways I tested threads. One thread-process for each can-interface.
Every thread would occupy one core to almost 100% cpu.
I don't think select and treads works together well.
Anyways, I have now changed the code using fork() to make 6 extra processes.
All cpu-cores are now resting at 1 - 10%.
Success..
/Terje.
Thanks for a quick answer.
I based my code on your program example pcan event read.
Anyways I tested threads. One thread-process for each can-interface.
Every thread would occupy one core to almost 100% cpu.
I don't think select and treads works together well.
Anyways, I have now changed the code using fork() to make 6 extra processes.
All cpu-cores are now resting at 1 - 10%.
Success..
/Terje.