06-30-2014 01:18 PM
Hello everyone. I need advice from all you TestStand gurus out there.
I Need to run two things in parallel:
1. Polling Sequence: I need to poll devices in a product continuously. This poll just pings each device to make sure it is able to communicate with it. If a device does not get pinged within 5 seconds the device FW will shutdown the device. It is crucial that I continuously poll these devices to keep the product up and running.
2. Main Test Sequence: I also need to run a sequence to run test steps on this product.
My issue:
At certain steps in the "Main Test Sequence" I will need to tell the "Polling Sequence" (Polling Loop) to shut down so that I can free up the communication to send test commands on a device within the product.
I've done a bit of research on this issue. One way I believe to do this is from my "Main Test Sequence" I could create a "Sequence Call - New Thread" step. I could call this thread at the beginning of my "Main Test Sequence" to start it and if I come across a step in my "Main Test Sequence" that needs to access one of the devices in the product I could set a global variable step that the "Polling Sequence" would see so that it would stop or start based on this variable.
I am newer to TestStand and am looking for the most efficient way to do this. What do you guys and gals think is the most efficient way to do this?
Thanks!
06-30-2014 04:32 PM
questions
Are you going to communicate with each board/UUT with a communication Device/USB/Serial Independently or are you going to be switching to Share One device/usb to communicate with all the boards?
After that we can continue to make a strategy on how to do it.
but...
if you are not sharing resources and you have for example ONE serial port or USB/to serial convert for each UUT..
you could run everthing in parallel.. in testand you could build a while function to cycle your program to ping each 5 seconds...and if you want to do some other stuff every 15 minutes you could have an IF inside the loop call a Test Sequence. and after that it will come back to the ping.
is it something like that what you are looking for?
07-01-2014 08:08 AM - edited 07-01-2014 08:08 AM
One approach that works well for this is a notifier or queue. You would set up the sequences exactly as you described, with a monitoring/polling sequence running in a new thread concurrently with your main sequence. However, you can use a TestStand notifier (in the Synchronization folder of the insertion palette) to allow you to communicate between the two running threads. Your monitoring/polling thread should have a step in its loop which checks the notifier status and responds to new notifications as needed. When the main sequence needs the monitoring/polling sequence to pause or perform an action, it simply sends a notification to the that thread.
This also helps with shutdown at the end of the test program, as it provides a clean way to instruct the monitoring/polling thread to safely shut down.
I'd recommend this type of approach for your system--I've seen it used successfully by other customers in similar situations. Let us know if you have any additional questions about it, we're always happy to help out.
07-01-2014 08:43 AM
Thanks guys.
Daniel-E,
Do you have any good TestStand examples that show how Notifications are used to communicate between threads (in this case my Polling Thread and my Main Sequence)?
Thanks!
07-01-2014 09:28 AM - edited 07-01-2014 09:29 AM
I think the simplest approach would be to just use a lock around the calls to the devices. It sounds like you really don't want to stop the polling loop, you just want it to pause while you are accessing the hardware in a different thread. If so, you can accomplish that with a lock as follows:
Polling thread:
Begin Loop
AcquireLock
Ping Hardware
ReleaseLock
End Loop
Main thread:
AcquireLock
Use Hardware
ReleaseLock.
Ownership of the lock then effectively gives ownership of access to the device. There are a couple of ways to use locks in teststand. You can use the Lock step type to lock around multiple steps, or use the builtin step type lock setting to lock around the execution of a single step.
A global variable is not a good solution because when you set the global variable you still have know way of knowing if the polling thread has checked it yet. It might still be pinging the device. While a lock guarantees exclusive access if used as described above.
Also, don't forget to disable result collection for your polling sequence (in the sequence properties dialog) to avoid leaking memory while that thread is looping.
Hope this helps,
-Doug
07-01-2014 01:29 PM
Doug, in the method you mentioned above do I need to create 2 separate locks? One for Main Sequence and One for Polling Sequence? Thanks!
07-01-2014 01:30 PM
Doug, could you send me an example? Thanks!
07-02-2014 09:09 AM - edited 07-02-2014 09:11 AM
@testdesign wrote:
Doug, in the method you mentioned above do I need to create 2 separate locks? One for Main Sequence and One for Polling Sequence? Thanks!
They need to be the same lock (i.e. the same lock name). The idea is that only one thread can own the lock at a time. In order to create an example, I need to know what version of TestStand you are using.
-Doug
07-02-2014 11:06 AM
Thanks Doug. I am using TestStand 2013.
07-08-2014 10:11 AM
Here's an example. Had to zip it to get the forum to allow me to attach the file.
-Doug