简体   繁体   English

QT 5.7和Bluez 5.47 ConnectDevice的SegemtationError

[英]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 我正在尝试让以下git运行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. 在构建它时,我遇到了一个错误,这似乎是gcc 7中的错误。我在Qmake之后运行make进行编译时,遵循了Compile错误

Afterwards i encountered an Segemntationfault when running build/ankioverdrive 之后我在运行build/ankioverdrive时遇到了build/ankioverdrive

Running gdb give me the following information in BT Full 运行gdb在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. 我认为这是bluez的问题。 I'm running bluez 5.47 and while making i made sure that configuration allowed experimental mode by running 我正在运行bluez 5.47,同时确保通过运行来确保配置允许实验模式

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

and changed the /lib/systemd/system/bluetooth.service 并更改了/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 与我的blootooth设备一起蜂hci0

but still without any sucess 但仍然没有任何成功

I'm currenty trying all this on Kubuntu 18.04 as distro. 我目前正在Kubuntu 18.04上尝试所有这些发行版。

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: 我更改了ankicar.cpp以在尝试重新连接之前检查蓝牙控制器当前是否未连接:

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). 进行此更改后,汽车将建立连接,并且连接似乎稳定(即使没有如上所述的--experimental开关)。

[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 . 您需要在轨道上移动汽车一点点,以使其识别为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> ) 我还需要将QMAKE_CFLAGS_ISYSTEM = -I添加到项目文件ankioverdrive.pro (请参阅/ usr / include / c ++ / 7 / cstdlib:75:15:致命错误:stdlib.h:没有这样的文件或目录#include_next <stdlib。 h>

The QT docs say in http://doc.qt.io/qt-5.6/qlowenergycontroller.html#connectToDevice QT文档在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. 如果控制器的state()不等于UnconnectedState,则此函数不执行任何操作。 The connected() signal is emitted once the connection is successfully established. 成功建立连接后,将发出connected()信号。 On Linux/BlueZ systems, it is not possible to connect to the same remote device using two instances of this class. 在Linux / BlueZ系统上,无法使用此类的两个实例连接到同一远程设备。 The second call to this function may fail with an error. 对该函数的第二次调用可能会因错误而失败。 This limitation may be removed in future releases. 在将来的发行版中可能会删除此限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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