summaryrefslogtreecommitdiffstats
path: root/K2LABI/ABI/ResultParser.cpp
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2016-06-21 14:14:04 +0200
committerChristian Gromm <christian.gromm@microchip.com>2016-06-21 14:14:04 +0200
commit860b3c0ccfb2756b8ed77523048952011b74a212 (patch)
treee0672fb5cf923dcf0a4a48a62a69011e1b72976a /K2LABI/ABI/ResultParser.cpp
parent742bace60b9c0a0f583d8afe1097d029f468fa03 (diff)
src: can-lin: initial source import
This patch adds the sources needed for the HVAC and iDrive applications. Change-Id: I53148a5d11c34787dd11295939bbaf8702c64dcb Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Diffstat (limited to 'K2LABI/ABI/ResultParser.cpp')
-rw-r--r--K2LABI/ABI/ResultParser.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/K2LABI/ABI/ResultParser.cpp b/K2LABI/ABI/ResultParser.cpp
new file mode 100644
index 0000000..b5e39bc
--- /dev/null
+++ b/K2LABI/ABI/ResultParser.cpp
@@ -0,0 +1,29 @@
+#include "k2l-type.h"
+#include "ResultParser.h"
+#include <string.h>
+
+BYTE* CResultParser::ToByteArray(ParamDef* pParams, int nParamCount, int& nResultLength)
+{
+ int nLength = 0;
+ for (int i = 0; i < nParamCount; i++)
+ {
+ nLength += pParams[i].m_nLength;
+ }
+
+ BYTE* pBuffer = NULL;
+ if (nLength)
+ {
+ nLength = (nLength + 1) & ~1;
+ pBuffer = new BYTE[nLength];
+ memset(pBuffer, 0, nLength);
+ BYTE* pTemBuf = pBuffer;
+ for(int i = 0; i < nParamCount; i++)
+ {
+ memcpy(pTemBuf, pParams[i].m_pData, pParams[i].m_nLength);
+ pTemBuf += pParams[i].m_nLength;
+ }
+ }
+
+ nResultLength = nLength;
+ return pBuffer;
+}