w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlinkPacketBufRcv.hpp
Go to the documentation of this file.
1// $Id: RlinkPacketBufRcv.hpp 1198 2019-07-27 19:08:31Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2014-2019 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 1.2.1 add Nak handling
8// 2018-12-08 1079 1.2 use ref not ptr for RlinkPort
9// 2017-04-07 868 1.1.1 Dump(): add detail arg
10// 2017-02-19 853 1.1 use Rtime
11// 2014-12-25 621 1.0.1 Reorganize packet send/revd stats
12// 2014-11-30 607 1.0 Initial version
13// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
14// ---------------------------------------------------------------------------
15
16
21#ifndef included_Retro_RlinkPacketBufRcv
22#define included_Retro_RlinkPacketBufRcv 1
23
24#include "RlinkPacketBuf.hpp"
25#include "RlinkPort.hpp"
26
27namespace Retro {
28
30 public:
31
34
35 int ReadData(RlinkPort& port, const Rtime& timeout,
36 RerrMsg& emsg);
37 bool ProcessData();
38 void AcceptPacket();
39 void FlushRaw();
40
41 enum pkt_state {
46 };
48
49 bool CheckNak() const;
50 bool CheckSize(size_t nbyte) const;
51 void GetWithCrc(uint8_t& data);
52 void GetWithCrc(uint16_t& data);
53 void GetWithCrc(uint16_t* pdata, size_t count);
54 bool CheckCrc();
55
56 int NakIndex() const;
57 uint8_t NakCode() const;
58
59 void Dump(std::ostream& os, int ind=0, const char* text=0,
60 int detail=0) const;
61
62 // statistics counter indices
63 enum stats {
81 };
82
83 protected:
84 void ProcessDataIdle();
85 void ProcessDataFill();
86 uint8_t GetEcode();
87
88 enum rcv_state {
93 };
94
95 protected:
96 uint8_t fRawBuf[4096];
97 size_t fRawBufSize;
98 size_t fRawBufDone;
100 size_t fNDone;
101 bool fEscSeen;
103 uint8_t fNakCode;
104 std::vector<uint8_t> fDropData;
105 };
106
107} // end namespace Retro
108
109#include "RlinkPacketBufRcv.ipp"
110
111#endif
FIXME_docs.
Definition: RerrMsg.hpp:25
bool CheckNak() const
FIXME_docs.
uint8_t GetEcode()
FIXME_docs.
uint8_t fNakCode
code of active nak
void GetWithCrc(uint8_t &data)
FIXME_docs.
@ kPktAttn
attn notify packet (ATTN+EOP)
@ kPktPend
pending, still being filled
@ kPktResp
response packet (SOP+EOP)
int NakIndex() const
FIXME_docs.
int fNakIndex
index of active nak (-1 if no)
enum rcv_state fRcvState
receive FSM state
@ kStatNRxNak
Rx NAK commas seen.
@ kStatNRxNakCnt
Rx NAK Cnt seen.
@ kStatNRxNakDcrc
Rx NAK Dcrc seen.
@ kStatNRxNakRtOvlf
Rx NAK RtOvlf seen.
@ kStatNRxDrop
Rx bytes dropped.
@ kStatNRxEsc
Rx data escapes.
@ kStatNRxNakRtWblk
Rx NAK RtWblk seen.
@ kStatNRxEop
Rx EOP commas seen.
@ kStatNRxNakCcrc
Rx NAK Ccrc seen.
@ kStatNRxNakFrame
Rx NAK Frame seen.
@ kStatNRxPktByt
Rx packet bytes rcvd.
@ kStatNRxSop
Rx SOP commas seen.
@ kStatNRxNakCmd
Rx NAK Cmd seen.
@ kStatNRxNakUnused
Rx NAK Unused seen.
@ kStatNRxNakInval
Rx NAK invalid seen.
@ kStatNRxAttn
Rx ATTN commas seen.
@ kStatNRxClobber
Rx clobbered escapes.
std::vector< uint8_t > fDropData
dropped data buffer
RlinkPacketBufRcv()
Default constructor.
void ProcessDataIdle()
FIXME_docs.
uint8_t fRawBuf[4096]
raw data buffer
uint8_t NakCode() const
FIXME_docs.
void ProcessDataFill()
FIXME_docs.
bool CheckSize(size_t nbyte) const
FIXME_docs.
bool fEscSeen
last char was Escape
void AcceptPacket()
FIXME_docs.
pkt_state PacketState()
FIXME_docs.
@ kRcvIdle
wait for SOP or ATTN
@ kRcvError
packet framing error
@ kRcvFill
fill packet till EOP seen
@ kRcvDone
packet ok, EOP seen
size_t fNDone
number of pkt bytes processed
int ReadData(RlinkPort &port, const Rtime &timeout, RerrMsg &emsg)
FIXME_docs.
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
FIXME_docs.
Definition: RlinkPort.hpp:45
FIXME_docs.
Definition: Rtime.hpp:25
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47