09-03-2024 02:55 PM
I'm developing a Windows console application that will talk to an Agilent DAQ via an NI IEEE-488 interface. I'm pretty sure I have the right objects in use, but when it gets to the "open" method it throws an exception. Here's a snippet of the code and the resulting error:
// attempt communications with 34980A DAQ
Ivi.Visa.Interop.FormattedIO488 Data_Logger = new FormattedIO488();
//create the resource manager
ResourceManager mgr = new ResourceManager();
string DAQ_Address = "GPIB0";
// Try to open the device
string option_string = "";
Data_Logger.IO = (IMessage)mgr.Open(DAQ_Address, AccessMode.NO_LOCK, 2000, option_string); // This throws an exception
Exception: {"Unable to cast COM object of type 'System.__ComObject' to interface type 'Ivi.Visa.Interop.IMessage'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DB8CBF05-D6D3-11D4-AA51-00A024EE30BD}' failed due to the following error: No such interface supported (0x80004002 (E_NOINTERFACE))."}
Can anyone point me to a solution? Thanks.
09-11-2024 07:57 PM
Hi,
Can you try using the NationalInstruments.VISA dll?
Usually it should work using NI-VISA DLL.
Public gpibAddress As String
Public RM_VNA As NationalInstruments.Visa.ResourceManager
Public GPIBDevice_VNA As MessageBasedSession
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
gpibAddress = "ASRL5::INSTR"
RM_VNA = New NationalInstruments.Visa.ResourceManager
GPIBDevice_VNA = CType(RM_VNA.Open(gpibAddress), MessageBasedSession)
Dim textToWrite As String = "HelloGPIB"
GPIBDevice_VNA.RawIO.Write(textToWrite)
End Sub
The example Visual Basic code above worked on my end in sending string data using NI-VISA DLL.