SFBFrame.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00027 #ifndef SFBFRAME_H_
00028 #define SFBFRAME_H_
00029 
00030 #include "SFBTypes.h"
00031 #include "SFBByteBuffer.h"
00032 #include "SFBAssert.h"
00033 #include "SFBPacket.h"
00034 
00038 class SFBFrame {
00039 public:
00040   SFBFrame(SFBRxByteBuffer & r, SFBTxByteBuffer & t, PacketBuffer & p, u8 face) ; 
00041 
00042   u8 * pollForRxPacket() ;
00043   
00044   bool txCanAddByte() ;         
00045   void txDataByte(u8 data) ;    
00046   void txEndPacket();
00047 
00048   void reset() ;                
00049   void resetRx() ;              
00050 
00051   void resetTx() ;              
00052 
00053 
00054   enum FrameTypes {
00055     STANDARD_PACKET,
00056     BYTE_PER_PACKET,
00057     MAX_FRAME_TYPES
00058   };
00059 
00060   void setRxFrameType(u32 frameType) ;
00061   void setTxFrameType(u32 frameType) ;
00062   u32 getRxFrameType() { return rxFrameType; }
00063   u32 getTxFrameType() { return txFrameType; }
00064 private:
00065 
00066   bool rxByte(int byteOrErrorVal); 
00067   bool rxByteNonstandard(int byteVal); 
00068 
00069   bool rxStoreRaw(u8 byte); 
00070   void rxSetupError(u8 flags) ; 
00071   void rxSetupPacket() ; 
00072 
00073   void txDataByteNonstandard(u8 data); 
00074 
00075   SFBRxByteBuffer & rxBuf;
00076   SFBTxByteBuffer & txBuf;
00077   PacketBuffer & deframeBuffer;
00078   int txCount;
00079   int rxCount;                  
00080   bool rxEscape;                
00081   u8 rxFrameType;
00082   u8 txFrameType;
00083   const u8 face;
00084 };
00085 #endif