Switch Hardware and Software

cancel
Showing results for 
Search instead for 
Did you mean: 

CanConnect From .NET Wrapper Never True?

Solved!
Go to solution

I am using he .NET wrapper for niSwitch. In it is a function called "CanConnect", which should verify if a path is possible and/or exists between two channels. However, when I use it to test if a path is indeed available, I get a "0" returned no matter what. My understanding is that I should call it, and send three arguments: the first channel, the second channel, and the condition I'd like to check (integer values 1-6 correspond to the 6 possible conditions).

 

But when I call it like so:

Const PATH_DOES_EXIST = 1

 

result = niSwitch.CanConnect(CH2, COM2, PATH_DOES_EXIST)

 

I get a zero returned whether channel 2 is actually closed or not, as verified by the Soft Panel. 

 

What am I doing wrong?

0 Kudos
Message 1 of 3
(4,951 Views)
Solution
Accepted by topic author jvavra

jvavra,

 

niSwitch.CanConnect will return an error code. An error code of 0 means that no errors occurred :).

 

I would reference the C API Help if you are looking for info on using the .NET API (it should be nearly the same).

 

http://zone.ni.com/reference/en-XX/help/375472C-01/switchcref/c_nisw_canconnect/

 

The third argument should actually be a variable. Calling that function will update the variable's value with the current status of that path between the two channels. You can later check if the Variable's value == PATH_DOES_EXIST.

 

Cheers!

Frank,
National Instruments
Software Group Manager
Message 2 of 3
(4,940 Views)

Frank,

Thanks, that did it. Just needed to pass in a "Status" variable which I then read after.

0 Kudos
Message 3 of 3
(4,932 Views)