LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CVI to connect via TCP/IP

Solved!
Go to solution

Hello,

 

Environment Info:

 

  • TestStand 2017
  • CVI 2016
  • Windows 10

 

I need to connect to a system that uses TCP/IP over ethernet to send and receive data. The system uses its own proprietary packet format. It uses a simple server/client model, where it is the server and I am the client. Before I start developing data structures to send/recieve data, I need a way to connect to that system. I have the destination IP address and port number. I was looking at using CVIs in-built "TCP Support Library" I was planning to build a DLL using that library that I can call from TestStand. Alternatively, an option is to call VISA32.dll from Windows and use the viopen() viread() and viwrite() functions. 

 

Does anyone have some suggestions of the best approach. Before I get to read/write, I just want to know how to connect to the server. CVI has the in-built function ConnectToTCPServerEx. One of the parameters for this function is "server host name." I'm not sure what to provide for that... why isn't there simply a parameter for IP address? As I mentioned, I just have the IP address and port number of the server.

 

Thank you

Message 1 of 5
(3,601 Views)
Solution
Accepted by topic author TestEngineer11

Well, actually there is!

 

As you can see in the help for the function,

serverHostName const char [] The name of the host machine for the server.

The name can either be an alphabetical string, such as xyz.natinst.com, or a numerical string, such as 123.456.7.8.

 

In my opinion you should begin trying to connect to your instrument using the TCP library, which is simpler than VISA and does not rely on external libraries to be installed separately in your target.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 5
(3,527 Views)

Thanks Roberto,

 

I am trying to build a solution that would allow me to talk to the UUT via TCP/IP. The UUT would be the server and my TestStand/CVI application would be the client. Per your suggestion I am planning to use the CVI in-built TCP library, but I want to be able to expose these functions in a DLL (that I can call from TestStand). It seems that the main functions (connect, read, write, disconnect) are defined in tcpsupp.h. What is the best way to expose these for export? I tried to list the prototypes in my header file for export, but it doesn't like that because tcpsupp.h has already defined them. I also have an internally defined callback function in my DLL which handles asyncronous data transfers. I modeled it after the example code for TCP, the fucntion CVICALLBACK ClientTCPCB. 

 

I am trying to deal with the fact that the UUT sends data back immediately after a command is sent (in most cases) and I want to make sure I capture that data. 

0 Kudos
Message 3 of 5
(3,503 Views)
Solution
Accepted by topic author TestEngineer11

I'm not using TestStand in my activity so I I don't know how to export functions from the library. I can only suggest that you create wrappers fro the functions you need and export them instead.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 5
(3,471 Views)

Thanks, Roberto. I looked at a similar example from a colleague and he did exactly the same thing you suggested, created wrapper functions. 

0 Kudos
Message 5 of 5
(3,464 Views)