11-24-2016 04:18 AM
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é
Solved! Go to Solution.
11-28-2016 08:55 AM
Hello René,
first of all, what error do you get and which function throws that error?
Best regards
Wolfgang
11-28-2016 09:18 PM
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!
11-29-2016 12:40 AM
Hi,
thanks for the answers. I do some testing. I insert some semaphores at the beginning and the end of a base read funktion
Is this also a good way to synchronize 2 or 3 tasks?
11-29-2016 04:36 AM
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.