Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/runonphone/symbianutils/trkutils.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    5252
    5353namespace trk {
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
    5473
    5574TrkAppVersion::TrkAppVersion()
     
    7897    extended2TypeSize = 0;
    7998    pid = 0;
     99
    80100    tid = 0;
    81101    codeseg = 0;
    82102    dataseg = 0;
    83103
    84     currentThread = 0;
    85104    libraries.clear();
    86105    trkAppVersion.reset();
     
    144163}
    145164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
    146249// --------------
    147250
     
    189292    const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen);
    190293    for (int i = 0; i < size; ++i) {
    191         //if (i == 5 || i == ba.size() - 2)
    192         //    str += "  ";
    193         int c = byte(ba.at(i));
    194         str += QString("%1 ").arg(c, 2, 16, QChar('0'));
    195         if (i >= 8 && i < ba.size() - 2)
    196             ascii += QChar(c).isPrint() ? QChar(c) : QChar('.');
     294        const int c = byte(ba.at(i));
     295        str += QString::fromAscii("%1 ").arg(c, 2, 16, QChar('0'));
     296        ascii += QChar(c).isPrint() ? QChar(c) : QChar('.');
    197297    }
    198298    if (size != ba.size()) {
    199         str += "...";
    200         ascii += "...";
    201     }
    202     return str + "  " + ascii;
     299        str += ;
     300        ascii += ;
     301    }
     302    return str + + ascii;
    203303}
    204304
     
    277377/* returns 0 if array doesn't represent a result,
    278378otherwise returns the length of the result data */
    279 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame)
     379ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame)
    280380{
    281381    if (serialFrame) {
     
    283383        if (buffer.length() < 4)
    284384            return 0;
    285         if (buffer.at(0) != 0x01 || byte(buffer.at(1)) != 0x90)
    286             return 0;
     385        mux = extractShort(buffer.data());
    287386        const ushort len = extractShort(buffer.data() + 2);
    288387        return (buffer.size() >= len + 4) ? len : ushort(0);
     
    293392    // Regular message delimited by 0x7e..0x7e
    294393    if (firstDelimiterPos == 0) {
     394
    295395        const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1);
    296396        return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0;
     
    300400}
    301401
    302 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData)
     402bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData)
    303403{
    304404    result->clear();
    305405    if(rawData)
    306406        rawData->clear();
    307     const ushort len = isValidTrkResult(*buffer, serialFrame);
     407    ushort len = isValidTrkResult(*buffer, serialFrame, result->multiplex);
     408    // handle receiving application output, which is not a regular command
     409    const int delimiterPos = serialFrame ? 4 : 0;
     410    if (linkEstablishmentMode) {
     411        //when "hot connecting" a device, we can receive partial frames.
     412        //this code resyncs by discarding data until a TRK frame is found
     413        while (buffer->length() > delimiterPos
     414               && result->multiplex != MuxTextTrace
     415               && !(result->multiplex == MuxTrk && buffer->at(delimiterPos) == 0x7e)) {
     416            buffer->remove(0,1);
     417            len = isValidTrkResult(*buffer, serialFrame, result->multiplex);
     418        }
     419    }
    308420    if (!len)
    309421        return false;
    310     // handle receiving application output, which is not a regular command
    311     const int delimiterPos = serialFrame ? 4 : 0;
    312422    if (buffer->at(delimiterPos) != 0x7e) {
    313423        result->isDebugOutput = true;
    314424        result->data = buffer->mid(delimiterPos, len);
    315         result->data.replace("\r\n", "\n");
    316         *buffer->remove(0, delimiterPos + len);
     425        buffer->remove(0, delimiterPos + len);
    317426        return true;
    318427    }
     
    322431    if(rawData)
    323432        *rawData = data;
    324     *buffer->remove(0, delimiterPos + len);
     433    buffer->remove(0, delimiterPos + len);
    325434
    326435    byte sum = 0;
     
    337446    //QByteArray prefix = "READ BUF:                                       ";
    338447    //logMessage((prefix + "HEADER: " + stringFromArray(header).toLatin1()).data());
     448
    339449    return true;
    340450}
     
    351461    res *= 256; res += byte(data[2]);
    352462    res *= 256; res += byte(data[3]);
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
    353476    return res;
    354477}
Note: See TracChangeset for help on using the changeset viewer.