Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Turn System Controller bit On/Off, programmatically

>>I assume that is a typo and you meant gpib-32.dll.
Yes, you are correct

I've decided to do this in Python, instead of C or VB.
However, I can translate the C or VB code to Python, assuming I have a reliable mechanism that works in C/VB.
Python has a mechanism to access all of the Windows DLLs, and it works quite well. However, I still cannot see the ibfind() proc in the gpib-32.dll.
0 Kudos
Message 11 of 12
(1,218 Views)
You are right, there is no ibfind within gpib-32.dll. You would need to use ibfindA. However, most of the time you don't even need an ibfind call. If you are trying to control an instrument, use ibdev instead to open the device handle.


Gpib32Lib = LoadLibrary ("GPIB-32.DLL");
if (!Gpib32Lib) {
// Error out
return;
}

// Retrieve the global variables
Pibsta = (int *) GetProcAddress(Gpib32Lib, (LPCSTR)"user_ibsta");
Piberr = (int *) GetProcAddress(Gpib32Lib, (LPCSTR)"user_iberr");
Pibcntl = (long *)GetProcAddress(Gpib32Lib, (LPCSTR)"user_ibcnt");

// Retrieve some device function calls
Pibclr = (int (__stdcall *)(int))GetProcAddress(Gpib32Lib, (LPCSTR)"ibclr");
Pibdev = (int (__stdcall *)(int, int, int, int, int, int))GetProcAddress(Gpib32Lib, (LPCSTR)"ibdev");
Pibonl = (int (__stdcall *)(int, int))GetProcAddress(Gpib32Lib, (LPCSTR)"ibonl");
Pibrd = (int (__stdcall *)(int, PVOID, LONG))GetProcAddress(Gpib32Lib, (LPCSTR)"ibrd");
Pibwrt = (int (__stdcall *)(int, PVOID, LONG))GetProcAddress(Gpib32Lib, (LPCSTR)"ibwrt");

// Use the calls
DeviceHandle = (*Pibdev) (boardIndex, devicePad, deviceSad, timeout, eot, eos);
if ((*Pibsta) & ERR)
{
GPIBCleanup(Dev, "Unable to open device");
return 1;
}

If you really want to you can create your own language interface that wraps these calls (see below). This way your code looks more like a C program would using the same NI-488.2 calls.
int __stdcall ibdev (int ud, int pad, int sad, int tmo, int eot, int eos)
{
if (Pibdev == NULL) {
// Verify that the DLL is loaded if necessary
...
// Load global variables if necessar
...

// Load the ibdev call
Pibdev = (int (__stdcall *)(int, int, int, int, int, int))GetProcAddress(Gpib32Lib, (LPCSTR)"ibdev");
if (Pibdev == NULL) {
return -1;
}
}
int retval = return (*Pibdev ) (ud, pad, sad, tmo, eot, eos);

// Retrieve the global variables
ibsta = (int)*Pibsta;
iberr = (int)*Piberr;
ibcntl = (long)*Pibcnt;

return retval;
}
0 Kudos
Message 12 of 12
(1,215 Views)