NI VISA Interface Clear Workaround

Comments 0

NI VIsa Interface Clear has a minor bug causing it to time out if no resources exist on the bus.  Here is a method aimed at a work around as part of a class that inherits the NationalInstruments.VisaNS.GpibInterface.

”’ <summary>Issues an interface clear.</summary>
”’ <returns>Returns <see cref=”VisaStatusCode”>Visa status code</see>.
”’ </returns>
”’ <remarks>Works around the following NI Visa Interface Clear issues:
”’ <para>
”’ NI Visa (4.1) times out issueing interface clear if no resources exist on the bus.
”’ This method traps the timeout and returns a
”’ <see cref=”VisaStatusCode.ErrorTimeout”>timeout status</see>.
”’ </para>
”’ <para>
”’ Also, NI Visa incorrectly returns a status of success. This cannot be fixed
”’ because the <see cref=”LastStatus”>status</see> property is read only.
”’ Thus returning the the relevant status helps.
”’ </para>
”’ </remarks>
Public Shadows Function SendInterfaceClear() As NationalInstruments.VisaNS.VisaStatusCode

Return MyBase.LastStatus
Catch ex As NationalInstruments.VisaNS.VisaException When ex.ErrorCode = VisaStatusCode.ErrorTimeout
‘ trap timeout error. Apparently, VISA is trying to send commands to the devices
‘ even if none are present.
‘ un-time exception thrown:
‘ NationalInstruments.VisaNS.VisaException – Timeout expired before operation completed.
‘ VISA error code -1073807339 (0xBFFF0015), ErrorTimeout
Return VisaStatusCode.ErrorTimeout
End Try

End Function

This article is licensed under The Code Project Open License (CPOL)

Leave a Reply

Your email address will not be published. Required fields are marked *