DESERT 4.0.0
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
56{
57
58 uint8_t srcID_;
59 unsigned int pktID_;
61public:
62 RxFrameSetKey(uint8_t, unsigned int);
63
65
69 inline uint8_t
70 srcID() const
71 {
72 return srcID_;
73 }
74
78 inline unsigned int
79 pktID() const
80 {
81 return pktID_;
82 }
83
84 bool operator<(RxFrameSetKey) const;
85
86 std::string displayKey() const;
87};
88
90{
91
92 char binPayload_[MAX_BIN_PAYLOAD_ARRAY_LENGTH];
96 [MAX_BIN_PAYLOAD_CHECK_ARRAY_LENGTH];
101 bool error_;
102
103public:
104 RxFrameSet();
105
106 ~RxFrameSet();
107
111 inline int
113 {
114 return tot_length_;
115 }
116
120 inline size_t
122 {
123 return curr_length_;
124 }
125
129 inline double
131 {
132 return t_last_rx_frame_;
133 }
134
138 inline std::string
140 {
141 return binPayload(true);
142 }
143
144 inline void
146 {
147 error_ = true;
148 }
149
150 inline bool
151 getError() const
152 {
153 return error_;
154 }
155
161 std::string binPayload(bool) const;
162
163 void UpdateRxFrameSet(char *, size_t, size_t, int, double);
164
165 std::string displaySet();
166};
167
168#endif
Definition frame-set.h:56
bool operator<(RxFrameSetKey) const
Definition frame-set.cpp:74
uint8_t srcID() const
Definition frame-set.h:70
unsigned int pktID_
Definition frame-set.h:59
uint8_t srcID_
Definition frame-set.h:58
~RxFrameSetKey()
Definition frame-set.cpp:69
std::string displayKey() const
Definition frame-set.cpp:84
unsigned int pktID() const
Definition frame-set.h:79
Definition frame-set.h:90
bool error_
Definition frame-set.h:101
char binPayloadCheck_[MAX_BIN_PAYLOAD_CHECK_ARRAY_LENGTH]
Definition frame-set.h:96
size_t curr_length_
Definition frame-set.h:99
int tot_length_
Definition frame-set.h:98
size_t curr_length() const
Definition frame-set.h:121
char binPayload_[MAX_BIN_PAYLOAD_ARRAY_LENGTH]
Definition frame-set.h:92
RxFrameSet()
Definition frame-set.cpp:95
std::string displaySet()
Definition frame-set.cpp:111
bool getError() const
Definition frame-set.h:151
~RxFrameSet()
Definition frame-set.cpp:106
void setError()
Definition frame-set.h:145
std::string binPayload() const
Definition frame-set.h:139
void UpdateRxFrameSet(char *, size_t, size_t, int, double)
Definition frame-set.cpp:150
int tot_length() const
Definition frame-set.h:112
double t_last_rx_frame_
Definition frame-set.h:100
double t_last_rx_frame() const
Definition frame-set.h:130