MTB daemon is a simple console computer application intended to be run as a service. It features 2 interfaces:
- MTB-USB v4 connection via USB CDC
- json tcp server
Aim of this daemon is
- to allow multiple applications to control single MTBbus
- to provide nice communication API with MTBbus.
JSON server features API for setting MTBbus modules state, getting MTBbus modules state as well as configuring modules, changing MTBbus speed etc.
When program starts, configuration file mtb-daemon.json
is read. If the file
does not exists, it is created. JSON server is started. When server cannot be
started, program dies. Main application loop is started.
Daemon searches for available MTB-USB modules. If it finds module specified in configuration, it connects. It reports changes to clients and allows clients to control MTBbus and MTBbus modules. When connection with MTB-USB fails, daemon reports this event to clients and keeps running. When MTB-USB is available again, connection is established again.
Just start the console application and let it run as a daemon on background.
$ ./mtb-daemon [config-filename]
The program takes a single optional argument – path to main configuration file
(default: ./mtb-daemon.json
).
See Description of mtb-daemon.json file.
This library was developed in vim
using qmake
& make
. It is suggested
to use clang
as a compiler, because then you may use clang-tools
(see below).
- Qt 5/6
- Qt's
serialport
- Bear
$ apt install qt6-base-dev qt6-serialport-dev
$ apt install bear
$ apt install clang clang-tools clang-tidy clang-format
Clone this repository:
$ git clone https://github.com/kmzbrnoI/mtb-daemon
And then build:
$ mkdir build
$ cd build
$ qmake -spec linux-clang ..
$ # qmake CONFIG+=debug -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.
This repository contains tests for MTB Daemon. See
README in test
directory.
$ clang-tidy -p build src/*.cpp
$ clang-format <all .cpp and .h files in the 'src' directory>
$ clang-include-fixer -p build src/*.cpp
For clang-include-fixer
to work, it is necessary to build yaml
symbols
database.
You can do it this way:
- Download
run-find-all-symbols.py
from github repo. - Execute it in
build
directory.
This library was created by:
- Jan Horacek ([email protected])
Do not hesitate to contact author in case of any troubles!
This application is released under the Apache License v2.0 .