Thanks for the help!
After not getting any replies for a couple days, I decided to attack the problem using the GPIB-32 dll.
I'm not sure what's better, using COM or DLL's functions directly, but my C# GPIB wrapper seems to be working out well so far.
In case someone wants to go that route, here's my wrapper class so far:
public class GPIB
{
[DllImport("GPIB-32.dll")]
public static extern int ibask(
int UnitDescriptor,
int Option,
System.IntPtr Value
);
[DllImport("GPIB-32.dll")]
public static extern int ibbna(
int UnitDescriptor,
[MarshalAs(UnmanagedType.LPStr)] char[] BName
);
[DllImport("GPIB-32.dll")]
public static extern int ibcac(
int UnitDescriptor,
int IsSynchronous
);
[DllImport("GPIB-32.dll")]
public static extern int ibclr(
int DeviceDescriptor
);
[DllImport("GPIB-32.dll")]
public static extern int ibcmd(
int UnitDescriptor,
byte[] CommandBuffer,
long Count
);
[DllImport("GPIB-32.dll")]
public static extern int ibcmda(
int UnitDescripor,
byte[] CommandBuffer,
long Count
);
[DllImport("GPIB-32.dll")]
public static extern int ibconfig(
int UnitDescriptor,
int Option,
int Value
);
[DllImport("GPIB-32.dll")]
public static extern int ibdev(
int BoardIndex,
int PrimaryAddress,
int SecondaryAddress,
int TimeOut,
int eot,
int eos
);
[DllImport("GPIB-32.dll")]
public static extern int ibdma(
int UnitDescriptor,
int EnableDMA
);
[DllImport("GPIB-32.dll")]
public static extern int ibeos(
int UnitDescriptor,
int EnableEOS
);
[DllImport("GPIB-32.dll")]
public static extern int ibeot(
int UnitDescriptor,
int EnableEOT
);
[DllImport("GPIB-32.dll")]
public static extern int ibfind(
[MarshalAs(UnmanagedType.LPStr)] char[] UnitName
);
[DllImport("GPIB-32.dll")]
public static extern int ibwrt(
int UnitDescriptor,
byte[] WriteBuffer,
long count
);
[DllImport("GPIB-32.dll")]
public static extern int ibrd(
int UnitDescriptor,
byte[] ReadBuffer,
long Count
);
public GPIB()
{
}
public static string DecodeGPIBStatus(int StatusWord)
{
string ES = "";
if((StatusWord & 1) != 0)
ES += "Device Clear State. ";
if((StatusWord & 2) != 0)
ES += "Device Trigger State. ";
if((StatusWord & 4) != 0)
ES += "Listener. ";
if((StatusWord & 😎 != 0)
ES += "Talker. ";
if((StatusWord & 0x10) != 0)
ES += "Attention is asserted. ";
if((StatusWord & 0x20) != 0)
ES += "Controller-In-Charge";
if((StatusWord & 0x40) != 0)
ES += "Remote State. ";
if((StatusWord & 0x80) != 0)
ES += "Lockout State. ";
if((StatusWord & 0x100) != 0)
ES += "I/O completed. ";
if((StatusWord & 0x800) != 0)
ES += "Device requesting service. ";
if((StatusWord & 0x1000) != 0)
ES += "SRQ interrupt received. ";
if((StatusWord & 0x2000) != 0)
ES += "End of EOS detected. ";
if((StatusWord & 0x4000) != 0)
ES += "Time limit exceeded. ";
if((StatusWord & 0x8000) != 0)
ES += "NI-488.2 error. ";
return ES;
}
public static int WriteString(int handle, string command)
{
char[] ch_command = command.ToCharArray();
byte[] cmd = new byte[ch_command.Length];
for(int i=0; i cmd[i] = (byte) command[i];
return GPIB.ibwrt(handle, cmd, cmd.Length);
}
public static string ReadGPIBBuffer(int handle, int size)
{
byte[] output = new byte[size];
char[] outchars = new char[size];
int response = ibrd(handle, output, size);
for(int i=0; i {
outchars[i] = (char) output[i];
if(outchars[i] == '\0')
break;
}
return new string(outchars);
}
}