Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

C++ Qt XpressNET library

This repository contains a fully open-source C++ library for communicating with XpressNET DCC Command Station.

It connects to the (virtual) serial port, which is typically served by LI.

Currently, it implements basic commands of XpressNET v3.0 protocol as well as some advanced commands of XpressNET v3.6).

See xn.h: class XpressNET for list of supported commands.


You may use this library in two major ways:

Dynamic library

You can download precompiled dll version of this library in Releases section.

Since v2.0 release, this library is distributed as trakce-xn.dll file. This library is developed in Qt framework, thus some more dll are required on your computer for trakce-xn.dll to work. These libraries are available in Relaeses in zips trakce-xn-required-libs-*.zip. Use min variant by default, this should be enough. If your computer complains about unmet dependencies, use all variant.

Dynamic-library-api specification is located on wiki.

Static library

Simply include header files listed in into your project and use instance of XpressNet class (see xn.h).

Add .cpp and .h files from to is not used in your project. You just include header files as in plain C.

This library uses Qt's SerialPort which creates a very good cross-platform abstraction of serial port interface. Thus, the library uses Qt's mechanisms like slots and signals.

When library is used as static library, it is not usable without Qt.

Basic information

  • This library uses 28 speed steps only. It simplifies things a lot. Other speed steps could be added in future.
  • To change the version of this library, update both constants at file and xn.h file. This is needed for proper behavior as a dynamic and static library too.

Project structure

  • xn*{.cpp,.h} files contain low-level implementations of XpressNET library. Only these files are needed for static-library use.
    • See xn.h for static API specification.
  • lib-*{.cpp,.h} files contain implementations of dynamic-library API. These files use xn*{.cpp,.h} files.
    • See lib-main.h for dynamic API specification.


This library has been tested with:

  • uLI
  • Lenz LI-USB-Ethernet
  • NanoX's LI

It should support all LI100-like or LI101-like interfaces. It also supports newer interfaces which add 0xFF 0xFE to the header of each packet. User chooses which version of protocol the library should use.

Building & toolkit

This SW was developed in vim using qmake & make. Downloads are available in Releases section. It is suggested to use clang as a compiler, because then you may use clang-tools during development process (see below).


  • Qt 5
  • Qt's serialport
  • Optional: clang build tools (see below)
  • Optional for clang: Bear

Example: toolchain setup on Debian

$ apt install qt5-default libqt5serialport5-dev
$ apt install clang-7 clang-tools-7 clang-tidy-7 clang-format-7
$ apt install bear


Clone this repository:

$ git clone

And then build:

$ mkdir build
$ cd build
$ qmake -spec linux-clang ..
$ bear make

Cross-compiling for Windows

This library could be cross-compiled for Windows dll via MXE. Follow these instructions for building standalone dll file.

You may want to use activation script:

export PATH="$HOME/...../mxe/usr/bin:$PATH"
~/...../mxe/usr/i686-w64-mingw32.static/qt5/bin/qmake ..

MXE must be compiled with qtserialport:

make qtbase qtserialport

Style checking

$ clang-tidy-7 -p build -extra-arg-before=-x -extra-arg-before=c++ -extra-arg=-std=c++14 -header-filter=. *.cpp
$ clang-format-7 *.cpp *.h


This library was created by:

Do not hesitate to contact author in case of any troubles!


This application is released under the Apache License v2.0 .