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))
52
extern
packet_t
PT_UWRANGING_TDOA
;
53
54
typedef
float
uwrange_time_t
;
55
typedef
uint8_t
uwrange_pkt_t
;
56
typedef
uint8_t
uwrange_node_t
;
61
typedef
struct
tdoa_entry
{
62
uwrange_time_t
time
;
63
uwrange_pkt_t
id
;
64
uwrange_node_t
node
;
66
tdoa_entry
(
uwrange_time_t
time
,
uwrange_node_t
node
,
uwrange_pkt_t
id
)
67
:
time
(
time
)
68
,
id
(
id
)
69
,
node
(
node
)
70
{
71
}
72
73
tdoa_entry
()
74
:
tdoa_entry
(-1., -1, -1)
75
{
76
}
77
}
tdoa_entry
;
78
82
typedef
struct
hdr_ranging_tdoa
{
83
static
int
offset_
;
84
uwrange_pkt_t
source_pkt_id
;
85
uwrange_node_t
source_node_id
;
86
uwrange_node_t
times_size_
;
87
tdoa_entry
times_
[
MAX_NUM_NODES
];
89
inline
uint8_t &
90
times_size
()
91
{
92
return
times_size_
;
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
}
138
}
hdr_ranging_tdoa
;
139
140
#endif
hdr_ranging_tdoa
Header of the token bus protocol.
Definition
uwranging_tdoa_hdr.h:84
hdr_ranging_tdoa::offset_
static int offset_
Required by the PacketHeaderManager.
Definition
uwranging_tdoa_hdr.h:85
hdr_ranging_tdoa::access
static struct hdr_ranging_tdoa * access(const Packet *p)
Returns a pointer to the tokenbus_ranging header of a packet.
Definition
uwranging_tdoa_hdr.h:136
hdr_ranging_tdoa::getSize
size_t getSize() const
Returns the size of a ranging header with all the entries.
Definition
uwranging_tdoa_hdr.h:102
hdr_ranging_tdoa::times_size_
uwrange_node_t times_size_
Definition
uwranging_tdoa_hdr.h:88
hdr_ranging_tdoa::times_size
uint8_t & times_size()
Definition
uwranging_tdoa_hdr.h:92
hdr_ranging_tdoa::offset
static int & offset()
Returns a reference to the offset_ variable.
Definition
uwranging_tdoa_hdr.h:125
hdr_ranging_tdoa::source_pkt_id
uwrange_pkt_t source_pkt_id
Ranging packet id.
Definition
uwranging_tdoa_hdr.h:86
hdr_ranging_tdoa::source_node_id
uwrange_node_t source_node_id
Source node id.
Definition
uwranging_tdoa_hdr.h:87
hdr_ranging_tdoa::times_
tdoa_entry times_[MAX_NUM_NODES]
Number of entries in the packet.
Definition
uwranging_tdoa_hdr.h:89
tdoa_entry
Define the struct of a single tdoa payload entry.
Definition
uwranging_tdoa_hdr.h:63
tdoa_entry::id
uwrange_pkt_t id
Id of the packet.
Definition
uwranging_tdoa_hdr.h:65
tdoa_entry::time
uwrange_time_t time
Holdover time.
Definition
uwranging_tdoa_hdr.h:64
tdoa_entry::node
uwrange_node_t node
Id of the source node.
Definition
uwranging_tdoa_hdr.h:66
tdoa_entry::tdoa_entry
tdoa_entry()
Definition
uwranging_tdoa_hdr.h:75
uwrange_time_t
float uwrange_time_t
set here the size and precision of the time measures (uint16/half/float...)
Definition
uwranging_tdma_hdr.h:53
PT_UWRANGING_TDOA
packet_t PT_UWRANGING_TDOA
Definition
DESERT_Framework/DESERT/ranging/uwranging_tdoa/initlib.cpp:42
uwrange_pkt_t
uint8_t uwrange_pkt_t
Number of bits to store a packet id.
Definition
uwranging_tdoa_hdr.h:57
MAX_NUM_NODES
#define MAX_NUM_NODES
Definition
uwranging_tdoa_hdr.h:47
uwrange_time_t
float uwrange_time_t
Precision of the holdover times measurement.
Definition
uwranging_tdoa_hdr.h:56
uwrange_node_t
uint8_t uwrange_node_t
Number of bits to store a node id.
Definition
uwranging_tdoa_hdr.h:58
DESERT_Framework
DESERT
ranging
uwranging_tdoa
uwranging_tdoa_hdr.h
Generated by
1.9.8