Skip to content

Commit 7da3bf7

Browse files
authored
Add profiling messages [AP-650] (#1401)
# Description @swift-nav/devinfra Add definitions and tests for 3 new messages - `MSG_PROFILING_RESOURCE_COUNTER` - `MSG_PROFILING_SYSTEM_INFO` - `MSG_PROFILING_THREAD_INFO` These messages are not intended for wide public use, the definitions and significance are defined elsewhere As always, only the changes under the `spec` directory are interesting, everything else is generated # API compatibility Does this change introduce a API compatibility risk? No ## API compatibility plan If the above is "Yes", please detail the compatibility (or migration) plan: N/A # JIRA Reference https://swift-nav.atlassian.net/browse/AP-650
1 parent 4bfa982 commit 7da3bf7

File tree

66 files changed

+12104
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+12104
-4
lines changed

c/include/libsbp/cpp/message_traits.h

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,6 +5357,118 @@ struct MessageTraits<sbp_msg_print_dep_t> {
53575357
}
53585358
};
53595359

5360+
template <>
5361+
struct MessageTraits<sbp_msg_profiling_resource_counter_t> {
5362+
static constexpr sbp_msg_type_t id = SbpMsgProfilingResourceCounter;
5363+
static constexpr const char *name = "MSG_PROFILING_RESOURCE_COUNTER";
5364+
static const sbp_msg_profiling_resource_counter_t &get(const sbp_msg_t &msg) {
5365+
return msg.profiling_resource_counter;
5366+
}
5367+
static sbp_msg_profiling_resource_counter_t &get(sbp_msg_t &msg) {
5368+
return msg.profiling_resource_counter;
5369+
}
5370+
static void to_sbp_msg(const sbp_msg_profiling_resource_counter_t &msg,
5371+
sbp_msg_t *sbp_msg) {
5372+
sbp_msg->profiling_resource_counter = msg;
5373+
}
5374+
static sbp_msg_t to_sbp_msg(const sbp_msg_profiling_resource_counter_t &msg) {
5375+
sbp_msg_t sbp_msg;
5376+
sbp_msg.profiling_resource_counter = msg;
5377+
return sbp_msg;
5378+
}
5379+
static s8 send(sbp_state_t *state, u16 sender_id,
5380+
const sbp_msg_profiling_resource_counter_t &msg,
5381+
sbp_write_fn_t write) {
5382+
return sbp_msg_profiling_resource_counter_send(state, sender_id, &msg,
5383+
write);
5384+
}
5385+
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
5386+
const sbp_msg_profiling_resource_counter_t &msg) {
5387+
return sbp_msg_profiling_resource_counter_encode(buf, len, n_written, &msg);
5388+
}
5389+
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
5390+
sbp_msg_profiling_resource_counter_t *msg) {
5391+
return sbp_msg_profiling_resource_counter_decode(buf, len, n_read, msg);
5392+
}
5393+
static size_t encoded_len(const sbp_msg_profiling_resource_counter_t &msg) {
5394+
return sbp_msg_profiling_resource_counter_encoded_len(&msg);
5395+
}
5396+
};
5397+
5398+
template <>
5399+
struct MessageTraits<sbp_msg_profiling_system_info_t> {
5400+
static constexpr sbp_msg_type_t id = SbpMsgProfilingSystemInfo;
5401+
static constexpr const char *name = "MSG_PROFILING_SYSTEM_INFO";
5402+
static const sbp_msg_profiling_system_info_t &get(const sbp_msg_t &msg) {
5403+
return msg.profiling_system_info;
5404+
}
5405+
static sbp_msg_profiling_system_info_t &get(sbp_msg_t &msg) {
5406+
return msg.profiling_system_info;
5407+
}
5408+
static void to_sbp_msg(const sbp_msg_profiling_system_info_t &msg,
5409+
sbp_msg_t *sbp_msg) {
5410+
sbp_msg->profiling_system_info = msg;
5411+
}
5412+
static sbp_msg_t to_sbp_msg(const sbp_msg_profiling_system_info_t &msg) {
5413+
sbp_msg_t sbp_msg;
5414+
sbp_msg.profiling_system_info = msg;
5415+
return sbp_msg;
5416+
}
5417+
static s8 send(sbp_state_t *state, u16 sender_id,
5418+
const sbp_msg_profiling_system_info_t &msg,
5419+
sbp_write_fn_t write) {
5420+
return sbp_msg_profiling_system_info_send(state, sender_id, &msg, write);
5421+
}
5422+
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
5423+
const sbp_msg_profiling_system_info_t &msg) {
5424+
return sbp_msg_profiling_system_info_encode(buf, len, n_written, &msg);
5425+
}
5426+
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
5427+
sbp_msg_profiling_system_info_t *msg) {
5428+
return sbp_msg_profiling_system_info_decode(buf, len, n_read, msg);
5429+
}
5430+
static size_t encoded_len(const sbp_msg_profiling_system_info_t &msg) {
5431+
return sbp_msg_profiling_system_info_encoded_len(&msg);
5432+
}
5433+
};
5434+
5435+
template <>
5436+
struct MessageTraits<sbp_msg_profiling_thread_info_t> {
5437+
static constexpr sbp_msg_type_t id = SbpMsgProfilingThreadInfo;
5438+
static constexpr const char *name = "MSG_PROFILING_THREAD_INFO";
5439+
static const sbp_msg_profiling_thread_info_t &get(const sbp_msg_t &msg) {
5440+
return msg.profiling_thread_info;
5441+
}
5442+
static sbp_msg_profiling_thread_info_t &get(sbp_msg_t &msg) {
5443+
return msg.profiling_thread_info;
5444+
}
5445+
static void to_sbp_msg(const sbp_msg_profiling_thread_info_t &msg,
5446+
sbp_msg_t *sbp_msg) {
5447+
sbp_msg->profiling_thread_info = msg;
5448+
}
5449+
static sbp_msg_t to_sbp_msg(const sbp_msg_profiling_thread_info_t &msg) {
5450+
sbp_msg_t sbp_msg;
5451+
sbp_msg.profiling_thread_info = msg;
5452+
return sbp_msg;
5453+
}
5454+
static s8 send(sbp_state_t *state, u16 sender_id,
5455+
const sbp_msg_profiling_thread_info_t &msg,
5456+
sbp_write_fn_t write) {
5457+
return sbp_msg_profiling_thread_info_send(state, sender_id, &msg, write);
5458+
}
5459+
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
5460+
const sbp_msg_profiling_thread_info_t &msg) {
5461+
return sbp_msg_profiling_thread_info_encode(buf, len, n_written, &msg);
5462+
}
5463+
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
5464+
sbp_msg_profiling_thread_info_t *msg) {
5465+
return sbp_msg_profiling_thread_info_decode(buf, len, n_read, msg);
5466+
}
5467+
static size_t encoded_len(const sbp_msg_profiling_thread_info_t &msg) {
5468+
return sbp_msg_profiling_thread_info_encoded_len(&msg);
5469+
}
5470+
};
5471+
53605472
template <>
53615473
struct MessageTraits<sbp_msg_protection_level_dep_a_t> {
53625474
static constexpr sbp_msg_type_t id = SbpMsgProtectionLevelDepA;

c/include/libsbp/profiling.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
#ifndef LIBSBP_PROFILING_MESSAGES_H
1919
#define LIBSBP_PROFILING_MESSAGES_H
2020
#include <libsbp/profiling/MSG_MEASUREMENT_POINT.h>
21+
#include <libsbp/profiling/MSG_PROFILING_RESOURCE_COUNTER.h>
22+
#include <libsbp/profiling/MSG_PROFILING_SYSTEM_INFO.h>
23+
#include <libsbp/profiling/MSG_PROFILING_THREAD_INFO.h>
24+
#include <libsbp/profiling/ResourceBucket.h>
2125

2226
#endif /* LIBSBP_PROFILING_MESSAGES_H */
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
/*
2+
* Copyright (C) 2015-2021 Swift Navigation Inc.
3+
* Contact: https://support.swiftnav.com
4+
*
5+
* This source is subject to the license found in the file 'LICENSE' which must
6+
* be be distributed together with this source. All other rights reserved.
7+
*
8+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
9+
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
10+
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
13+
/*****************************************************************************
14+
* Automatically generated from yaml/swiftnav/sbp/profiling.yaml
15+
* with generate.py. Please do not hand edit!
16+
*****************************************************************************/
17+
18+
#ifndef LIBSBP_PROFILING_MSG_PROFILING_RESOURCE_COUNTER_H
19+
#define LIBSBP_PROFILING_MSG_PROFILING_RESOURCE_COUNTER_H
20+
21+
#include <math.h>
22+
#include <stdarg.h>
23+
#include <stdbool.h>
24+
#include <stddef.h>
25+
#include <stdint.h>
26+
#include <string.h>
27+
28+
#include <libsbp/common.h>
29+
#include <libsbp/profiling/ResourceBucket.h>
30+
#include <libsbp/profiling_macros.h>
31+
#include <libsbp/string/sbp_string.h>
32+
33+
#ifdef __cplusplus
34+
extern "C" {
35+
#endif
36+
37+
/******************************************************************************
38+
*
39+
* SBP_MSG_PROFILING_RESOURCE_COUNTER
40+
*
41+
*****************************************************************************/
42+
/** Information about resource buckets
43+
*
44+
* Information about resource buckets. Refer to product documentation to
45+
* understand the meaning and values in this message.
46+
*/
47+
typedef struct {
48+
/**
49+
* Message number in complete sequence
50+
*/
51+
u8 seq_no;
52+
53+
/**
54+
* Length of message sequence
55+
*/
56+
u8 seq_len;
57+
58+
/**
59+
* List of resource buckets
60+
*/
61+
sbp_resource_bucket_t buckets[SBP_MSG_PROFILING_RESOURCE_COUNTER_BUCKETS_MAX];
62+
/**
63+
* Number of elements in buckets
64+
*
65+
* When sending a message fill in this field with the number elements set in
66+
* buckets before calling an appropriate libsbp send function
67+
*
68+
* When receiving a message query this field for the number of elements in
69+
* buckets. The value of any elements beyond the index specified in this field
70+
* is undefined
71+
*/
72+
u8 n_buckets;
73+
} sbp_msg_profiling_resource_counter_t;
74+
75+
/**
76+
* Get encoded size of an instance of sbp_msg_profiling_resource_counter_t
77+
*
78+
* @param msg sbp_msg_profiling_resource_counter_t instance
79+
* @return Length of on-wire representation
80+
*/
81+
static inline size_t sbp_msg_profiling_resource_counter_encoded_len(
82+
const sbp_msg_profiling_resource_counter_t *msg) {
83+
return SBP_MSG_PROFILING_RESOURCE_COUNTER_ENCODED_OVERHEAD +
84+
(msg->n_buckets * SBP_RESOURCE_BUCKET_ENCODED_LEN);
85+
}
86+
87+
/**
88+
* Encode an instance of sbp_msg_profiling_resource_counter_t to wire
89+
* representation
90+
*
91+
* This function encodes the given instance in to the user provided buffer. The
92+
* buffer provided to this function must be large enough to store the encoded
93+
* message otherwise it will return SBP_ENCODE_ERROR without writing anything to
94+
* the buffer.
95+
*
96+
* Specify the length of the destination buffer in the \p len parameter. If
97+
* non-null the number of bytes written to the buffer will be returned in \p
98+
* n_written.
99+
*
100+
* @param buf Destination buffer
101+
* @param len Length of \p buf
102+
* @param n_written If not null, on success will be set to the number of bytes
103+
* written to \p buf
104+
* @param msg Instance of sbp_msg_profiling_resource_counter_t to encode
105+
* @return SBP_OK on success, or other libsbp error code
106+
*/
107+
SBP_EXPORT s8 sbp_msg_profiling_resource_counter_encode(
108+
uint8_t *buf, uint8_t len, uint8_t *n_written,
109+
const sbp_msg_profiling_resource_counter_t *msg);
110+
111+
/**
112+
* Decode an instance of sbp_msg_profiling_resource_counter_t from wire
113+
* representation
114+
*
115+
* This function decodes the wire representation of a
116+
* sbp_msg_profiling_resource_counter_t message to the given instance. The
117+
* caller must specify the length of the buffer in the \p len parameter. If
118+
* non-null the number of bytes read from the buffer will be returned in \p
119+
* n_read.
120+
*
121+
* @param buf Wire representation of the sbp_msg_profiling_resource_counter_t
122+
* instance
123+
* @param len Length of \p buf
124+
* @param n_read If not null, on success will be set to the number of bytes read
125+
* from \p buf
126+
* @param msg Destination
127+
* @return SBP_OK on success, or other libsbp error code
128+
*/
129+
SBP_EXPORT s8 sbp_msg_profiling_resource_counter_decode(
130+
const uint8_t *buf, uint8_t len, uint8_t *n_read,
131+
sbp_msg_profiling_resource_counter_t *msg);
132+
/**
133+
* Send an instance of sbp_msg_profiling_resource_counter_t with the given write
134+
* function
135+
*
136+
* An equivalent of #sbp_message_send which operates specifically on
137+
* sbp_msg_profiling_resource_counter_t
138+
*
139+
* The given message will be encoded to wire representation and passed in to the
140+
* given write function callback. The write callback will be called several
141+
* times for each invocation of this function.
142+
*
143+
* @param s SBP state
144+
* @param sender_id SBP sender id
145+
* @param msg Message to send
146+
* @param write Write function
147+
* @return SBP_OK on success, or other libsbp error code
148+
*/
149+
SBP_EXPORT s8 sbp_msg_profiling_resource_counter_send(
150+
sbp_state_t *s, u16 sender_id,
151+
const sbp_msg_profiling_resource_counter_t *msg, sbp_write_fn_t write);
152+
153+
/**
154+
* Compare two instances of sbp_msg_profiling_resource_counter_t
155+
*
156+
* The two instances will be compared and a value returned consistent with the
157+
* return codes of comparison functions from the C standard library
158+
*
159+
* 0 will be returned if \p a and \p b are considered equal
160+
* A value less than 0 will be returned if \p a is considered to be less than \p
161+
* b A value greater than 0 will be returned if \p b is considered to be greater
162+
* than \p b
163+
*
164+
* @param a sbp_msg_profiling_resource_counter_t instance
165+
* @param b sbp_msg_profiling_resource_counter_t instance
166+
* @return 0, <0, >0
167+
*/
168+
SBP_EXPORT int sbp_msg_profiling_resource_counter_cmp(
169+
const sbp_msg_profiling_resource_counter_t *a,
170+
const sbp_msg_profiling_resource_counter_t *b);
171+
172+
#ifdef __cplusplus
173+
}
174+
175+
static inline bool operator==(const sbp_msg_profiling_resource_counter_t &lhs,
176+
const sbp_msg_profiling_resource_counter_t &rhs) {
177+
return sbp_msg_profiling_resource_counter_cmp(&lhs, &rhs) == 0;
178+
}
179+
180+
static inline bool operator!=(const sbp_msg_profiling_resource_counter_t &lhs,
181+
const sbp_msg_profiling_resource_counter_t &rhs) {
182+
return sbp_msg_profiling_resource_counter_cmp(&lhs, &rhs) != 0;
183+
}
184+
185+
static inline bool operator<(const sbp_msg_profiling_resource_counter_t &lhs,
186+
const sbp_msg_profiling_resource_counter_t &rhs) {
187+
return sbp_msg_profiling_resource_counter_cmp(&lhs, &rhs) < 0;
188+
}
189+
190+
static inline bool operator<=(const sbp_msg_profiling_resource_counter_t &lhs,
191+
const sbp_msg_profiling_resource_counter_t &rhs) {
192+
return sbp_msg_profiling_resource_counter_cmp(&lhs, &rhs) <= 0;
193+
}
194+
195+
static inline bool operator>(const sbp_msg_profiling_resource_counter_t &lhs,
196+
const sbp_msg_profiling_resource_counter_t &rhs) {
197+
return sbp_msg_profiling_resource_counter_cmp(&lhs, &rhs) > 0;
198+
}
199+
200+
static inline bool operator>=(const sbp_msg_profiling_resource_counter_t &lhs,
201+
const sbp_msg_profiling_resource_counter_t &rhs) {
202+
return sbp_msg_profiling_resource_counter_cmp(&lhs, &rhs) >= 0;
203+
}
204+
205+
#endif // ifdef __cplusplus
206+
207+
#endif /* LIBSBP_PROFILING_MSG_PROFILING_RESOURCE_COUNTER_H */

0 commit comments

Comments
 (0)