I wrote a custom plugin for QCanBus
, that simply is a copy of the socketcan plugin but has been renamed and the identifiers have been adjusted to that new name.
I did that copying to first get the plugin recognised before I alter it.
I changed the qmake project to look that way:
TEMPLATE = lib
TARGET = qtcopysocketcanbus
CONFIG += plugin
QT = core serialbus
HEADERS += \
copysocketcanbackend.h
SOURCES += \
main.cpp \
copysocketcanbackend.cpp
DISTFILES = plugin.json
and added the plugin.json
like so:
{
"Key": "copysocketcan"
}
I then renamed everything else from socketcan
to copysocketcan
in the main.cpp
, the copysocketcan.cpp
and the copysocketcan.h
as well.
When I build the project, I get my *.so file which i put into $QT_PLUGIN_PATH/canbus/
on my target.
However, a quick start reveals, that qt only lists the plugins that came with the installation, not my added custom one.
I tried putting QLoggingCategory::setFilterRules(QStringLiteral("qt.canbus* = true"));
as first line in my code and hoped getting more debug output, but I only get the debug output that my own application is producing. No output from the actual QCanBus
.
So my questions are
qt.canbus
? Do I have to build QT with debug config for that?Through a helpful comment, I was able to debug the problems. The commentor suggested to use QT_DEBUG_PLUGINS
to debug the plugin call. That lead to the appearance of an error message, that clearly stated, that the plugin I was trying to load because it was not a plugin and plugin metadata could not be extracted.
A bit of googling after those messages helped.
The answer to question 1 is:
Yes, you apparently have QT to build with debug information, to get the actual log output.
In my case, I configured the framework with --force-debug-info
For the second question, my approach was indeed reasonable, because as answer for question 3 turned out that one has to include the moc
file as soon, as a Q_OBJECT
macro is used within a *.cpp
file and not in a separate header, which is the case for the canbus plugins. You can read more about that here