-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
DataLinkLayer.h
52 lines (33 loc) · 907 Bytes
/
DataLinkLayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef DATALINKLAYER_H_
#define DATALINKLAYER_H_
#include "Acceptor.h"
#include <vector>
using namespace std;
namespace MPOST
{
class CDataLinkLayer
{
public:
CDataLinkLayer(CAcceptor* acceptor);
void SendPacket(char payload[], int payloadLength);
char ComputeCheckSum(vector<char>);
vector<char>* ReceiveReply();
void WaitForQuiet();
bool ReplyAcked(vector<char>* reply);
void LogCommandAndReply(vector<char>& command, vector<char>& reply, bool wasEchoDiscarded);
void FlushIdenticalTransactionsToLog();
private:
CAcceptor* _acceptor;
static const char STX;
static const char ETX;
char _ackToggleBit;
char _nakCount;
static const char ACKMask;
vector<char> _currentCommand;
vector<char> _echoDetect;
vector<char> _previousCommand;
vector<char> _previousReply;
int _identicalCommandAndReplyCount;
};
}
#endif /*DATALINKLAYER_H_*/