Parallel using of CAN1 and CAN2 on Apalis T30

Hello dear support team,

Is it possible that the can_write and can_read methods block each other when used in different threads?

I programmed CAN1 as a CANopen NMT master and CAN2 as a CANopen node. The NMT master transmits SYNC messages in 50ms intervals. This affects that the node response time grows to >500ms. If I deactivate the NMT master, then the response times of the node are <= 1ms. I play with the thread priorities, but I always come to the conclusion that one of the two functionalities does not get reasonable maturity. It seems that the write or read method or both can not be executed parallel to CAN1 and CAN2.

I work with the CE-Library V 2.3b4555.

I init CAN by using can_init(L"CAN1") and can_init(L"CAN2").

I use two threads for NMT-Master (CAN1). The first is for receiving messages and the second is for management and sending messages (e.g. creating sync or RPDO messages etc.). The prioritys for receive thread ist 124 and for the other 138.
I also use two threads for the node (CAN2). The first is for receiving messages and also for sending the direct answer (e.g. SDO answers). Its priority is set to 128. The second thread is for Management (e.g. creating heardbeat, mapping the io or TPDO messages etc.). Its priority is set to 160.

What I’m particularly surprised about is that the two management threads, which have a lower priority, nevertheless still approximately keep their running times. From this one could conclude that the can_read methods influence each other. Could that be? But I´m not sure.

Something is missing: …If I deactivate the NMT master, then the response times of the node are <= 1ms. …

Dear @JanP,

Thank you for contacting support. Your last comment is partially filled, I don’t know whether some data is missed when you submit the comment.
“Something is missing: …If I deactivate the NMT master, then the response times of the node are” Could you write once again?

We would like to suggest a loopback test at CANBUS layer and let us know the result. You need to use 2 CAN interfaces(controller), one for the reading interface and another for write interface. First, configure the read interface and wait for a message with Infinite timeout. Configure the 2nd write interface and write a message to the CAN controller, we are expecting the read thread should receive this message and verify the data. if you are experiencing some problem and let us know with the reproducible application, that will help us to dig the issue and solve it.
Please remember that the read thread is for separate CAN controller and wait for a message in a thread.

We have CAN_Demo(…\TdxLibsBeta\libDemos\Can_Demo) application in our Toradex_CE libraries.

You need to make a custom cable to connect on X20 connector on Ixora board for loopback test.

Please let us know if you have any other questions?

If I deactivate the NMT master, the Response times of the node are less than 1ms,

Dear @JanP,

Thank you for your reply and demo application. Could you please wait for a day? let me test that tomorrow and get back you.
Thank you

Super, no Problem!

Dear Raja,

I tested the same application with the new library. It works fine. Responses are less than 2ms. Wonderful!

Can I use this library as release or do you publish a better version in the next time?

Hi Raja,

I write a little demo. click here

I wrote demo with vs2015. It´s a light version of my actual project.

The demo can used as CAN NMT master (Mode=0; CAN1 is active), only as CAN node (Mode=1; CAN2 is active) or both (Mode=2; CAN1 and CAN2 are active).

First I test mode=2 and connect CAN1 and CAN2 on the same module with a cable and a 120Ohm resistor on both sides. CAN1 sends every 50ms a SYNC message. If you press ‘s’ CAN1 sends a SDO message and wait for a response of CAN2. After a Response is comming in, the application shows the needed time. What I see where that Response times are simular to my real Project (between 200 and 900ms).


I log messages parallel with Device Explorer from emtas GmbH.


What you see now is, that the measured times of the application are the same like Device Explorer shows. What I also see is, that between the request and response are more (in the picture 12) SYNC messages. If I deaktivate the 50ms SYNC message sending in code, the result is the same (which suprises me). You can test that. But I really dont know why. Is it a priority issue? But why there are comming SYNC Messages created by a thread with reduced priority? Are the reading threads block each other? I allready played with prioritys.

The next test I´ve done is that I use two moduls. On both I deploy the demo application. On first one I used Mode 0 and bring the cable to CAN1. On the second modul I used Mode 1 in application and bring the cable to CAN2. Now I got this result:


In Device Explorer I saw this:


Please test the demo and let me know if you can reproduce that. Thanks in advance!

Dear @JanP,

Thank you for the feedback. You would use that as a release, our regular release is the same as preliminary release.

Please feel free to contact us if you need any support in the future!

Dear @JanP,

Could you test with this library release : ToradexCeLibraries_2.3b4561-20190312 and let us know the result.
I guess due to the same named event used in the two receive thread that would make such addition relay for processing.