Search code examples
c#visual-studio-2012visual-studio-2015visa

Visual Studio 2015 has problems communicating using VISA Libraries


I'm having problems with the VISA-Com Libraries to communicate with a Keysight (N6700B) power supply.

I have some C# code I am compiling in Visual Studio 2015, and it does not work. However, if I compile the same code in Visual Studio 2012, then it works.

Basically I am just doing simple communication with the device:

using Ivi.Visa.Interop;
//...
string address = "USB0::2391::2311::MY54002380::0::INSTR";
ResourceManager rm = new ResourceManager();
FormattedIO488 myDmm = (IMessage)rm.Open(address , AccessMode.NO_LOCK, 2000, "");
myDmm.WriteString("*RST"); // reset the device
myDmm.WriteString("*IDN?"); // request the IDN string;
string IDN = myDmm.ReadString(); // This is where it fails, returning: "VI_ERROR_TMO: A timeout occurred"

Also, the power supply has an error state of: "Error -420, Query UNTERMINATED"

The code does not work with VS2015, but it DOES work with VS2012. (In VS2012 I get no errors at all.)

I have tried downloading the latest drivers from KeySight, and it still does not work (www.keysight.com/find/iosuitedownload).

Does anyone have any idea why it would be breaking with VS2015 but work with VS2012?

I've looked up "Quere Unterminated" and some say that it could be a missing Termination character "\n". I've tried adding the "\n" to both writeStrings, and it still fails.


EDIT: I have also now tried using (in various places):

myDmm.IO.TerminationCharacterEnabled = true; // and = false 

myDmm.FlushWrite(); // also tried passing in "true" (default is 'false')

I also tried adding the:

myDmm.IO.TerminationCharacter

to the WriteStrings.


Solution

  • http://download.ni.com/support/softlib//visa/NI-VISA/15.0/Windows/readme.html

    Microsoft Visual Studio Support

    The following table lists the programming languages and Microsoft Visual Studio versions supported by this version of NI-VISA.

    Earlier versions of NI-VISA support other application software and language versions. For more information on Visual Studio compatibility with earlier versions of VISA, refer to ni.com/info and enter the info code NETlegacydrivers. To find and download an earlier version of a driver, refer to ni.com/downloads.

    Visual Studio Versions Support by NI-VISA:

    Visual C++ MFC1 -------------- 2008

    Framework 3.5 Languages (Visual C# and Visual Basic .NET) -- 2008

    .NET Framework 4.0 Languages (Visual C# and Visual Basic .NET)-- 2010

    .NET Framework 4.5 Languages (Visual C# and Visual Basic .NET)-- 2012

    So apparently the drivers don't work with VS2015... (not sure how a newer version doesn't work.. but okay)

    EDIT, FOUND ANSWER

    Someone from NI-VISTA told me to just add "true" as a second parameter:

    myDmm.WriteString("*RST",true); // reset the device
    myDmm.WriteString("*IDN?",true); // request the IDN string;
    string IDN = myDmm.ReadString(); // now it works.
    

    I'm not sure why "true" wasn't needed in 2012, and why it is needed in 2015... oh well.