Changeset 846 for trunk/tools/runonphone/symbianutils/trkutils.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tools/runonphone/symbianutils/trkutils.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/runonphone/symbianutils/trkutils.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 52 52 53 53 namespace trk { 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 54 73 55 74 TrkAppVersion::TrkAppVersion() … … 78 97 extended2TypeSize = 0; 79 98 pid = 0; 99 80 100 tid = 0; 81 101 codeseg = 0; 82 102 dataseg = 0; 83 103 84 currentThread = 0;85 104 libraries.clear(); 86 105 trkAppVersion.reset(); … … 144 163 } 145 164 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 146 249 // -------------- 147 250 … … 189 292 const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen); 190 293 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('.'); 197 297 } 198 298 if (size != ba.size()) { 199 str += "...";200 ascii += "...";201 } 202 return str + " "+ ascii;299 str += ; 300 ascii += ; 301 } 302 return str + + ascii; 203 303 } 204 304 … … 277 377 /* returns 0 if array doesn't represent a result, 278 378 otherwise returns the length of the result data */ 279 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame )379 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame) 280 380 { 281 381 if (serialFrame) { … … 283 383 if (buffer.length() < 4) 284 384 return 0; 285 if (buffer.at(0) != 0x01 || byte(buffer.at(1)) != 0x90) 286 return 0; 385 mux = extractShort(buffer.data()); 287 386 const ushort len = extractShort(buffer.data() + 2); 288 387 return (buffer.size() >= len + 4) ? len : ushort(0); … … 293 392 // Regular message delimited by 0x7e..0x7e 294 393 if (firstDelimiterPos == 0) { 394 295 395 const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1); 296 396 return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0; … … 300 400 } 301 401 302 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData)402 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData) 303 403 { 304 404 result->clear(); 305 405 if(rawData) 306 406 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 } 308 420 if (!len) 309 421 return false; 310 // handle receiving application output, which is not a regular command311 const int delimiterPos = serialFrame ? 4 : 0;312 422 if (buffer->at(delimiterPos) != 0x7e) { 313 423 result->isDebugOutput = true; 314 424 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); 317 426 return true; 318 427 } … … 322 431 if(rawData) 323 432 *rawData = data; 324 *buffer->remove(0, delimiterPos + len);433 buffer->remove(0, delimiterPos + len); 325 434 326 435 byte sum = 0; … … 337 446 //QByteArray prefix = "READ BUF: "; 338 447 //logMessage((prefix + "HEADER: " + stringFromArray(header).toLatin1()).data()); 448 339 449 return true; 340 450 } … … 351 461 res *= 256; res += byte(data[2]); 352 462 res *= 256; res += byte(data[3]); 463 464 465 466 467 468 469 470 471 472 473 474 475 353 476 return res; 354 477 }
Note:
See TracChangeset
for help on using the changeset viewer.
