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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 30 wfjm
// $Id: RlinkPort.hpp 666 2015-04-12 21:17:54Z mueller $
2 10 wfjm
//
3 30 wfjm
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 10 wfjm
//
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 30 wfjm
// 2015-04-11   666   1.3    add fXon, XonEnable()
17 27 wfjm
// 2014-12-10   611   1.2.2  add time stamps for Read/Write for logs
18 21 wfjm
// 2013-05-01   513   1.2.1  fTraceLevel now uint32_t
19 19 wfjm
// 2013-02-23   492   1.2    use RparseUrl
20
// 2013-02-22   491   1.1    use new RlogFile/RlogMsg interfaces
21
// 2013-01-27   477   1.0.3  add RawRead(),RawWrite() methods
22 17 wfjm
// 2012-12-26   465   1.0.2  add CloseFd() method
23 12 wfjm
// 2011-04-24   380   1.0.1  use boost::noncopyable (instead of private dcl's)
24 10 wfjm
// 2011-03-27   375   1.0    Initial version
25
// 2011-01-15   356   0.1    First draft
26
// ---------------------------------------------------------------------------
27
 
28
 
29
/*!
30
  \file
31 30 wfjm
  \version $Id: RlinkPort.hpp 666 2015-04-12 21:17:54Z mueller $
32 10 wfjm
  \brief   Declaration of class RlinkPort.
33
*/
34
 
35
#ifndef included_Retro_RlinkPort
36
#define included_Retro_RlinkPort 1
37
 
38
#include <string>
39
#include <map>
40
 
41 12 wfjm
#include "boost/utility.hpp"
42
 
43 10 wfjm
#include "librtools/RerrMsg.hpp"
44
#include "librtools/RlogFile.hpp"
45
#include "librtools/Rstats.hpp"
46 19 wfjm
#include "librtools/RparseUrl.hpp"
47 10 wfjm
 
48
namespace Retro {
49
 
50 12 wfjm
  class RlinkPort : private boost::noncopyable {
51 10 wfjm
    public:
52
                    RlinkPort();
53 19 wfjm
      virtual      ~RlinkPort();
54 10 wfjm
 
55
      virtual bool  Open(const std::string& url, RerrMsg& emsg) = 0;
56
      virtual void  Close();
57
 
58
      virtual int   Read(uint8_t* buf, size_t size, double timeout,
59
                         RerrMsg& emsg);
60
      virtual int   Write(const uint8_t* buf, size_t size, RerrMsg& emsg);
61
      virtual bool  PollRead(double timeout);
62
 
63 19 wfjm
      int           RawRead(uint8_t* buf, size_t size, bool exactsize,
64
                            double timeout, double& tused, RerrMsg& emsg);
65
      int           RawWrite(const uint8_t* buf, size_t size, RerrMsg& emsg);
66
 
67 10 wfjm
      bool          IsOpen() const;
68
 
69 19 wfjm
      const RparseUrl&  Url() const;
70 30 wfjm
      bool          XonEnable() const;
71 19 wfjm
 
72 10 wfjm
      int           FdRead() const;
73
      int           FdWrite() const;
74
 
75 19 wfjm
      void          SetLogFile(const boost::shared_ptr<RlogFile>& splog);
76 21 wfjm
      void          SetTraceLevel(uint32_t level);
77 29 wfjm
 
78 21 wfjm
      uint32_t      TraceLevel() const;
79 10 wfjm
 
80
      const Rstats& Stats() const;
81
 
82
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
83
 
84 19 wfjm
    // some constants (also defined in cpp)
85 27 wfjm
      static const int  kEof  =  0;         //<! return code: end-of-file 
86
      static const int  kTout = -1;         //<! return code: time out
87
      static const int  kErr  = -2;         //<! return code: IO error
88 10 wfjm
 
89
    // statistics counter indices
90
      enum stats {
91
        kStatNPortWrite = 0,
92
        kStatNPortRead,
93
        kStatNPortTxByt,
94
        kStatNPortRxByt,
95 19 wfjm
        kStatNPortRawWrite,
96
        kStatNPortRawRead,
97 10 wfjm
        kDimStat
98
      };
99
 
100
    protected:
101 17 wfjm
      void          CloseFd(int& fd);
102 10 wfjm
 
103
    protected:
104
      bool          fIsOpen;                //!< is open flag
105 19 wfjm
      RparseUrl     fUrl;                   //!< parsed url
106 30 wfjm
      bool          fXon;                   //!< xon attribute set 
107 10 wfjm
      int           fFdRead;                //!< fd for read
108
      int           fFdWrite;               //!< fd for write
109 19 wfjm
      boost::shared_ptr<RlogFile>  fspLog;  //!< log file ptr
110 21 wfjm
      uint32_t      fTraceLevel;            //!< trace level
111 27 wfjm
      double        fTsLastRead;            //!< time stamp last write
112
      double        fTsLastWrite;           //!< time stamp last write
113 10 wfjm
      Rstats        fStats;                 //!< statistics
114
  };
115
 
116
} // end namespace Retro
117
 
118
#include "RlinkPort.ipp"
119
 
120
#endif

powered by: WebSVN 2.1.0

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