PicoTech LabVIEW Error handler

Post your LabVIEW discussions here
Post Reply
AndrewA
PICO STAFF
PICO STAFF
Posts: 401
Joined: Tue Oct 21, 2014 3:07 pm

PicoTech LabVIEW Error handler

Post by AndrewA »

I have attached images of code examples of how to use our old and current error handler.
Current-
Using errorhandler2.png
Using errorhandler2.png (10.3 KiB) Viewed 10493 times
Old-
Using errorhandler.png
Using errorhandler.png (8.21 KiB) Viewed 10493 times
You may wish change the code in the current errorhandler - (PicoErrorHandler2.vi), so it writes the error text (function, error details) to a file, rather than the dialog box.

Both error handlers are in-
https://github.com/picotech/picosdk-ni-labview-shared
Current errorhandler - https://github.com/picotech/picosdk-ni- ... andler2.vi
Old errorhandler - https://github.com/picotech/picosdk-ni- ... Handler.vi

Errorhandler details-
We have a improved Error handler vi see the text below, so switching your code to use the current one should help some what.
The PICO_STATUS codes can be ignored but this normally means your the unit will fail to work as normal.
So your code should check the PICO_STATUS from each Pico function called.
There is no way to clear/reset errors. I believe all the error codes are recoverable apart from maybe some USB power errors.
So there two ways you can handle the error codes-
A) Detect the error code and then call psXXXXCloseUnit to close the device
B) Call the function again using different input values until the status code is zero. You may want add max. number times it reties, and then calls psXXXXCloseUnit to close the device.
Doing B) for every function is a lot of work.

PicoErrorHandler2.vi-
Our current errorhandler - (PicoErrorHandler2.vi) does A, but triggers a message box on a error code and gives you three options-
1) Calls the psXXXXCloseUnit and exits the example
2) Continues
3) Exits the example
errorhandler2 Dialog.png
The current Error handler vi this stops devices being left open by the driver.
Most of our LabVIEW examples use shared error handler vi code, which when non zero PICO_STATUS code is returned from a function, triggers a message box, and then exits. This leaves the device open by driver.
To reuse the device you either have to close LabVIEW, switch USB ports, or run the psXXXXClose.vi using the correct handle value. This is time consuming when running and debugging code when a error code happens.

Due to the current errorhandler having to add new connections to the sub vi block (changing the connection pattern from more two connects) this will break links to existing code examples.
The addition of 'default handle' input is optional and is only required if wishing to close already open units, with a non standard handle value. (ie non-'a' drivers or multiple scopes on the same PC)

We are leaving the existing errorhandler, apart from modifying it to use a sub vi that contains PICOSTATUS codes and enums from the PicoStatus.h file. (PicoErrorString.vi)
The current errorhandler also uses PicoErrorString.vi which also has addition code to lookup and return PICOSTATUS codes values with enum error as a string.

Our full code examples are here-
https://github.com/picotech/picosdk-ni-labview-examples See-
https://github.com/picotech/picosdk-ni- ... /README.md
Regards Andrew
Technical Specialist

Post Reply