summaryrefslogtreecommitdiffstats
path: root/remote-processor/Message.cpp
diff options
context:
space:
mode:
authorKevin Rocard <kevinx.rocard@intel.com>2014-04-23 20:34:14 +0200
committerMattijs Korpershoek <mattijsx.korpershoek@intel.com>2014-06-25 10:52:28 +0200
commitef8d727ca0eb346af951d15d84ba6f2b9564adf5 (patch)
tree533e493aa4814b12c3b49da7ee1ba5864b436042 /remote-processor/Message.cpp
parentf976f3749c6639915a646a88049fe523e3d5f051 (diff)
downloadexternal_parameter-framework-ef8d727ca0eb346af951d15d84ba6f2b9564adf5.zip
external_parameter-framework-ef8d727ca0eb346af951d15d84ba6f2b9564adf5.tar.gz
external_parameter-framework-ef8d727ca0eb346af951d15d84ba6f2b9564adf5.tar.bz2
[remote-processor] Add context information on failure
BZ: 190038 Remote processor was not displaying information in case of network read/write error. Add some error messages to ease debug. Change-Id: I465062e8cf77f94b3d4d4d0c71338c4630aac276 Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com> Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Diffstat (limited to 'remote-processor/Message.cpp')
-rw-r--r--remote-processor/Message.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/remote-processor/Message.cpp b/remote-processor/Message.cpp
index 8efec1f..db24d80 100644
--- a/remote-processor/Message.cpp
+++ b/remote-processor/Message.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2011-2014, Intel Corporation
* All rights reserved.
*
@@ -33,6 +33,7 @@
#include "RemoteProcessorProtocol.h"
#include <string.h>
#include <assert.h>
+#include <errno.h>
CMessage::CMessage(uint8_t ucMsgId) : _ucMsgId(ucMsgId), _pucData(NULL), _uiDataSize(0), _uiIndex(0)
{
@@ -123,7 +124,7 @@ uint32_t CMessage::getRemainingDataSize() const
}
// Send/Receive
-bool CMessage::serialize(CSocket* pSocket, bool bOut)
+bool CMessage::serialize(CSocket* pSocket, bool bOut, string& strError)
{
if (bOut) {
@@ -141,6 +142,7 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
if (!pSocket->write(&uiSyncWord, sizeof(uiSyncWord))) {
+ strError += string("Sync write failed: ") + strerror(errno);
return false;
}
@@ -149,18 +151,21 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
if (!pSocket->write(&uiSize, sizeof(uiSize))) {
+ strError += string("Size write failed: ") + strerror(errno);
return false;
}
// Msg Id
if (!pSocket->write(&_ucMsgId, sizeof(_ucMsgId))) {
+ strError += string("Msg write failed: ") + strerror(errno);
return false;
}
// Data
if (!pSocket->write(_pucData, _uiDataSize)) {
+ strError = string("Data write failed: ") + strerror(errno);
return false;
}
@@ -169,6 +174,7 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
if (!pSocket->write(&ucChecksum, sizeof(ucChecksum))) {
+ strError = string("Checksum write failed: ") + strerror(errno);
return false;
}
@@ -178,12 +184,14 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
if (!pSocket->read(&uiSyncWord, sizeof(uiSyncWord))) {
+ strError = string("Sync read failed: ") + strerror(errno);
return false;
}
// Check Sync word
if (uiSyncWord != SYNC_WORD) {
+ strError = "Sync word incorrect";
return false;
}
@@ -192,12 +200,14 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
if (!pSocket->read(&uiSize, sizeof(uiSize))) {
+ strError = string("Size read failed: ") + strerror(errno);
return false;
}
// Msg Id
if (!pSocket->read(&_ucMsgId, sizeof(_ucMsgId))) {
+ strError = string("Msg id read failed: ") + strerror(errno);
return false;
}
@@ -209,6 +219,7 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
// Data receive
if (!pSocket->read(_pucData, _uiDataSize)) {
+ strError = string("Data read failed: ") + strerror(errno);
return false;
}
@@ -217,11 +228,13 @@ bool CMessage::serialize(CSocket* pSocket, bool bOut)
if (!pSocket->read(&ucChecksum, sizeof(ucChecksum))) {
+ strError = string("Checksum read failed: ") + strerror(errno);
return false;
}
// Compare
if (ucChecksum != computeChecksum()) {
+ strError = "Received checksum != computed checksum";
return false;
}