DESERT 4.0.0
uwranging_tdma_hdr.h
Go to the documentation of this file.
1//
2// Copyright (c) 2022 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
40#ifndef UWRANGING_TDMA_HDR_H
41#define UWRANGING_TDMA_HDR_H
42
43#include <cstdint>
44#include <limits>
45#include <packet.h>
46#include <vector>
47// #include "half.hpp" //for using half precision library from
48// https://half.sourceforge.net/
49
50typedef uint_least16_t slotid_t;
51constexpr size_t SLOTIDMAX_HDR = std::numeric_limits<slotid_t>::max();
52extern packet_t PT_UWRANGING_TDMA;
53// typedef half_float::half uwrange_time_t; /**< set here the size and precision
54// of the time measures (uint16/half/float...)*/
55typedef float uwrange_time_t;
61typedef struct hdr_ranging_tdma {
62public:
63 static int offset_;
65 std::vector<uwrange_time_t>
72 slotid_t &
74 {
75 return (slotid_);
76 }
77
82 std::vector<uwrange_time_t> &
84 {
85 return (times_);
86 }
87
92 size_t
93 getSize() const
94 {
95 return (sizeof(uwrange_time_t) * times_.size() + sizeof(slotid_t));
96 }
97
102 inline static int &
104 {
105 return offset_;
106 }
107
113 inline static struct hdr_ranging_tdma *
114 access(const Packet *p)
115 {
116 return (struct hdr_ranging_tdma *) p->access(offset_);
117 }
119
120#define HDR_RANGING_TDMA(p) \
121 (hdr_ranging_tdma::access( \
122 p))
124#endif
Definition uwranging_tdma_hdr.h:61
slotid_t slotid_
Definition uwranging_tdma_hdr.h:64
static int & offset()
Definition uwranging_tdma_hdr.h:103
slotid_t & slotId()
Definition uwranging_tdma_hdr.h:73
size_t getSize() const
Definition uwranging_tdma_hdr.h:93
std::vector< uwrange_time_t > & times()
Definition uwranging_tdma_hdr.h:83
std::vector< uwrange_time_t > times_
Definition uwranging_tdma_hdr.h:66
static struct hdr_ranging_tdma * access(const Packet *p)
Definition uwranging_tdma_hdr.h:114
static int offset_
Definition uwranging_tdma_hdr.h:63
packet_t PT_UWRANGING_TDMA
Definition initlib.cpp:42
uint_least16_t slotid_t
Definition uwranging_tdma_hdr.h:50
constexpr size_t SLOTIDMAX_HDR
Definition uwranging_tdma_hdr.h:51
float uwrange_time_t
Definition uwranging_tdma_hdr.h:55