DESERT 3.5.1
Loading...
Searching...
No Matches
uwranging_tdoa_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_TDOA_HDR_H
41#define UWRANGING_TDOA_HDR_H
42
43#include <packet.h>
44#include <sys/types.h>
45#include <cmath>
46
47#define MAX_NUM_NODES 32
48#define HDR_RANGING_TDOA(p) \
49 (hdr_ranging_tdoa::access( \
50 p))
52extern packet_t PT_UWRANGING_TDOA;
53
54typedef float uwrange_time_t;
55typedef uint8_t uwrange_pkt_t;
56typedef uint8_t uwrange_node_t;
61typedef struct tdoa_entry {
82typedef struct hdr_ranging_tdoa {
83 static int offset_;
89 inline uint8_t &
91 {
93 }
94
99 size_t
100 getSize() const
101 {
102 return std::ceil(times_size_ * sizeof(tdoa_entry)
103 + sizeof(uwrange_node_t) + sizeof(uwrange_pkt_t));
104 }
105
111 static size_t
112 getSize(int entries)
113 {
114 return std::ceil(entries * sizeof(tdoa_entry)
115 + sizeof(uwrange_node_t) + sizeof(uwrange_pkt_t));
116 }
117
122 inline static int &
123 offset()
124 {
125 return offset_;
126 }
127
133 inline static struct hdr_ranging_tdoa *
134 access(const Packet *p)
135 {
136 return (struct hdr_ranging_tdoa *) p->access(offset_);
137 }
139
140#endif
Header of the token bus protocol.
static int offset_
Required by the PacketHeaderManager.
static struct hdr_ranging_tdoa * access(const Packet *p)
Returns a pointer to the tokenbus_ranging header of a packet.
size_t getSize() const
Returns the size of a ranging header with all the entries.
uwrange_node_t times_size_
static int & offset()
Returns a reference to the offset_ variable.
uwrange_pkt_t source_pkt_id
Ranging packet id.
uwrange_node_t source_node_id
Source node id.
tdoa_entry times_[MAX_NUM_NODES]
Number of entries in the packet.
Define the struct of a single tdoa payload entry.
uwrange_pkt_t id
Id of the packet.
uwrange_time_t time
Holdover time.
uwrange_node_t node
Id of the source node.
tdoa_entry()
float uwrange_time_t
set here the size and precision of the time measures (uint16/half/float...)
uint8_t uwrange_pkt_t
Number of bits to store a packet id.
#define MAX_NUM_NODES
float uwrange_time_t
Precision of the holdover times measurement.
uint8_t uwrange_node_t
Number of bits to store a node id.