Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

simple C# GPIB listener program

Hello,

               I am new to ‘GPIB’, for my project I have to run one application on Windows (os) controlled from an Unix system.

Under Windows (os) I have a C# (VS-2008) application which have to read strings from Unix,  windows-pc is installed with NI-GPIB-USB.

When I try to send one string from Unix, the program try to send but it stops after 15sec because of timeout. On Windows side I cannot read any string.

I think the problem is not so complicated for many of you because I am a beginner in GPIB and C#, it will be very helpful if someone can solve it. I am adding some part of my C# code here.

 

using NationalInstruments.NI4882;

namespace ftt

{

 public class ts

 {

  Device device = new Device(0,11);

  Board board = new Board(0);

  string mes;  bool i = true;

 

public string dloop()

{

 while (i)

 {

  GpibStatusFlags mask = (GpibStatusFlags.ListenerAddressed);

 

try

{

  board.Wait(mask); // Update gpib status

}

catch (ArgumentException) { MessageBox.Show("A bit set in the mask is invalid"); i = false; }

catch (GpibException) { MessageBox.Show("NI-488.2 driver returns an error"); i = false; }

 

// Addressed as a Listener

if(board.GetCurrentStatus() == GpibStatusFlags.ListenerAddressed)

{

 mes = device.ReadString();

 i = false;

}

. . . . .. .. .. ... ...

return mes;

-----------------

-----------------

Thanks.

0 Kudos
Message 1 of 2
(5,665 Views)

I found something,

Please check my new topic >  NI-GPIB-USB controller as a device (C#)

0 Kudos
Message 2 of 2
(5,618 Views)