Getting Started with NI-XNET C API

This section helps you get started using NI-XNET for C. It includes basic information about using LabWindows/CVI and Microsoft Visual C, and C examples.

LabWindows/CVI

To view the NI-XNET function panels, select Library»NI-XNET. This opens a dialog containing the NI-XNET classes. You also can use the Library Tree to access all the function panels quickly. To use the NI-XNET Library Tree, go to View and make sure that Library Tree is selected. In the Library Tree, expand Libraries and scroll down to NI-XNET.

You can access the help for each class or function panel by right-clicking the function panel and selecting Class Help... or Function Help....

NI-XNET includes LabWindows/CVI examples that demonstrate a wide variety of use cases. The examples build on the basic concepts to demonstrate more in-depth use cases.

To view the NI-XNET examples, select Find Examples... from the LabWindows/CVI Help menu. When you browse examples by task, NI-XNET examples are under Hardware Input and Output. The examples are grouped by protocol in CAN, FlexRay, and LIN folders. Although you can write NI-XNET applications for either protocol, and each folder contains shared examples, this organization helps you find examples for your specific hardware product.

Open an example project by double-clicking its name. To run the example, select values using the front panel controls, then read the instructions on the front panel to run the examples. Suggested examples to get started with NI-XNET include:

CAN (Hardware Input and Output»CAN»NI-XNET»Basic):

  • CAN Signal Input Single Point with CAN Signal Output Single Point
  • CAN Signal Input Waveform with CAN Signal Output Waveform
  • CAN Frame Input Stream with any output example.

FlexRay (Hardware Input and Output»FlexRay»Basic):

  • FlexRay Signal Input Single Point with FlexRay Signal Output Single Point.
  • FlexRay Signal Input Waveform with FlexRay Signal Output Waveform.
  • FlexRay Frame Input Stream with any output example.

LIN (Hardware Input and Output»LIN»NI-XNET»Basic):

  • LIN Signal Input Single Point with LIN Signal Output Single Point
  • LIN Signal Input Waveform with LIN Signal Output Waveform
  • LIN Frame Input Stream with any output example

Visual C++

Refer to the Microsoft Visual Studio Support section in the NI-XNET readme file for the versions of Microsoft Visual C/C++ that your NI-XNET software supports.

The NIEXTCCOMPILERSUPP environment variable is provided as an alias to the C language header file and library location. You can use this variable when compiling and linking an application.

For compiling applications that use the NI-XNET API, you must include the nixnet.h header file in the code.

For C applications (files with a .c extension), include the header file by adding a #include to the beginning of the code, such as:
#include "nixnet.h"
In your project options for compiling, you must include this statement to add a search directory to find the header file:
/I "$(NIEXTCCOMPILERSUPP)include"
For linking applications, you must add the nixnet.lib file and the following statement to your linker project options to search for the library:
/libpath:"$(NIEXTCCOMPILERSUPP)\lib32\msvc"

The reference for each NI-XNET API function is in NI-XNET API for C Reference.

For compiling applications that use the Automotive Ethernet Socket API for C, you must include the nxsocket.h header file in the code. To include the header file, add #include to the beginning of the code. For example:
    #include "nxsocket.h"
   
In your project options for compiling, you must include the following statement to add a search directory to find the header file:
    /I "$(NIEXTCCOMPILERSUPP)include"
   
For linking applications, you must add the nixntipstack.lib file and the following statement to your linker project options to search for the library (for a 32-bit OS, replace lib64 with lib32):
    /libpath:"$(NIEXTCCOMPILERSUPP)\lib64\msvc"
   

The reference for each NI-XNET IP Stack API function is in IP Stack Functions. The reference for each NI-XNET Socket API function is in Socket Functions, and each socket option is referenced in Socket Options.