Changeset b409e9f in subsurface


Ignore:
Timestamp:
Jul 11, 2017, 4:29:41 AM (13 days ago)
Author:
Jan Mulder <jlmulder@…>
Branches:
master
Children:
8911281
Parents:
b7057c4
Message:

BLE read: remove aggressive read

Commit 709c1df2af4b87 introduced a hard blocking read for BLE devices.
This did break BLE reads from multiple DCs, and (in hindsight) was not
a correct implementation. It would require, for example, dynamic
read buffers as especially profile data grows with dive time, and
in addition, and more importantly, also the OSTC libdc parser cannot
process the entire profile of a dive at once (but likes to receive
it in 1K blocks). So, basically, it introduced issues, and did not
solve the OSTC read.

This commit reverts this hard blocking read (and as such will break
OSTC BLE reads). But it enables removal of the special cases for
the EON Steel and G2.

A next commit will solve OSTC BLE reads.

Signed-off-by: Jan Mulder <jlmulder@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/qt-ble.cpp

    rb7057c4 rb409e9f  
    2828#define IS_HW(_d) same_string((_d)->vendor, "Heinrichs Weikamp")
    2929#define IS_SHEARWATER(_d) same_string((_d)->vendor, "Shearwater")
    30 #define IS_EON_STEEL(_d) same_string((_d)->product, "EON Steel")
    31 #define IS_G2(_d) same_string((_d)->product, "G2")
    3230
    3331#define MAXIMAL_HW_CREDIT       255
     
    190188                return DC_STATUS_IO;
    191189
    192         int offset = 0;
    193         while (!receivedPackets.isEmpty()) {
    194                 /*
    195                  * Yes, two while loops with same condition seems strange. The inner one
    196                  * does the real work, but it prevents the QtEventloop to do its thing.
    197                  * As the incoming packets arrive based on signals and slots, that
    198                  * stuff is not handeled during the inner loop. So, add a short waitFor
    199                  * between the inner and outer while loop.
    200                  */
    201                 while (!receivedPackets.isEmpty()) {
    202                         QByteArray packet = receivedPackets.takeFirst();
    203 
    204                         if (IS_SHEARWATER(device))
    205                                 packet.remove(0,2);
    206 
    207                         //qDebug() << ".. read (packet.length, contents, size)" << packet.size() << packet.toHex() << size;
    208 
    209                         if ((offset + packet.size()) > size) {
    210                                 qDebug() << "BLE read trouble, receive buffer too small";
    211                                 return DC_STATUS_NOMEMORY;
    212                         }
    213 
    214                         memcpy((char *)data + offset, packet.data(), packet.size());
    215                         offset += packet.size();
    216                         *actual += packet.size();
    217                         // EON Steel wants to read only one packet at a time
    218                         if (IS_EON_STEEL(device) || IS_G2(device))
    219                                 goto we_are_done;
    220                 }
    221                 waitFor(50); // and process some Qt events to see if there is more data coming in.
    222         }
    223 we_are_done:
     190        QByteArray packet = receivedPackets.takeFirst();
     191
     192        if (IS_SHEARWATER(device))
     193                packet.remove(0,2);
     194
     195        if (packet.size() > size)
     196                return DC_STATUS_NOMEMORY;
     197
     198        memcpy((char *)data, packet.data(), packet.size());
     199        *actual += packet.size();
     200
    224201        return DC_STATUS_SUCCESS;
    225202}
Note: See TracChangeset for help on using the changeset viewer.