diff options
author | Christian Gromm <christian.gromm@microchip.com> | 2016-06-21 14:14:04 +0200 |
---|---|---|
committer | Christian Gromm <christian.gromm@microchip.com> | 2016-06-21 14:14:04 +0200 |
commit | 860b3c0ccfb2756b8ed77523048952011b74a212 (patch) | |
tree | e0672fb5cf923dcf0a4a48a62a69011e1b72976a /K2LABI/IPC/K2LIPC.cpp | |
parent | 742bace60b9c0a0f583d8afe1097d029f468fa03 (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/IPC/K2LIPC.cpp')
-rw-r--r-- | K2LABI/IPC/K2LIPC.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/K2LABI/IPC/K2LIPC.cpp b/K2LABI/IPC/K2LIPC.cpp new file mode 100644 index 0000000..5d17359 --- /dev/null +++ b/K2LABI/IPC/K2LIPC.cpp @@ -0,0 +1,70 @@ +#include "windows-adapter.h" +#include "K2LIPC.h" +#include "IPCFlowDecoder.h" +#include "Ipc.h" + +IIpc* CIpcFactory::CreateIpc() +{ + return new CIpc(); +} + +//----------------------------------------------------------------------------- +void CIpcFactory::DestroyIpc(IIpc* pIpc) +{ + delete pIpc; +} + +//----------------------------------------------------------------------------- +K2LABI_API IPC_HANDLE CreateIPC() +{ + CIpc* pIpc = new CIpc; + return reinterpret_cast<IPC_HANDLE>(pIpc); +} + +//----------------------------------------------------------------------------- +K2LABI_API void DestroyIPC(IPC_HANDLE hIpc) +{ + CIpc* pIpc = reinterpret_cast<CIpc*>(hIpc); + delete pIpc; +} + +//----------------------------------------------------------------------------- +K2LABI_API int IPCInit(IPC_HANDLE hIpc, FCT_OnMessageEvent callback, FCT_OnEvent error, FCT_OnEvent overflow) +{ + CIpc* pIpc = reinterpret_cast<CIpc*>(hIpc); + if (!pIpc) + return -1; + + IIPCListener* pListener = pIpc->CreateListener(callback, error, overflow); + return pIpc->Init(pListener); +} + +//----------------------------------------------------------------------------- +K2LABI_API int IPCDeinit(IPC_HANDLE hIpc) +{ + CIpc* pIpc = reinterpret_cast<CIpc*>(hIpc); + if (!pIpc) + return -1; + + pIpc->DestroyListener(); + return pIpc->Deinit(); +} + +//----------------------------------------------------------------------------- +K2LABI_API int IPCFormatRequest(IPC_HANDLE hIpc, BYTE channel, BYTE ifaceId, BYTE funId, DWORD dwSenderID, const BYTE *pReqData, DWORD dataLen, BYTE* pResult, int nResultLen, int* nNeededResultLen) +{ + CIpc* pIpc = reinterpret_cast<CIpc*>(hIpc); + if (!pIpc) + return -1; + + return pIpc->FormatRequest(channel, ifaceId, funId, dwSenderID, pReqData, dataLen, pResult, nResultLen, nNeededResultLen); +} + +//----------------------------------------------------------------------------- +K2LABI_API void IPCDecode(IPC_HANDLE hIpc, BYTE* pData, int nDataLen) +{ + CIpc* pIpc = reinterpret_cast<CIpc*>(hIpc); + + if (pIpc) + pIpc->Decode(pData, nDataLen); +} |