Reference Design Content

Showing results for 
Search instead for 
Did you mean: 

LabWindows/CVI Example for Client Implementation of the Simple Messaging (STM) Library



The attached example contains an implementation of STM in LabWindows/CVI and examples of its use.




  • This code requires the Simple Messaging Library (STM)
  • The LabVIEW example code included in the attached example requires LabVIEW version 8.6 or higher.

The C code was written in LabWindows/CVI 9.0.  Much of the code can be converted to other LabWindows/CVI versions with minimal effort.




The zip file contains the following:


CVI Folder


This folder contains the LabWindows/CVI STM implementation as well as an example of its use.  The following files are significant:


CVI\_STM_libraries Folder


STM_Comm.h and STM_Comm.c

These files implement the main STM communication.  This is directly used to connect to the server / client, disconnect from the server / client, and send / receive messages.  Additionally, the functions in these files allow you to receive notification of a successful connection, the loss of a connection, the receipt of meta data, the receipt of any data on the STM socket, the receipt of an STM message, a successfully transmitted message and/or a connection error.  


STM_Convert.h and STM_Convert.c

These files provide a number of functions which help you to encode and decode data into a format acceptable by LabVIEW.  This is called flattening and unflattening.  Note that not all possible data types are implemented. If you need a data type that isn't available, use the provided functions as a guide and the refer to Flattened Data for the data format.


CVI\Server and CVI\Client Folder


STM Server Example.h, STM Server Example.c, and STM Server Example.uir

These files implement an example of using the LabWindows / CVI STM libraries to run an STM server and accept connections from an STM client.


STM Client Example.h, STM Client Example.c, and STM for CVI client.uir

These files implement an example of using the LabWindows/CVI STM libraries to create an STM client that connects to an STM server.


LabVIEW Folder

This folder contains LabVIEW VIs that implement the same functionality as the CVI Client and Server examples.
This code requires the Simple Messaging Reference Library (STM) to open.  This example is a good test for the LabWindows/CVI implementation as it uses multiple data types and arrays in its STM messages.




Please submit your feedback and questions on this example in the STM discussion forum. General product support questions should be directed to NI Technical Support.

authored by
Christian L, CLA
Applications Engineering Senior Manager - Automotive and Transportation
NI - Austin, TX