Example Code

Ivi.Visa.NativeVisaException: '인터페이스 타입이 유효하지만 그러나 지정된 인터페이스 번호가 설정되지 않았습니다.'

프로그램이 다른 PC에서는 작동하는데 기존 PC에서 작동이 안되는 원인을 알고 싶습니다.

 

코드의 ConnectToGPIBDevice 메서드가 시작됩니다.
ResourceManager를 생성하고 rm.Open(address)를 호출하여 GPIB 장치에 연결을 시도합니다.
예외가 ResourceManager.Parse 메서드에서 발생하며, 이것은 GPIB 주소를 파싱하려고 시도할 때 발생합니다.
주요 문제는 GPIB 주소가 올바르게 파싱되지 않았다는 것으로 보입니다.

 

Keysight Connection Expert 프로그램을 사용한 화면

dhjung_0-1695088590303.png

통신이나 주소 문제는 아니고 Command Send & Read는 잘 작동하는 모습입니다.

 

아래는 사용한 프로그램 코드 입니다.

 

using NationalInstruments.Visa;

namespace New3458A
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ConnectButton_Click(object sender, RoutedEventArgs e)
{
ConnectToGPIBDevice();
}
private void ConnectToGPIBDevice()
{

// GPIB 주소를 설정합니다.
string address = "GPIB0::1::INSTR";

// ResourceManager를 생성합니다.
var rm = new ResourceManager();

// GPIB 장치에 연결합니다.
var session = (MessageBasedSession)rm.Open(address);

// 장치에 명령을 보냅니다.
session.RawIO.Write("*IDN?");

// 장치로부터 응답을 읽습니다.
string response = session.RawIO.ReadString();

// 응답을 출력합니다.
DeviceResponse.Text = response;

// 세션을 종료합니다.
session.Dispose();
}
}
}

 

아래는 예외처리의 세부 정보 입니다.

 

Ivi.Visa.NativeVisaException
HResult=0x80131500
메시지=인터페이스 타입이 유효하지만 그러나 지정된 인터페이스 번호가 설정되지 않았습니다.
소스=NationalInstruments.Visa
StackTrace:
at NationalInstruments.Visa.Internal.ErrorChecker.CheckStatusAndThrow(Int32 status, SafeVisaHandle visaObject)
at NationalInstruments.Visa.ResourceManager.Parse(String resourceName)
at NationalInstruments.Visa.ResourceManager.Open(String resourceName, AccessModes accessModes, Int32 timeoutMilliseconds, ResourceOpenStatus& openStatus)
at NationalInstruments.Visa.ResourceManager.Open(String resourceName)
at New3458A.MainWindow.ConnectToGPIBDevice() in C:\Users\wjdeo\OneDrive\바탕 화면\3458A\New3458A\New3458A\MainWindow.xaml.cs:line 42
at New3458A.MainWindow.ConnectButton_Click(Object sender, RoutedEventArgs e) in C:\Users\wjdeo\OneDrive\바탕 화면\3458A\New3458A\New3458A\MainWindow.xaml.cs:line 30
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at New3458A.App.Main()

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.