1 |
27 |
wfjm |
// $Id: RlinkPacketBuf.hpp 606 2014-11-24 07:08:51Z mueller $
|
2 |
10 |
wfjm |
//
|
3 |
27 |
wfjm |
// Copyright 2011-2014 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 |
27 |
wfjm |
// 2014-11-23 606 2.0 re-organize for rlink v4
|
17 |
20 |
wfjm |
// 2013-04-21 509 1.0.2 add SndAttn() method
|
18 |
19 |
wfjm |
// 2013-01-13 474 1.0.1 add PollAttn() method
|
19 |
10 |
wfjm |
// 2011-04-02 375 1.0 Initial version
|
20 |
|
|
// 2011-03-05 366 0.1 First draft
|
21 |
|
|
// ---------------------------------------------------------------------------
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/*!
|
25 |
|
|
\file
|
26 |
27 |
wfjm |
\version $Id: RlinkPacketBuf.hpp 606 2014-11-24 07:08:51Z mueller $
|
27 |
10 |
wfjm |
\brief Declaration of class RlinkPacketBuf.
|
28 |
|
|
*/
|
29 |
|
|
|
30 |
|
|
#ifndef included_Retro_RlinkPacketBuf
|
31 |
|
|
#define included_Retro_RlinkPacketBuf 1
|
32 |
|
|
|
33 |
|
|
#include <cstdint>
|
34 |
27 |
wfjm |
#include <ostream>
|
35 |
10 |
wfjm |
#include <vector>
|
36 |
|
|
|
37 |
27 |
wfjm |
#include "boost/utility.hpp"
|
38 |
10 |
wfjm |
|
39 |
27 |
wfjm |
#include "librtools/Rstats.hpp"
|
40 |
|
|
|
41 |
|
|
#include "RlinkCrc16.hpp"
|
42 |
|
|
|
43 |
10 |
wfjm |
namespace Retro {
|
44 |
|
|
|
45 |
27 |
wfjm |
class RlinkPacketBuf : private boost::noncopyable {
|
46 |
10 |
wfjm |
public:
|
47 |
|
|
|
48 |
|
|
RlinkPacketBuf();
|
49 |
27 |
wfjm |
~RlinkPacketBuf();
|
50 |
10 |
wfjm |
|
51 |
|
|
size_t PktSize() const;
|
52 |
|
|
|
53 |
|
|
uint32_t Flags() const;
|
54 |
|
|
bool TestFlag(uint32_t mask) const;
|
55 |
|
|
|
56 |
27 |
wfjm |
const Rstats& Stats() const;
|
57 |
|
|
|
58 |
10 |
wfjm |
void Dump(std::ostream& os, int ind=0, const char* text=0) const;
|
59 |
|
|
|
60 |
19 |
wfjm |
// flag bits (also defined in cpp)
|
61 |
27 |
wfjm |
static const uint32_t kFlagSopSeen = 1<<0; //!< sop was seen
|
62 |
|
|
static const uint32_t kFlagEopSeen = 1<<1; //!< eop was seen
|
63 |
|
|
static const uint32_t kFlagNakSeen = 1<<2; //!< nak was seen
|
64 |
|
|
static const uint32_t kFlagAttnSeen = 1<<3; //!< attn was seen
|
65 |
|
|
static const uint32_t kFlagErrTout = 1<<16; //!< err: timeout on read
|
66 |
|
|
static const uint32_t kFlagErrIO = 1<<17; //!< err: IO error on read
|
67 |
|
|
static const uint32_t kFlagErrFrame = 1<<18; //!< err: frame error
|
68 |
|
|
static const uint32_t kFlagErrClobber = 1<<19; //!< err: clobbered esc
|
69 |
10 |
wfjm |
|
70 |
19 |
wfjm |
// some constants (also defined in cpp)
|
71 |
27 |
wfjm |
static const uint8_t kSymEsc = 0xCA; //!< VHDL def escape 1100 1010
|
72 |
|
|
static const uint8_t kSymFill = 0xD5; //!< VHDL def fill 1101 0101
|
73 |
|
|
static const uint8_t kSymXon = 0x11; //!< VHDL def xon 0001 0001
|
74 |
|
|
static const uint8_t kSymXoff = 0x13; //!< VHDL def xoff 0001 0011
|
75 |
|
|
static const uint8_t kSymEdPref = 0x40; //!< VHDL def ed_pref 0100 0000
|
76 |
|
|
static const uint8_t kEcSop = 0x00; //!< VHDL def ec_sop 000
|
77 |
|
|
static const uint8_t kEcEop = 0x01; //!< VHDL def ec_eop 001
|
78 |
|
|
static const uint8_t kEcNak = 0x02; //!< VHDL def ec_nak 010
|
79 |
|
|
static const uint8_t kEcAttn = 0x03; //!< VHDL def ec_attn 011
|
80 |
|
|
static const uint8_t kEcXon = 0x04; //!< VHDL def ec_xon 100
|
81 |
|
|
static const uint8_t kEcXoff = 0x05; //!< VHDL def ec_xoff 101
|
82 |
|
|
static const uint8_t kEcFill = 0x06; //!< VHDL def ec_fill 110
|
83 |
|
|
static const uint8_t kEcEsc = 0x07; //!< VHDL def ec_esc 111
|
84 |
|
|
static const uint8_t kEcClobber = 0xff; //!< invalid Ecode
|
85 |
10 |
wfjm |
|
86 |
|
|
protected:
|
87 |
|
|
void SetFlagBit(uint32_t mask);
|
88 |
|
|
void ClearFlagBit(uint32_t mask);
|
89 |
|
|
|
90 |
|
|
protected:
|
91 |
|
|
std::vector<uint8_t> fPktBuf; //!< packet buffer
|
92 |
27 |
wfjm |
RlinkCrc16 fCrc; //!< crc accumulator
|
93 |
10 |
wfjm |
uint32_t fFlags; //!< request/response flags
|
94 |
27 |
wfjm |
Rstats fStats; //!< statistics
|
95 |
10 |
wfjm |
};
|
96 |
|
|
|
97 |
|
|
} // end namespace Retro
|
98 |
|
|
|
99 |
|
|
#include "RlinkPacketBuf.ipp"
|
100 |
|
|
|
101 |
|
|
#endif
|