Serial data throughput via QBluetooth issues
-
Hi,
I'm having issues receiving data from a device via bluetooth on Linux (Ubuntu 20.04.2). The device has both serial and bluetooth functionality and is sending data at 921600 baud on the serial bus. There are no issues reading the data from /dev/ttyUSB0 using QtSerialPort via the readyRead() Signal. I receive data packets (31 bytes custom protocol) at exactly 1kHz. Among the data is a counter which increases by 1 for each packet sent.
However, when the connection is established via bluetooth I seem to be missing several packets (even in the lower 100s) at a time (number of missed consecutive counts) resulting in an average rate of ~500Hz. These "gaps" appear irregularly and independent of the distance between the receiver and the device (within a reasonable range). Using a proprietary Windows software with the same receiver in the same conditions does not have these issues.
When I establish the connection externally via BlueZ (5.53-0ubuntu3.3)rfcomm -E -S connect /dev/rfcomm0 $DEVICE_MAC
I can use QtSerialPort on /dev/rfcomm0 instead of /dev/ttyUSB0 and the issues seem to be a lot better, only dropping exactly 2 packets at a time at irregular intervals. This is still not ideal but a lot better.
So, the question is, what does QBluetooth do differently and are there any parameters which I could set for QBluetoothSocket, QBluetoothLocalDevice, etc.? Qt is version is 5.12.8-0ubuntu1 -
This post is deleted!
-
Hi,
I'm having issues receiving data from a device via bluetooth on Linux (Ubuntu 20.04.2). The device has both serial and bluetooth functionality and is sending data at 921600 baud on the serial bus. There are no issues reading the data from /dev/ttyUSB0 using QtSerialPort via the readyRead() Signal. I receive data packets (31 bytes custom protocol) at exactly 1kHz. Among the data is a counter which increases by 1 for each packet sent.
However, when the connection is established via bluetooth I seem to be missing several packets (even in the lower 100s) at a time (number of missed consecutive counts) resulting in an average rate of ~500Hz. These "gaps" appear irregularly and independent of the distance between the receiver and the device (within a reasonable range). Using a proprietary Windows software with the same receiver in the same conditions does not have these issues.
When I establish the connection externally via BlueZ (5.53-0ubuntu3.3)rfcomm -E -S connect /dev/rfcomm0 $DEVICE_MAC
I can use QtSerialPort on /dev/rfcomm0 instead of /dev/ttyUSB0 and the issues seem to be a lot better, only dropping exactly 2 packets at a time at irregular intervals. This is still not ideal but a lot better.
So, the question is, what does QBluetooth do differently and are there any parameters which I could set for QBluetoothSocket, QBluetoothLocalDevice, etc.? Qt is version is 5.12.8-0ubuntu1 -
@ocgltd Not exactly. I tried 5 Bluetooth adapters of which 2 worked as expected (no dropped packets) using rfcomm. IIRC the QBluetooth connection worked correctly only if the application doesn't scan for the device, but instead uses a hard-coded/argument provided MAC address. I haven't looked into the issue since then so I can't verify it on newer Qt versions.