To download NI software, including the products shown below, visit ni.com/downloads.
This example provides custom step types that allow you to utilize TCP client side communication directly from TestStand.
TCP is a client-server protocol widely used to exchange data over the network or internet. Many National Instruments products provide TCP communication capabilities, including LabVIEW, LabWindows/CVI, and Measurement Studio.
The TCP step types are an example of custom steps that integrate TestStand with TCP communication. This example provides a set of custom step types that you may insert into TestStand sequences to perform basic TCP client operations (Connect, Read, Write, and Disconnect) without the need for external code modules. The image below shows these steps types in use in a TestStand sequence.
The Step types use a DLL developed in CVI to implement this functionality. The source files used to create this DLL is included with this example. If you need to perform more sophisticated TCP tasks, you can use the TCP/IP built-in functions available in LabVIEW or LabWindows/CVI to develop your required code.
TCP Custom Step_NIVerified.zip
TestStand 4.1.1 or Compatible
TCP Custom Step Legacy_NIVerified.zip
TestStand 4.1 and Previous
TCP Custom Step - TS 2017.zip
TestStand 2017 or compatible
CVI 2013 SP2 or compatible (to edit and build the source code).
TCP Custom Step_NIVerified.zip
TCP Custom Step Legacy_NIVerified.zip
After installing the step types, you will see a new folder in the insertion palette, containing four new step types:
Note: To use the step types, you must have an active TCP server application to connect to. If you do not have a TCP server application, use the TCP_server_example.exe server, located in the TCP Custom Step_NIVerified.zip attachment.
To see how the steps function, open the example sequence file, TCP Step Types Example.seq, and complete the following steps:
TCP Connect Step
This step opens a connection to a TCP server. The following parameters can be configured by right clicking the step, then selecting Edit TCPConnect.
TCP Write Step
This step writes string data to the TCP server. The following parameters can be configured by right clicking the step, then selecting Edit TCPWrite:
TCP Read Step
This step waits for the TCP server to send a message. The following parameters can be configured by right clicking the step, then selecting Edit TCPRead:
TCP Disconnect Step
Closes a connection to a TCP Server. The following parameters can be configured by right clicking the step, then selecting Edit TCPDisconnect.
The step types in this example demonstrate many of the recommended methods for custom step type development. For more information on custom step type best practices, refer to the Best Practices for Custom Step Type Development document (part of the NI TestStand Advanced Architecture Series).
Configuration of step instances
Since the TCP step types require a number of user-configured parameters, each type has custom properties to store step related data. For example, the TCP Write step type contains the Step.Result.Data property to store the data to write. In addition, each of the step types implements an edit substep, making it easy for a user to configure the custom step properties from a dialog box. The dialog box is implemented in a DLL, which uses the TestStand API to set the TestStand properties based on the user's configuration.
Run-Time functionality
The actual TCP functionality is implemented using pre-step substeps, defined in the step type. This approach is recommended because step instances will update if you modify the substep code module. The alternate approach of using a custom default module for a step type does not have this feature.
Notifying TestStand of configuration changes
When using the TCP steps, you will notice that the sequence file will indicate that a change has been made (by displaying a "*" after the file name) if you change the properties of a custom step. In order for this behavior to occur, it is necessary to call the IncChangeCount method on the sequence file to notify TestStand that the sequence file has changed:
tsErrChk(TS_SeqFileIncChangeCount (hSeqFile, NULL));
It is important to call this method if the sequence file is modified outside of the TestStand User Interface.
TestStand Help: Best Practices for Custom Step Type Development
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hi Mark,
Is there a chance that you have a 64Bit version of the TCPSteps.dll?
Buggy.
The function "TCPRead" returns more bytes than was sent by "TCP_server_example.exe".
e.g. Server sends "AAA", but TestStand 2017 received some extra random content.
Is there a chance that you have a 64Bit version of the TCPSteps.dll? Thank you