Commit 8c95dfeb authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Symbian/trk: Fix debugging output for the N8.



1. Fix hanging behaviour when we receive a message on the wrong mux in
framed mode
2. Treat messages on the trace mux (0102) as debug output
3. Separate timestamp from text in trace messages
Initial-patch-by: default avatarShane Kearns <shane.kearns@accenture.com>
parent 626221b6
......@@ -353,8 +353,22 @@ void Launcher::handleResult(const TrkResult &result)
QByteArray prefix = "READ BUF: ";
QByteArray str = result.toString().toUtf8();
if (result.isDebugOutput) { // handle application output
logMessage("APPLICATION OUTPUT: " + result.data);
emit applicationOutputReceived(result.data);
QString msg;
if (result.multiplex == MuxTextTrace) {
if (result.data.length() > 8) {
quint64 timestamp = extractInt64(result.data) & 0x0FFFFFFFFFFFFFFFULL;
quint64 secs = timestamp / 1000000000;
quint64 ns = timestamp % 1000000000;
msg = QString("[%1.%2] %3").arg(secs).arg(ns).arg(QString(result.data.mid(8)));
logMessage("TEXT TRACE: " + msg);
}
} else {
logMessage("APPLICATION OUTPUT: " + result.data);
msg = result.data;
}
msg.replace("\r\n", "\n");
if(!msg.endsWith('\n')) msg.append('\n');
emit applicationOutputReceived(msg);
return;
}
switch (result.code) {
......
......@@ -264,14 +264,13 @@ QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool s
/* 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);
}
......@@ -280,6 +279,7 @@ ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame)
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;
}
......@@ -292,7 +292,7 @@ bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByt
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
......@@ -300,7 +300,6 @@ bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByt
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;
}
......@@ -341,6 +340,19 @@ SYMBIANUTILS_EXPORT uint extractInt(const char *data)
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;
......
......@@ -123,9 +123,16 @@ enum Command {
TrkDSPositionFile = 0xd4
};
enum SerialMultiplexor {
MuxRaw = 0,
MuxTextTrace = 0x0102,
MuxTrk = 0x0190
};
inline byte extractByte(const char *data) { return *data; }
SYMBIANUTILS_EXPORT ushort extractShort(const char *data);
SYMBIANUTILS_EXPORT uint extractInt(const char *data);
SYMBIANUTILS_EXPORT quint64 extractInt64(const char *data);
SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba);
......@@ -205,6 +212,7 @@ struct SYMBIANUTILS_EXPORT TrkResult
int errorCode() const;
QString errorString() const;
ushort multiplex;
byte code;
byte token;
QByteArray data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment