OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librlink/] [RlinkPacketBufRcv.hpp] - Blame information for rev 28

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 wfjm
// $Id: RlinkPacketBufRcv.hpp 621 2014-12-26 21:20:05Z mueller $
2 27 wfjm
//
3
// Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16 28 wfjm
// 2014-12-25   621   1.0.1  Reorganize packet send/revd stats
17 27 wfjm
// 2014-11-30   607   1.0    Initial version 
18
// 2014-11-02   600   0.1    First draft (re-organize PacketBuf for rlink v4)
19
// ---------------------------------------------------------------------------
20
 
21
 
22
/*!
23
  \file
24 28 wfjm
  \version $Id: RlinkPacketBufRcv.hpp 621 2014-12-26 21:20:05Z mueller $
25 27 wfjm
  \brief   Declaration of class RlinkPacketBuf.
26
*/
27
 
28
#ifndef included_Retro_RlinkPacketBufRcv
29
#define included_Retro_RlinkPacketBufRcv 1
30
 
31
#include "RlinkPacketBuf.hpp"
32
#include "RlinkPort.hpp"
33
 
34
namespace Retro {
35
 
36
  class RlinkPacketBufRcv: public RlinkPacketBuf  {
37
    public:
38
 
39
                    RlinkPacketBufRcv();
40
                   ~RlinkPacketBufRcv();
41
 
42
      int           ReadData(RlinkPort* port, double timeout, RerrMsg& emsg);
43
      bool          ProcessData();
44
      void          AcceptPacket();
45
      void          FlushRaw();
46
 
47
      enum pkt_state {
48
        kPktPend=0,                         //<! pending, still being filled
49
        kPktResp,                           //<! response packet (SOP+EOP)
50
        kPktAttn,                           //<! attn notify packet (ATTN+EOP)
51
        kPktError                           //<! errorous packet
52
      };
53
      pkt_state     PacketState();
54
 
55
      bool          CheckSize(size_t nbyte) const;
56
      void          GetWithCrc(uint8_t& data);
57
      void          GetWithCrc(uint16_t& data);
58
      void          GetWithCrc(uint16_t* pdata, size_t count);
59
      bool          CheckCrc();
60
 
61
      int           NakIndex() const;
62
 
63
      void          Dump(std::ostream& os, int ind=0, const char* text=0) const;
64
 
65
   // statistics counter indices
66
      enum stats {
67 28 wfjm
        kStatNRxPktByt=0,                   //!< Rx packet bytes rcvd
68
        kStatNRxDrop,                       //!< Rx bytes dropped
69 27 wfjm
        kStatNRxSop,                        //!< Rx SOP commas seen
70
        kStatNRxEop,                        //!< Rx EOP commas seen
71
        kStatNRxNak,                        //!< Rx NAK commas seen
72
        kStatNRxAttn,                       //!< Rx ATTN commas seen
73
        kStatNRxEsc,                        //!< Rx data escapes
74
        kStatNRxClobber                     //!< Rx clobbered escapes
75
      };
76
 
77
    protected:
78
      void          ProcessDataIdle();
79
      void          ProcessDataFill();
80
      uint8_t       GetEcode();
81
 
82
      enum rcv_state {
83
        kRcvIdle=0,                         //!< wait for SOP or ATTN
84
        kRcvFill,                           //!< fill packet till EOP seen
85
        kRcvDone,                           //!< packet ok, EOP seen
86
        kRcvError                           //!< packet framing error
87
      };
88
 
89
    protected:
90
      uint8_t       fRawBuf[4096];          //!< raw data buffer
91
      size_t        fRawBufSize;            //!< # of valid bytes in RawBuf
92
      size_t        fRawBufDone;            //!< # of processed bytes in RawBuf
93
      enum rcv_state       fRcvState;       //!< receive FSM state
94
      size_t        fNDone;                 //!< number of pkt bytes processed
95
      bool          fEscSeen;               //!< last char was Escape
96
      int           fNakIndex;              //!< index of active nak (-1 if no)
97
      std::vector<uint8_t> fDropData;       //!< dropped data buffer    
98
  };
99
 
100
} // end namespace Retro
101
 
102
#include "RlinkPacketBufRcv.ipp"
103
 
104
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.