Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

CANOpen parallel reading from the same device

Solved!
Go to solution

Hi,

i want to read and write parallel to the same device on the can bus. I write a small test programm. but if i want to read parallel i become an error. It is possible to read/write to the same device in multible threats?

The final application has two threats...one reads values and the other write values.

I have the CANOpen NI PCI 8531 Card in my PC.

 

thanks,

 

René

 

0 Kudos
Message 1 of 5
(3,884 Views)

Hello René,

first of all, what error do you get and which function throws that error?

 

Best regards

Wolfgang

0 Kudos
Message 2 of 5
(3,850 Views)

Hello René,

 

I agree that the error code and useful scrrenshot will help us to figure out this question.

 

According to your description and the attachment, I suppose the error occurred when the Read.vi(on the lower thread) started to work during the Write.vi(on the upper thread) running. If so, it makes sense because it cannot do 2 works in the same interface simultaneously. In other words, a thread cannot break off the other thread. After all, whatever Read.vi and Write.vi needs time to execution.

 

For running a PCI 8531 with 2 threads, you should control the data stream by Error Cluster between the 2 threads.

 

Thanks!

 

0 Kudos
Message 3 of 5
(3,837 Views)

Hi,

thanks for the answers. I do some testing. I insert some semaphores at the beginning and the end of a base read funktion

labview_canbus.PNG

Is this also a good way to synchronize 2 or 3 tasks?

0 Kudos
Message 4 of 5
(3,829 Views)
Solution
Accepted by topic author renek

Yes, you can use semaphores but serializing the threats would bring the same result and the code would be much easier to read. Just do the writing/reading and after that task is done, do the reading/writing. Use error clusters like proposed before. Your application could look the screenshot attached.

0 Kudos
Message 5 of 5
(3,822 Views)