LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delaying Error Messages

I'm looking for a way to stop error messages during the excecution of a program. The situation is basically this:

 

I am currently working on a Labview program that interacts with a program on a different computer using text files. Essentially the labview program provides instructions (in the form of a text file with the instructions for what the temperature of a piece of hardware should be), the other program uses these instructions to change the temperature of the hardware. The other program also constantly updates a text file that represents the current temperature of the piece of hardware. My labview program is then grabbing that text file reading it and recording it in an array with many other temperatures.

 

The problem is that when the labview program is trying to read the file at the same time as the other program is saving it my labview program gets an error message. Because this program is being used in a research study I obviously dont want error messages going off and delaying my program at random invalidating data etc etc. I'm wondering if theres a way to set my program so rather than producing an error message it simply no longer writes a temperature value to that file but writes "X" or "ERROR" in the spot of that value instead.

 

Is this possible? Am I going about this the wrong way? I'm relatively new to this so any help would be appreciated.

"There will be water if God wills it"
0 Kudos
Message 1 of 5
(2,745 Views)

Nproach,

 

You need to use the general error handler.vi.  If you enter the error code in the [error code] input it will ignore that error.  You can then output to your text file with the message output.  Also, make sure you use clear errors.vi so it can continue after that.  

 

Hope this helps

 

 

Pete

Peter C.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(2,729 Views)

Another solution that I use is to copy the file from the network location using the system32.dll Move function.  This takes care of any conflicts.  There is also a Copy function in the Files Function palette you can try that may work.

Another solution would be to handle error 5 when it occurs, clear it, and repeat the read until it opens it successfully.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 3 of 5
(2,723 Views)

pretty easy to do- just use a case structure arround your write to file

easier.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(2,720 Views)

Here is what I do for your specific problem

 

The creator of the file does this:

  • Create an empty file named "file.lock"
  • Create or modify actual file named "file.txt"
  • Delete "file.lock"

The consumer of the file does this:

  • Look for files with .txt extension
  • Finds "file.txt"
  • Checks if "file.lock" exists
  • If "file.lock" does not exist then read "file.txt"
  • If "file.lock" does exist then start over

As others have pointed out you might take advantage of the OS file copy functions as they do something similar at a lower level or just retry.

=====================
LabVIEW 2012


0 Kudos
Message 5 of 5
(2,714 Views)