12-14-2015 02:21 AM
I have add reference "NationalIstruments.NI4882", but can't coding 488.2 command. please see below picture.
My OS is WIN 7 64 bit, VS2013, MAX v15.0.0f0, upgrate to new version.
Below is my code, can't to build, NI488 code can't complete compile.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ivi.Visa.Interop; //VisaComLib
using NationalInstruments.NI4882;
using NationalInstruments.VisaNS;
namespace xxx
{
class Program
{
private MessageBasedSession mbSession;
static void Main(string[] args)
{
int noncontroller;
char[] buffer = new char[100];
int panelHandle;
//Open session to the GPIB board
noncontroller = ibfind ("gpib0");
//Release system control
ibrsc(noncontroller, 0);
//Change GPIB primary address from 0 to 2
ibpad(noncontroller, 2);
while(true)
{
//Update status variable
ibwait(noncontroller, 0);
//Wait until non-controller is listener and ATN line is dropped.
if ((ibsta&LACS)&&(!(ibsta&ATN)))
{
ibrd(noncontroller, buffer, 100); // Read data bytes
buffer[ibcnt] = '\n'; //Add linefeed and 0 to string
buffer[ibcnt + 1] = 0;
Console.WriteLine("Buffer Value{0}", buffer);
//printf("%s", buffer); // Print buffer for C
return;
}
}
}
}
}
Solved! Go to Solution.
12-14-2015 09:17 AM
If you the newest NI-488.2 installed, it should support .NET Framework 4.5.1
12-14-2015 08:39 PM
Yes, can support .NET Framework 4.5.1, so only can use .NET to programming?
12-15-2015 09:50 AM
@JackieLin wrote:
Yes, can support .NET Framework 4.5.1, so only can use .NET to programming?
I don't understand your question.
Visual Studio uses .NET
12-15-2015 08:38 PM
I think loss NationalInstruments.Common,but add reference, can't include program, please see below picture.
NationalInstruments.Common verison is 15.0.40.49154
.Net Framework 4
12-16-2015 02:46 AM
Confirm NI4882.dll is working, but can't use ibfind,ibwait..... command, i don't know why?
12-19-2015 06:39 AM
Hi,
You set a reference to the GPIB .NET library, but you using the old Win32 function calls.
ibfind, ibread etc...
You need to use the NI488.2 Class library objects and methods
Check the examples located at the followng link
http://digital.ni.com/public.nsf/allkb/39F4B9264B94308C8625729D0067F9AF
Curt
12-22-2015 12:55 AM
Thanks and understood, but use .NET library, any document can read, because for Win32 have NI-488.2 user manual for reference to programming, such as ibfind,ibwrt...etc, but .NET only example program, i don't know which command same ibfind?
12-22-2015 01:08 AM
I think find maybe answer,please see path http://zone.ni.com/reference/en-XX/help/370628F-01/mstudiowebhelp/html/gpibapimapping/
12-22-2015 06:32 AM
Hi,
You need to create a Board object.
Address boardAddress; Board board; private void butOpen_Click(object sender, EventArgs e) { bool retval = false; try { boardAddress.PrimaryAddress = 0; board = new Board(); //defaults to 0 for GPIB board index number 'GPIB0'. Change to your board number idf required retval = board.FindListener(boardAddress); Debug.WriteLine("FindListener returned " + retval.ToString()); board.IsSystemController = false; retval = board.IsSystemController; Debug.WriteLine("IsSystemController returned " + retval.ToString()); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } }
Debug Output
FindListener returned True
IsSystemController returned False
Good luck!
Curt