w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlinkPacketBuf.cpp
Go to the documentation of this file.
1// $Id: RlinkPacketBuf.cpp 1198 2019-07-27 19:08:31Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2019-07-27 1198 2.0.4 add kNc* definitions
8// 2017-04-07 868 2.0.1 Dump(): add detail arg
9// 2014-11-23 606 2.0 re-organize for rlink v4
10// 2013-04-21 509 1.0.4 add SndAttn() method
11// 2013-02-03 481 1.0.3 use Rexception
12// 2013-01-13 474 1.0.2 add PollAttn() method
13// 2013-01-04 469 1.0.1 SndOob(): Add filler 0 to ensure escape state
14// 2011-04-02 375 1.0 Initial version
15// 2011-03-05 366 0.1 First draft
16// ---------------------------------------------------------------------------
17
22#include "RlinkPacketBuf.hpp"
23
24#include "librtools/RosFill.hpp"
27
28using namespace std;
29
35// all method definitions in namespace Retro
36namespace Retro {
37
38//------------------------------------------+-----------------------------------
39// constants definitions
40
41const uint32_t RlinkPacketBuf::kFlagSopSeen;
42const uint32_t RlinkPacketBuf::kFlagEopSeen;
43const uint32_t RlinkPacketBuf::kFlagNakSeen;
45const uint32_t RlinkPacketBuf::kFlagErrTout;
46const uint32_t RlinkPacketBuf::kFlagErrIO;
49
50const uint8_t RlinkPacketBuf::kSymEsc;
51const uint8_t RlinkPacketBuf::kSymFill;
52const uint8_t RlinkPacketBuf::kSymXon;
53const uint8_t RlinkPacketBuf::kSymXoff;
54const uint8_t RlinkPacketBuf::kSymEdPref;
55const uint8_t RlinkPacketBuf::kEcSop;
56const uint8_t RlinkPacketBuf::kEcEop;
57const uint8_t RlinkPacketBuf::kEcNak;
58const uint8_t RlinkPacketBuf::kEcAttn;
59const uint8_t RlinkPacketBuf::kEcXon;
60const uint8_t RlinkPacketBuf::kEcXoff;
61const uint8_t RlinkPacketBuf::kEcFill;
62const uint8_t RlinkPacketBuf::kEcEsc;
63const uint8_t RlinkPacketBuf::kEcClobber;
64const uint8_t RlinkPacketBuf::kNcCcrc;
65const uint8_t RlinkPacketBuf::kNcDcrc;
66const uint8_t RlinkPacketBuf::kNcFrame;
67const uint8_t RlinkPacketBuf::kNcUnused;
68const uint8_t RlinkPacketBuf::kNcCmd;
69const uint8_t RlinkPacketBuf::kNcCnt;
70const uint8_t RlinkPacketBuf::kNcRtOvlf;
71const uint8_t RlinkPacketBuf::kNcRtWblk;
72const uint8_t RlinkPacketBuf::kNcInval;
73
74//------------------------------------------+-----------------------------------
76
78 : fPktBuf(),
79 fCrc(),
80 fFlags(0),
81 fStats()
82{}
83
84//------------------------------------------+-----------------------------------
86
88{}
89
90//------------------------------------------+-----------------------------------
92
93void RlinkPacketBuf::Dump(std::ostream& os, int ind, const char* text,
94 int detail) const
95{
96 RosFill bl(ind);
97 os << bl << (text?text:"--") << "RlinkPacketBuf @ " << this << endl;
98 os << bl << " fCrc: " << RosPrintBvi(fCrc.Crc(), 0) << endl;
99 os << bl << " fFlags: " << RosPrintBvi(fFlags, 0) << endl;
100 fStats.Dump(os, ind+2, "fStats: ", detail-1);
101
102 os << bl << " fPktBuf.size: " << RosPrintf(fPktBuf.size(),"d",4);
103 size_t ncol = max(1, (80-ind-4-6)/(2+1));
104 for (size_t i=0; i< fPktBuf.size(); i++) {
105 if (i%ncol == 0) os << "\n" << bl << " " << RosPrintf(i,"d",4) << ": ";
106 os << RosPrintBvi(fPktBuf[i],16) << " ";
107 }
108 os << endl;
109
110 return;
111}
112
113} // end namespace Retro
uint16_t Crc() const
FIXME_docs.
Definition: RlinkCrc16.ipp:48
static const uint8_t kEcXon
VHDL def ec_xon 100.
static const uint8_t kNcCnt
VHDL def nak_cnt 101.
RlinkPacketBuf()
Default constructor.
static const uint8_t kNcRtWblk
VHDL def nak_rtwblk 111.
static const uint8_t kNcUnused
VHDL def nak_unused 011.
static const uint8_t kNcFrame
VHDL def nak_frame 010.
static const uint32_t kFlagErrTout
err: timeout on read
static const uint8_t kSymEsc
VHDL def escape 1100 1010.
static const uint8_t kEcClobber
invalid Ecode
~RlinkPacketBuf()
Destructor.
static const uint8_t kEcEsc
VHDL def ec_esc 111.
static const uint8_t kNcCmd
VHDL def nak_cmd 100.
static const uint32_t kFlagSopSeen
sop was seen
static const uint8_t kSymFill
VHDL def fill 1101 0101.
static const uint8_t kNcRtOvlf
VHDL def nak_rtovfl 110.
RlinkCrc16 fCrc
crc accumulator
static const uint8_t kEcSop
VHDL def ec_sop 000.
static const uint32_t kFlagEopSeen
eop was seen
static const uint8_t kNcDcrc
VHDL def nak_dcrc 001.
static const uint32_t kFlagErrFrame
err: frame error
static const uint8_t kEcFill
VHDL def ec_fill 110.
static const uint8_t kNcInval
invalid NAK
std::vector< uint8_t > fPktBuf
packet buffer
static const uint32_t kFlagErrClobber
err: clobbered esc
static const uint32_t kFlagNakSeen
nak was seen
Rstats fStats
statistics
static const uint8_t kEcNak
VHDL def ec_nak 010.
static const uint8_t kEcAttn
VHDL def ec_attn 011.
static const uint8_t kSymEdPref
VHDL def ed_pref 0100 0000.
uint32_t fFlags
request/response flags
static const uint8_t kEcXoff
VHDL def ec_xoff 101.
static const uint8_t kSymXon
VHDL def xon 0001 0001.
static const uint8_t kEcEop
VHDL def ec_eop 001.
static const uint8_t kSymXoff
VHDL def xoff 0001 0011.
static const uint8_t kNcCcrc
VHDL def nak_ccrc 000.
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
static const uint32_t kFlagErrIO
err: IO error on read
static const uint32_t kFlagAttnSeen
attn was seen
I/O appicator to generate fill characters.
Definition: RosFill.hpp:24
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rstats.cpp:178
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Definition: RosPrintf.ipp:38
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47