DESERT 3.5.1
Loading...
Searching...
No Matches
frame-set.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
38#ifndef FRAMESET_H
39#define FRAMESET_H
40
41#include <cstring>
42#include <iostream>
43#include <sstream>
44#include <stdio.h>
45#include <stdlib.h>
46#include <string.h>
47
48#include "stdint.h"
49
50#define MAX_BIN_PAYLOAD_ARRAY_LENGTH 2240
51
52#define MAX_BIN_PAYLOAD_CHECK_ARRAY_LENGTH \
53 ((MAX_BIN_PAYLOAD_ARRAY_LENGTH + sizeof(char) - 1) / sizeof(char))
54
55
56
58{
59
60 uint8_t srcID_;
61 unsigned int pktID_;
63public:
64 RxFrameSetKey(uint8_t, unsigned int);
65
67
71 inline uint8_t
72 srcID() const
73 {
74 return srcID_;
75 }
76
80 inline unsigned int
81 pktID() const
82 {
83 return pktID_;
84 }
85
86 bool operator<(RxFrameSetKey) const;
87
88 std::string displayKey() const;
89};
90
92{
93
103 bool error_;
104
105public:
106 RxFrameSet();
107
108 ~RxFrameSet();
109
113 inline int
115 {
116 return tot_length_;
117 }
118
122 inline size_t
124 {
125 return curr_length_;
126 }
127
131 inline double
133 {
134 return t_last_rx_frame_;
135 }
136
140 inline std::string
142 {
143 return binPayload(true);
144 }
145
146 inline void
148 {
149 error_ = true;
150 }
151
152 inline bool
153 getError() const
154 {
155 return error_;
156 }
157
163 std::string binPayload(bool) const;
164
165 void UpdateRxFrameSet(char *, size_t, size_t, int, double);
166
167 std::string displaySet();
168};
169
170#endif
bool operator<(RxFrameSetKey) const
Definition frame-set.cpp:74
uint8_t srcID() const
Return the srcID_ variable.
Definition frame-set.h:72
unsigned int pktID_
ID of the packet.
Definition frame-set.h:61
uint8_t srcID_
ID of the packet's source node.
Definition frame-set.h:60
std::string displayKey() const
Definition frame-set.cpp:84
unsigned int pktID() const
Return the pktID_ variable.
Definition frame-set.h:81
bool error_
Definition frame-set.h:103
char binPayloadCheck_[MAX_BIN_PAYLOAD_CHECK_ARRAY_LENGTH]
array to count already received frames.
Definition frame-set.h:98
size_t curr_length_
Definition frame-set.h:101
int tot_length_
Definition frame-set.h:100
size_t curr_length() const
Reference to the curr_length_ variable.
Definition frame-set.h:123
char binPayload_[MAX_BIN_PAYLOAD_ARRAY_LENGTH]
array to store binary data received as frames.
Definition frame-set.h:94
std::string displaySet()
bool getError() const
Definition frame-set.h:153
void setError()
Definition frame-set.h:147
std::string binPayload() const
Return the content of the binPayload_ from 0 until tot_length_ array.
Definition frame-set.h:141
void UpdateRxFrameSet(char *, size_t, size_t, int, double)
int tot_length() const
Reference to the tot_length_ variable.
Definition frame-set.h:114
double t_last_rx_frame_
Definition frame-set.h:102
double t_last_rx_frame() const
Reference to the pktID_ variable.
Definition frame-set.h:132
#define MAX_BIN_PAYLOAD_ARRAY_LENGTH
Definition frame-set.h:50
#define MAX_BIN_PAYLOAD_CHECK_ARRAY_LENGTH
Definition frame-set.h:52