I have a Teststand seq using the sequencial process model. This seq has a subsequence that handles the CAN communication in a new thread in the background continuously. In CVI i have a CAN data struc that is written by the CAN sub sequence and read by a function in the mainsequence.
Can this situation lead the race conditions.
Thanks for your response in advance
Let me see if i understood your use case properly .
You have a structure in CVI which maintains data.
TS Sub sequence - write CAN command in this structure.
CVI - Send to target.Receives response and fills the same structure.
TS Main sequence - Reads data from the same structure.
Yes i think it will lead to race conditions.
You can modify the sub sequence only to read and write the data.On reading it can update a local container variable in TestStand.It can update a flag which says that data is read.
The flag will be read by main sequence before reading the data.
Thanks for your response
You understood it correctly. In the current situation the CAN subroutine writes data to a CVI structure in a new thread. The main tread reads this data. I have to use some kind of lock mechanisme to prevent reading and writing at the same time
You are correct.
You will need to implement some synchronisation mechanism in the CVI code.
Since the read and write are running in different threads you also need to ensure that first write is executed ( command) and then only read ( response to that particular command).