LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

.net ip address

Hello,

 

I am calling a .net dll driver.  There is a variable defined as "System_Net_IPAddress IPAddr" in the .h file.  I need to assign an IP address (e.g. 192.168.5.1) to the variable IPAddr.  I am stuck how to do this.

 

I asked the .net dll author.  He said IPAddress is a native type to .net.  He uses 

new IPAddress(new byte[] { 192, 168, 5, 1 }) or 

IPAddress address = IPAddress.Parse(“192.168.5.1”) to do the assignment.  But how to do this in CVI?  Should I use CDotNetCreateArray and CDotNetSetArrayElements functions?  Is there an example available?

 

Thanks a lot!

JZ

0 Kudos
Message 1 of 6
(2,660 Views)

Hi jzhu0000,

 

LabWindows/CVI is strictly an ANSI C development environment. Is there a reason that you are using a .NET assembly with this IDE?

 

There is a way to call .NET assemblies from CVI. Follow this link to find examples:

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvidotnet_sample_code/

0 Kudos
Message 2 of 6
(2,603 Views)

Hi mfaltin,

 

Thanks for your reply.  The .net dll is a device driver that our main application written in LabWindows needs to call the device.  No problem calling other functions in the .net dll package.  Only this System_Net_IPAddress conversion.  I will read the link more closely.  But it doesn't look straightforward.

0 Kudos
Message 3 of 6
(2,599 Views)

hello, please have you found a solution?

0 Kudos
Message 4 of 6
(756 Views)

Not sure about earlier versions but in LabWindows/CVI 2020 you have a .Net Instrument driver in samples\dotnet\SystemWrapper.fp

 

If you add that to your project you have 3 specific functions in there:

 

System_Net_IPAddress__Create()

System_Net_IPAddress__Create_1()

System_Net_IPAddress__Create_2()

 

You probably want to use the _2 variant, unless you need also IPv6 scopeID.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 6
(700 Views)

And if you want to create an IPAddress from a string, you would use the System_Net_IPAddress_Parse() function.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(693 Views)