Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I get an error 4 when calling the Read file vi?

It is the first call from a sub-vi of a path passed from another sub.
0 Kudos
Message 1 of 5
(3,713 Views)
Path was established, but no data was written before first call; therefore the EOF was immediately encountered.  Problem solved with specific logic to isolate control first call.
0 Kudos
Message 2 of 5
(3,703 Views)

Hi PowerTest,

Good job debugging that.  It looks like you have a solution that works well, but in case you wanted to do any more reading on Error 4, there is a good KnowledgeBase about this error and some work arounds:  KB 2WACHODS, Error 4 Occurred at Read File in XXX.vi.

Happy coding!
Megan B.
National Instruments

Message 3 of 5
(3,689 Views)
I found the 4th solution on the referenced knowledge base item above to be quite effective.  When the error cluster is unbundled, and the error status is set to false, the error is registered as a warning, and can be viewed by a probe.  Yet the error is not passed; instead "ok (4)" passes, not interfering with downline vi's, but informing one that the error--reduced to a warning--occured.
0 Kudos
Message 4 of 5
(3,679 Views)
Powertest,

allthough your method will work, it is not good style. There are a lot of other possible errors, starting at error 7 - file not found. Just resetting error.status to false prevents the following code from proper error handling. And there's a reason for the existence of warnings. I am not sure of the code of a warning is allways meaning the same as that of an error.
Instead of changing errors to wartning, you should compare your error cluster with the expected error (in your case error 4) and, if equal, replace it with a no_error-constant.
Attached you'll find an example for this kind of specific error handler.
Using this techniques you limit the reported errors to _all_ those that have not been expected and those that can not be handled locally. While the latter ones might be expected, the first group is totally undetermined and so cannot be handled properly. Ignoring those can harm your code.

Greetings from Germany!<br>-- <br>Uwe
Message 5 of 5
(3,669 Views)