Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

where is documentation for VisaNS

I'm trying to do serial I/O with NI-VISA through the .NET interface (VisaNS) using Visual Studio and C#.

 

Where is there any documentation for the various methods/fields/etc exposed in this interface?  I can use the VS object browser to see the method signatures and a summary of the method, but it's rather cryptic and doesn't provide any general info on using the NI-VISA .NET interface.

 

I have installed NI-VISA on my development system, as well as the NI serial driver, and the VisaNS .NET interface of course.

 

There are so many layers here that the whenever something isn't quite right, it's very difficult to get any traction on isolating a problem.

0 Kudos
Message 1 of 8
(4,429 Views)

Hey Menchar -

 

You can find the documentation for the NI-VISA .NET libraries through the Visual Studio help collection.  To get to the reference material, go to Help»Contents»NI Measurement Studio Help»Developing Measurement Studio Projects»Reference»NationalInstruments.VisaNS Namespace.

 

There is also some general overview help available at Help»Contents»NI Measurement Studio Help»Developing Measurement Studio Projects»Using the Measurement Studio .NET Class Libraries»Using the Measurement Studio VisaNS .NET Library.

 

Let me know if you continue to have trouble finding the documentation.

 

NickB

National Instruments

0 Kudos
Message 2 of 8
(4,357 Views)

Nick -

 

Thanks, that helped.  I'll drill through this and see if I can find out what I need.

 

What I'm looking for is definition of what happens if I do a synchronous read on a serial port with no termination character enabled - I would think the read might go on until timeout, or until input buffer is full, and then signal that somehow.  But I don't see this described anywhere. I suspect an exception is thrown, but the documentation refers to "Visa driver exception" and I guess we're supposed to figure out what those are on our own somehow - or run an experiment - is the driver "the NI-VISA driver" or is it an underlying serial driver, or is it a .NET driver, or is it an Windows OS driver?  All of the layers are trying to abstract away detail to the point that it's wonderful if it works and a PITA if it doesn't and you have to debug through all of these layers.

 

Can NI-Spy be used to capture calls to the NI serial driver?  I've only ever used it for GPIB.  I see where will capture NI-VISA calls, so at least I should be able to log at the NI-VISA layer, though there's quite a bit underneath it it seems.

 

 

 

0 Kudos
Message 3 of 8
(4,353 Views)

Hi menchar,

 

If you are using VISA commands, NI-Spy will capture the VISA calls and not the NI-Serial calls.  The information from the VISA calls do have valuable information.  You will be able to see the input and output parameters as well as the buffer contents.

 

For a VISA read that times out, you would see something like:

 

NI-Spy.JPG

 

This tutorial is worth reading for some good information on termination characters.

 

Regards,

 

Brandon V.

Applications Engineering

National Instruments

www.ni.com/support

 

 

 

 

0 Kudos
Message 4 of 8
(4,341 Views)

 

Thanks to both of you.

 

What I'm doing is trying to read a string until timeout from a serial port, with no read termination character, but I get an VisaNS generated exception and no data!  In other words, if the read times out, an exception gets thrown and no data is available (even though the string was in fact read prior to the timeout).

 

So I wind up having to use the termination character, then keep reading  until a timeout, and then swallow the exception.

 

My original problem was seeing what looked like a low - level race condition on the read - the source device can issue two messages one after the other, each terminated with a crg rtn. 

 

E.g.    FPA1\r\nFPA1 0x123456789abcdef\r\n

 

We were using an expression like this:

 

 

                string reply = string.Empty;
                try  {
                    do {
                        reply += _visaInstrument.Read();
                    }
                    while (true);
                }
                // assume it was a timeout, ignore ...
                catch { }

 

where a second read is getting set on the port immediately after the first read terminates.

 

We sometimes see what looks like an inqueue pointer glitch, with one of the characters getting doubled up towrds the start of the second string.  It looks to me like maybe some low level code is trying to recover from the termination of the first read and gets caught by the second read before it cleans up.

 

We're running as a 64 bit app on Win7 on a fast, 8 core PC with a lot of memory, so there's true concurrency at a low level if any of the serial sw is multi-threaded (our app is single threaded at the point the serial read is performed).

 

I've added a delay between the reads, and put a retry mechanism in place as well, but I'm curious if you have any reports of such a race in the NI .NET serial SW.  I know the CVI serial library and/or the NI Serial driver had a race condition in it at one point a couple years ago, as I recall it was assoiciated with clearing the inqueue and doing a read immediatley afterwards.

 

Thanks again for your help.

 


0 Kudos
Message 5 of 8
(4,337 Views)

I should add that I'm reading a "virtual" com port rather than a true com port.

 

The virtual com port is provided by DALSA Framegrabber software to allow access to the serial comman channel that's built into the CameraLink specification.

 

So, this problem could be in the DALSA SW I imagine.

0 Kudos
Message 6 of 8
(4,322 Views)

Hi menchar,

 

Have you tried setting the VisaNS.SerialTerminationMethod to none to see if that will give you the data without needing a termination character?

 

Regards,

 

Brandon V.

Applications Engineering

National Instruments

www.ni.com/support

 

 

0 Kudos
Message 7 of 8
(4,310 Views)

Brandon -

 

I did indeed, what I get is an exception and no data on the read.

 

I couldn't nail down the exception type because the application couldn't find the VisaNS DLL.  I did build the app with a reference to the VisaNS DLL, and it builds without error, but at runtime when I try to invoke the exception.Message() method, the runtime system can't find the VisaNS DLL to execute the method.

 

I don't think this failure to dynamically link to the VisaNS DLL has anything to do with NI SW, it's likely a deployment issue on my part.

 

So for the time being I just swallow the exception and continue - we're assuming the exception is for a timeout, and we use the termination character to terminate the reads.

 

But, swallowing exceptions like that is asking for trouble.

 

I put a retry in place, so even if the problem recurrs we'll likely get past it.

 

Menchar

0 Kudos
Message 8 of 8
(4,302 Views)