A library for communication with a BiDiB (www.bidib.org) system using a serial connection. The library was developed to be compatible with BiDiB revision 1.27.
The library was initially developed by Nicolas Gross in a student project at the Software Technologies Research Group (SWT) of the University of Bamberg. Its purpose is to provide an implementation of the BiDiB protocol as a basis for controlling a model railway. The railway should later on support teaching of the upcoming course Reactive Systems Design.
bidib_send_sys_reset()
)CMakeLists.txt
according to your installations of the dependencies
(libglib-2.0, libpthread, libyaml and cmocka).cmake <path-to-project-root>
make bidib
to create the shared library libbidib.so
make bidib_static
to create the static library
libbidib_static.a
To run the unit tests, execute make test
. Each unit test can be executed to
display more detailed test results, e.g., ./bidib_config_parser_tests
.
To run the physical tests, execute make
and afterwards ./testsuite
.
See the project-root/test/physical/Readme.md
for further details.
To generate the documentation, execute doxygen doxygen_config.txt
in the
root directory of the project. This will create the directory doc
which
contains the documentation.
To generate the code coverage report, run
cmake -DCMAKE_BUILD_TYPE=Debug <path-to-project-root>
and afterwards make coverage_test
.
To use the library in external applications without needing to specify absolute
include and library paths, the required files can be copied to a directory on
the system's path by running make install
. The copied files are listed in
install_manifest.txt
inside the build directory.
To uninstall the library, run xargs rm < install_manifest.txt
from inside the
build directory.
To run the unit tests, execute make test
from within the build directory.
Each unit test can be executed to display more detailed test results, e.g.,
./bidib_config_parser_tests
.
To run physical tests on a model railway platform, see the readme in project-root/test/physical
Many messages are already handled by the library. The remaining messages are placed either in the message queue or in the error queue. These queues should be checked by the user to react appropriately. Here is an overview on which messages will be put in the respective queues:
For some names/identifiers in the library it's maybe not clear what's meant by them. Here is a short explanation for the most important ones:
For further information have a look at the BiDiB specification.
Use with care, only parts of the functionality was tested on a real system!
The library logs to LOCAL0
, you may have to configure your log daemon
accordingly. On systemd-based distros, journalctl -t swtbahn
should provide
access to the log.
project-root/example/config
project-root/include/bidib.h
)bidib_start_serial(<params>)
or
bidib_start_pointer(<params>)
bidib_read_message()
(Queue capacity: 128 messages)bidib_read_error_message()
(Queue capacity: 128 messages)bidib_send_<message>(<params>)
bidib_set_train_speed(char *train, int speed)
bidib_flush()
bidib_stop()
Calling the functions mentioned in 4. before/while the library is started,
while/after it is stopped or while it is reset (bidib_send_sys_reset()
) is
not allowed and will result in undefined behaviour.
All the public functions of the library are documented in their respective header files,
found in the project-root/include
folder.
A short program illustrating the use of libbidib
can be found in the project-root/example
folder. Moreover, the physical test cases in project-root/test/physical
for SWTbahn
platforms can be consulted for further usage examples.
A log file for a short libbidib
session can be found in project-root/example/syslog_2020_01_10.txt
.
Moreover, annotated startup and shutdown log messages can be found in the wiki.
Once the library is started, you can safely call bidib_read_message()
,
bidib_read_error_message()
, all low level and high level send functions and
bidib_flush()
in a concurrent manner. If you stop the library or reset the
system, you have to ensure that none of these functions are called during the
execution of bidib_stop()
and bidib_send_sys_reset()
.
To summarize:
It's not supported to call ANY library function concurrently with
bidib_start_serial(<params>)
, bidib_start_pointer(<params>)
, bidib_stop()
and bidib_send_sys_reset()
.
The copyright holder for bidib_messages.h
is Wolfgang Kufer and the file is
excluded from the GPL3.0 license. The reason behind this is to prevent others
from defining alternative message numbers, which would lead to incompatible
products. The rest of the library is released under the terms of GPL3.0.