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:
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.
Simply include header files listed in xn.pro
into your project and use
instance of XpressNet
class (see xn.h
).
Add .cpp
and .h
files from xn.pro
to yourproject.pro
. xn.pro
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.
- 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
xn.pro
file andxn.h
file. This is needed for proper behavior as a dynamic and static library too.
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.
- See
lib-*{.cpp,.h}
files contain implementations of dynamic-library API. These files usexn*{.cpp,.h}
files.- See
lib-main.h
for dynamic API specification.
- See
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.
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
$ 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 https://github.com/kmzbrnoI/xn-lib-cpp-qt
And then build:
$ mkdir build
$ cd build
$ qmake -spec linux-clang ..
$ bear make
Just open the project in Qt Creator and compile it. This approach is currently used to build windows binaries in releases.
$ 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:
- Jan Horacek (jan.horacek@kmz-brno.cz)
Do not hesitate to contact author in case of any troubles!
This application is released under the Apache License v2.0 .