01-15-2008 12:15 PM
#include
<iostream>#include
<windows.h>#include
"ni488.h" int main(){
int gpib;gpib = ibfindA(
"GPIB0");ibsic(gpib);
ibcmd(gpib,
"_?@3",4L);ibwrt(gpib,
"C2",2L);ibcmd(gpib,
"_",1L);ibcmd(gpib,
"_?@3",4L);ibwrt(gpib,
"A0",2L);ibcmd(gpib,
"_",1L); return 0;}
The device does not respond to myt commands. I think it is probably with my board initialization, but I am at a loss. I know the commands work with ibic.exe, in the order presented and the hardware and unit are working. So it must be my coding.
If I use ibfind I get this error;
error C2664: 'ibfindW' : cannot convert parameter 1 from 'const char [6]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
01-16-2008 01:37 AM
status1=ibsic(gpib);
status2=ibcmd(gpib,"_?@3",4L);
status3=ibwrt(gpib,"C2",2L);
...
?
Hint: You can check the returned status variables (if not 0) with the GPIB error coding list. If the stuff works fine, status should be 0.Best regards peter
01-16-2008 06:53 AM
01-16-2008 08:48 AM - edited 01-16-2008 08:48 AM
muellerp,
I just got in this morning, but give me a little bit and I can get you the return values. I will either attach the NI Spy or re-write my code to capture the values.
01-16-2008 08:50 AM
Ray Farmer,
What the heck is that LPCSTR and how do I cast to it. Do I just do a <static_cast>LPCSTR ? Is that some sort of Microsoft data type? Thank you for your help.
01-16-2008 09:08 AM
Hi,
You can declare a variable ie
LPCSTR device = "GPIB0";
gpib= ibfind(device);
or
gpib = ibfind ((LPCSTR)"GPIB0");
regards
Ray Farmer
01-16-2008 10:19 AM
Ray,
When I use
gpib = ibfind(LPCWSTR(
"GPIB0"));the project will compile but then NI Spy tells me that iberr is EVDR, or "Error connecting to driver or device" and then all the following commands then fail.
01-16-2008 10:22 AM
muellerp,
I looked at the script with NI Spy and it told me all commands went through okay except my ibwrt. A coworker here had changed the PAD of the GPIB0 to 25 instead of 0, so the ibwrt wasn't working. Thank you for your help. I also found that despite what the manual and programming instructions say for the units I am working with, the "B" model and the "C" model are different in how they react to IEEE commands.
01-26-2008 03:11 PM
01-31-2008 07:45 AM
Ray,
I ended up fixing this by using a multi-byte character set in the properties drop-down of the project menu. After that, ta-da, no complaints from the compiler.