From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use threaded CVI serial port routines on teststand

I have an application which needs to run on the background during teststand execution and to collect data from UUT by using a serial port (Octal Legacy RS-422 NI card) . I've used asynctimer.fp to  run my statemachine algorithm to analyse data and I also put InstallComCallback to a thread on my DLL module to receive data simultaneously. It runs without any problem on CVI but when I use my DLL on TestStand asynctimer doesn't run at all. It seems like TS stops asynctimer thread during execution. What should I do to fix that problem? Is there any way to tell TS API to enable that timer thread? I'm not experienced on threaded programming. This is my first application using threads.
 
I've tried multithreading and single apartment thread settings on TestStand but I don't think that's what I wanted, because I need to collect data , analyse it and need to pass to the next step after that.
 
Thanks in advance,
Hakan
 
0 Kudos
Message 1 of 3
(3,111 Views)
Hakan -

Are you issuing two DLL calls in TestStand (one for the asynchronous state machine, the other for synchronous communication callbacks)?

I am unsure how you are using the asynctimer.fp for the statemachine.  I would assume you are using NewAsyncTimer( ) to create a new timer ID.  What function are you then passing the timer to?

You mention multithreading as well.  When using just CVI, are you creating a thread pool, and using one thread to run the state machine, another to do the synchrounous serial communication?  Characteristically, TestStand threading handles multiple UUTs simulatenously.  However, there may still be a way to use the batch or parallel process model to accomplish you application goal.  If you could give a description of how you are attempting to handle the threads, as well as the dependencies between the state machine and the communication threads, that would help greatly.

My only suggestion at this point would be to make a single function call to your CVI DLL in TestStand.  Since the timer and communication callbacks work in CVI, you could have the CVI DLL do the thread handling and device communication.  You can then return the data to TestStand, and have steps to analyze and present the data.

Andrew W. || Applications Engineer
Message 2 of 3
(3,074 Views)
Hi Hakan:

What adapter are you using in TestStand? Did you use the CVI adapter or the DLL adapter?

Have you compiled the CVI code into a DLL?

Do you use the CVI code to communicate to an instrument?

If so, do separate threads communicate with separate instances of the instrument?

Thank you

Nandini
NI
0 Kudos
Message 3 of 3
(3,063 Views)