简体   繁体   中英

SegemtationError with QT 5.7 and Bluez 5.47 ConnectDevice

I'm trying to get the following git running https://github.com/com2m/anki-overdrive-goes-iot/blob/master/Documentation.md#bluez5.42

when building it i encountered an error which seemed to be a bug in gcc 7. I followed Compile error when running make after Qmake to get it compiled.

Afterwards i encountered an Segemntationfault when running build/ankioverdrive

Running gdb give me the following information in BT Full

#0  0x00007ffff7931ccb in QLowEnergyController::connectToDevice() () from /usr/lib/x86_64-linux-gnu/libQt5Bluetooth.so.5
No symbol table info available.
#1  0x00005555555718cc in AnkiCar::reconnect (this=0x5555557a82d0) at src/ankicar.cpp:444
No locals.
#2  0x00005555555654b3 in DriveMode::requestBatteryUpdate (this=0x5555557a6400) at src/drivemode.cpp:102
        racecar = 0x5555557a82d0
        _container_ = {c = {<QListSpecialMethods<Racecar*>> = {<No data fields>}, {p = {static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
                          _M_i = -1}, <No data fields>}}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x5555557a85a0}, d = 0x5555557a85a0}}, i = {i = 0x5555557a85b8}, e = {i = 0x5555557a85d0}, 
          control = 1}
#3  0x00005555555768df in DriveMode::qt_static_metacall (_o=0x5555557a6400, _c=QMetaObject::InvokeMetaMethod, _id=8, _a=0x7fffffffdf20) at moc_drivemode.cpp:156
        _t = 0x5555557a6400
#4  0x00007ffff745f5b5 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#5  0x00007ffff746c027 in QTimer::timeout(QTimer::QPrivateSignal) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#6  0x00007ffff746c388 in QTimer::timerEvent(QTimerEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#7  0x00007ffff74600db in QObject::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#8  0x00007ffff7430991 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#9  0x00007ffff7488d8e in QTimerInfoList::activateTimers() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#10 0x00007ffff7489551 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#11 0x00007ffff5002287 in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#12 0x00007ffff50024c0 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#13 0x00007ffff500254c in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#14 0x00007ffff74898ef in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#15 0x00007ffff742e9ea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#16 0x00007ffff7437a84 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#17 0x000055555555b42e in main (argc=1, argv=0x7fffffffe468) at src/main.cpp:29
        a = <incomplete type>

I figured this to be a problem with bluez. I'm running bluez 5.47 and while making i made sure that configuration allowed experimental mode by running

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --enable-maintainer-mode

and changed the /lib/systemd/system/bluetooth.service

and i made sure that my bluetooth is running by calling

sudo hciconfig hci0 up

with my blootooth device beeing hci0

but still without any sucess

I'm currenty trying all this on Kubuntu 18.04 as distro.

I'm out of ideas how to fix this.

I've changed ankicar.cpp to check if the Bluetooth controller is currently unconnected before trying to reconnect it:

void AnkiCar::reconnect() {
    if (lowEnergyController != 0) {
        if (lowEnergyController->state() == QLowEnergyController::UnconnectedState)
            lowEnergyController->connectToDevice();
    }
}

With this change the cars get connected and the connection seems stable (even without the --experimental switch as described above).

[E6:45:5A:32:6E:4A]>> CONNECTED.
[E6:45:5A:32:6E:4A]>> SERVICE DISCOVERY FINISHED.
[E6:45:5A:32:6E:4A]>> FOUND ANKI SERVICE.
[E6:45:5A:32:6E:4A]>> SERVICE CHARACTERISTICS DISCOVERED.
[E6:45:5A:32:6E:4A]>> SDK ON.
[E6:45:5A:32:6E:4A]>> DESCRIPTOR SUCCESSFULLY WRITTEN.
[E6:45:5A:32:6E:4A]>> NOT CHARGING, NOT ON TRACK.
[E6:45:5A:32:6E:4A]>> ATTEMPT TO ACCESS GAMEPAD FAILED.
[E6:45:5A:32:6E:4A]>> USING GAMEPAD #1.
[E6:45:5A:32:6E:4A]>> READY.
[E6:45:5A:32:6E:4A]>> NOT CHARGING, ON TRACK.

You need to move the car on the track a litte bit to make it recognize to be ON TRACK . I've installed the following packages to be able to build the project:

pi@raspberrypi:~ $ sudo apt-get install bluetooth bluez blueman
pi@raspberrypi:~ $ sudo apt-get install bluez bluez-firmware       
pi@raspberrypi:~ $ sudo apt-get install pi-bluetooth
pi@raspberrypi:~ $ sudo apt-get install qt5-qmake
pi@raspberrypi:~ $ sudo apt-get install qt5-default
pi@raspberrypi:~ $ sudo apt-get install qtconnectivity5-dev

I also needed to add QMAKE_CFLAGS_ISYSTEM = -I to the project file ankioverdrive.pro (see /usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory #include_next <stdlib.h> )

The QT docs say in http://doc.qt.io/qt-5.6/qlowenergycontroller.html#connectToDevice

void QLowEnergyController::connectToDevice()
// Connects to the remote Bluetooth Low Energy device.

This function does nothing if the controller's state() is not equal to UnconnectedState. The connected() signal is emitted once the connection is successfully established. On Linux/BlueZ systems, it is not possible to connect to the same remote device using two instances of this class. The second call to this function may fail with an error. This limitation may be removed in future releases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM