tools/runonphone/symbianutils/trkutils.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
--- a/tools/runonphone/symbianutils/trkutils.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/tools/runonphone/symbianutils/trkutils.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -276,14 +276,13 @@
 
 /* returns 0 if array doesn't represent a result,
 otherwise returns the length of the result data */
-ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame)
+ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame, ushort& mux)
 {
     if (serialFrame) {
         // Serial protocol with length info
         if (buffer.length() < 4)
             return 0;
-        if (buffer.at(0) != 0x01 || byte(buffer.at(1)) != 0x90)
-            return 0;
+        mux = extractShort(buffer.data());
         const ushort len = extractShort(buffer.data() + 2);
         return (buffer.size() >= len + 4) ? len : ushort(0);
     }
@@ -292,6 +291,7 @@
     const int firstDelimiterPos = buffer.indexOf(delimiter);
     // Regular message delimited by 0x7e..0x7e
     if (firstDelimiterPos == 0) {
+        mux = MuxTrk;
         const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1);
         return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0;
     }
@@ -304,7 +304,7 @@
     result->clear();
     if(rawData)
         rawData->clear();
-    const ushort len = isValidTrkResult(*buffer, serialFrame);
+    const ushort len = isValidTrkResult(*buffer, serialFrame, result->multiplex);
     if (!len)
         return false;
     // handle receiving application output, which is not a regular command
@@ -312,7 +312,6 @@
     if (buffer->at(delimiterPos) != 0x7e) {
         result->isDebugOutput = true;
         result->data = buffer->mid(delimiterPos, len);
-        result->data.replace("\r\n", "\n");
         *buffer->remove(0, delimiterPos + len);
         return true;
     }
@@ -353,6 +352,19 @@
     return res;
 }
 
+SYMBIANUTILS_EXPORT quint64 extractInt64(const char *data)
+{
+    quint64 res = byte(data[0]);
+    res <<= 8; res += byte(data[1]);
+    res <<= 8; res += byte(data[2]);
+    res <<= 8; res += byte(data[3]);
+    res <<= 8; res += byte(data[4]);
+    res <<= 8; res += byte(data[5]);
+    res <<= 8; res += byte(data[6]);
+    res <<= 8; res += byte(data[7]);
+    return res;
+}
+
 SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba)
 {
     QString res;