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/Common/FlowDecoder/FlowDecoder.h | |
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/Common/FlowDecoder/FlowDecoder.h')
-rw-r--r-- | K2LABI/Common/FlowDecoder/FlowDecoder.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/K2LABI/Common/FlowDecoder/FlowDecoder.h b/K2LABI/Common/FlowDecoder/FlowDecoder.h new file mode 100644 index 0000000..6f8be64 --- /dev/null +++ b/K2LABI/Common/FlowDecoder/FlowDecoder.h @@ -0,0 +1,54 @@ +#ifndef __FLOW_DECODER_H__ +#define __FLOW_DECODER_H__ + +#include "IFlowDecoder.h" + + +class CFlowDecoder : public IFlowDecoder +{ +public: + CFlowDecoder(); + virtual ~CFlowDecoder() {} + + // Gets called to submit a new package to buffer + void DecodeFlow(BYTE* pBuffer, unsigned long nLen); + virtual void Reset(); + +protected: + void InitializeBuffer(BYTE* pBuffer, unsigned long nLen); + unsigned long GetNumberOfBytesInBuffer() const; + unsigned long GetNumberOfMemoryChunks() const; + bool GetMemoryChunk(unsigned long nNum, BYTE*& pReadPointer, unsigned long& nBytesAvailable) const; + bool AddBytesToBuffer(BYTE* pBuffer, unsigned long nLen); + bool CopyFromBuffer(BYTE* pTarget, unsigned long len) const; + bool RemoveBytesFromBuffer(unsigned long len); + +protected: + enum eStateRetVal + { + E_STATE_NEEDS_MORE_DATA, + E_STATE_GOT_WRONG_DATA, + E_STATE_OK, + E_STATE_UNDEFINED + }; + + bool m_nSynchronized; + + virtual eStateRetVal ReceiveHeader() = 0; + virtual eStateRetVal ReceivePacket() = 0; + +private: + enum eDecoderState + { + E_WAITING_FOR_HEADER, + E_WAITING_FOR_PACKET_DATA, + }; + + unsigned long m_nBytesInBuffer; + BYTE* m_pCurrentReadPointer; + BYTE* m_pBufferStart; + BYTE* m_pBufferEnd; + eDecoderState m_DecoderState; +}; + +#endif // __FLOW_DECODER_H__ |