Tags: case, consequently, detect, labview, port, programming, run, time, unless
How to detect first time a vi is run?
I have a vi that need to open a com port, unless it's already open in which
case it should just read the com port.
Consequently I would need either a way of detecting if this is the first tim
e a vi runs or a way of checking (very quickly) if a com port is open. Since
the first functionality is very universally useful I'd very much like a sug
gestion here in any case. W
iebe mentioned such functionality in one of his post, a vi that returns this
I have tried to use a while loop that runs once to detect if its the first r
un, for some reason I decided this worked yesterday but today it doesn't. (A
ny explanation on that anyone?)
I am programming a cFP-2120.
First run - initialize.jpg:
http://forums.ni.com/attachments/ni/170/298762/1/First run - initialize.jpg
Leave a comment...
- 3 Comments
- Rodnebb wrote:
I decided this worked yesterday but today it doesn't. (Any explanation on th
The USR keeps its value as long as the VI is in memory, even if the entire h
ierarchy stops running, so if you ran your code once and then ran it again w
ithout unloading the VI, it will return T even on the first call.#1; Thu, 01 May 2008 22:48:00 GMT
- Here is the path to a vi that I use to check to see if any ports are op
en you can then use the refnum you need from the array if the port is open.
It is also useful if you need to make sure all ports are closed, just run th
e array into a for loop wit
h a VISA Close.
CLA, Certified Trainer#2; Thu, 01 May 2008 22:49:00 GMT
- The only problem I have with the "detect first time" method is that it is ve
ry easy to leave a COM port in an unknown state especially if you have impro
perly terminated a program and have not exited the LabVIEW system you get a
"hung" port. LabVIEW has th
e port reserved as open but the program no longer has the session. I am atta
ching a program that should provide the functionality Rodnebb is looking for
. I am also attaching another quick vi that I have found very useful and tha
t one is for resetting all
open COM ports.
ResetCommPorts.vi:#3; Thu, 01 May 2008 22:50:00 GMT