Getting Started with NI-XNET C API
- Updated2023-11-02
- 3 minute(s) read
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 View and make sure that Library Tree is selected. In the Library Tree, expand Libraries and scroll down to 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 toYou 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.
#include "nixnet.h"
/I "$(NIEXTCCOMPILERSUPP)include"
/libpath:"$(NIEXTCCOMPILERSUPP)\lib32\msvc"
The reference for each NI-XNET API function is in NI-XNET API for C Reference.
#include "nxsocket.h"
/I "$(NIEXTCCOMPILERSUPP)include"
/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.