w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlinkPacketBufRcv.ipp
Go to the documentation of this file.
1// $Id: RlinkPacketBufRcv.ipp 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.0.1 add Nak handling
8// 2014-11-23 606 1.0 Initial version
9// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
10// ---------------------------------------------------------------------------
11
16// all method definitions in namespace Retro
17namespace Retro {
18
19//------------------------------------------+-----------------------------------
21
22inline bool RlinkPacketBufRcv::CheckNak() const
23{
24 return fNakIndex >= 0 && int(fNDone) == fNakIndex;
25}
26
27//------------------------------------------+-----------------------------------
29
30inline bool RlinkPacketBufRcv::CheckSize(size_t nbyte) const
31{
32 return fPktBuf.size()-fNDone >= nbyte;
33}
34
35//------------------------------------------+-----------------------------------
37
38inline void RlinkPacketBufRcv::GetWithCrc(uint8_t& data)
39{
40 data = fPktBuf[fNDone++];
41 fCrc.AddData(data);
42}
43
44//------------------------------------------+-----------------------------------
46
47inline void RlinkPacketBufRcv::GetWithCrc(uint16_t& data)
48{
49 uint8_t datl = fPktBuf[fNDone++];
50 uint8_t dath = fPktBuf[fNDone++];
51 fCrc.AddData(datl);
52 fCrc.AddData(dath);
53 data = uint16_t(datl) | (uint16_t(dath) << 8);
54}
55
56//------------------------------------------+-----------------------------------
58
60{
61 uint8_t datl = fPktBuf[fNDone++];
62 uint8_t dath = fPktBuf[fNDone++];
63 uint16_t data = uint16_t(datl) | (uint16_t(dath) << 8);
64 return data == fCrc.Crc();
65}
66
67//------------------------------------------+-----------------------------------
69
71{
72 return fNakIndex;
73}
74
75//------------------------------------------+-----------------------------------
77
78inline uint8_t RlinkPacketBufRcv::NakCode() const
79{
80 return fNakCode;
81}
82
83} // end namespace Retro
uint16_t Crc() const
FIXME_docs.
Definition: RlinkCrc16.ipp:48
void AddData(uint8_t data)
FIXME_docs.
Definition: RlinkCrc16.ipp:38
bool CheckNak() const
FIXME_docs.
uint8_t fNakCode
code of active nak
void GetWithCrc(uint8_t &data)
FIXME_docs.
int NakIndex() const
FIXME_docs.
int fNakIndex
index of active nak (-1 if no)
uint8_t NakCode() const
FIXME_docs.
bool CheckSize(size_t nbyte) const
FIXME_docs.
size_t fNDone
number of pkt bytes processed
RlinkCrc16 fCrc
crc accumulator
std::vector< uint8_t > fPktBuf
packet buffer
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47