04-09-2021 01:34 PM
Hello,
Environment Info:
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
Solved! Go to Solution.
04-11-2021 12:01 PM
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.
04-12-2021 11:37 AM
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.
04-13-2021 10:10 AM
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.
04-13-2021 04:42 PM
Thanks, Roberto. I looked at a similar example from a colleague and he did exactly the same thing you suggested, created wrapper functions.