Skip to content

Commit eeeea1c

Browse files
authored
Add MsgMeasurementPoint [AP-653] (#1388)
# Description @swift-nav/devinfra Create a new message to output profiling information from measurement points. Current version of some product will output measurement point profiling information in the LinuxCPUState message making use of the `cmdline` field to serialise various bits of information. Some other bits of information are placed in to the other fields in LinuxCpuState but since the fields are already defined the names are misleading. This PR introduces a dedicated message which contains the same information as is currently sent but broken out in to fields with the correct types. This removes the need to serialise/deserialise this information once products are updated to use this message instead. # 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: No # JIRA Reference https://swift-nav.atlassian.net/browse/AP-653
1 parent d9875ec commit eeeea1c

Some content is hidden

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

59 files changed

+4273
-6
lines changed

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ quicktype-javascript: deps-quicktype-javascript gen-quicktype-javascript test-qu
9696
quicktype-elm: deps-quicktype-elm gen-quicktype-elm test-quicktype-elm
9797
quicktype: quicktype-typescript quicktype-javascript quicktype-elm
9898

99+
gen-all: gen-c gen-python gen-javascript gen-java gen-haskell gen-rust gen-protobuf gen-kaitai gen-jsonschema gen-quicktype-typescript gen-quicktype-javascript gen-quicktype-elm
100+
99101
# Prerequisite verification
100102
verify-prereq-generator:
101103
ifeq ($(OS), Windows_NT)

c/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ swift_c_library(
3737
"src/observation.c",
3838
"src/orientation.c",
3939
"src/piksi.c",
40+
"src/profiling.c",
4041
"src/sbas.c",
4142
"src/settings.c",
4243
"src/signing.c",

c/include/libsbp/cpp/message_traits.h

+37
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <libsbp/observation.h>
3333
#include <libsbp/orientation.h>
3434
#include <libsbp/piksi.h>
35+
#include <libsbp/profiling.h>
3536
#include <libsbp/sbas.h>
3637
#include <libsbp/sbp_msg.h>
3738
#include <libsbp/sbp_msg_type.h>
@@ -4241,6 +4242,42 @@ struct MessageTraits<sbp_msg_mask_satellite_t> {
42414242
}
42424243
};
42434244

4245+
template <>
4246+
struct MessageTraits<sbp_msg_measurement_point_t> {
4247+
static constexpr sbp_msg_type_t id = SbpMsgMeasurementPoint;
4248+
static constexpr const char *name = "MSG_MEASUREMENT_POINT";
4249+
static const sbp_msg_measurement_point_t &get(const sbp_msg_t &msg) {
4250+
return msg.measurement_point;
4251+
}
4252+
static sbp_msg_measurement_point_t &get(sbp_msg_t &msg) {
4253+
return msg.measurement_point;
4254+
}
4255+
static void to_sbp_msg(const sbp_msg_measurement_point_t &msg,
4256+
sbp_msg_t *sbp_msg) {
4257+
sbp_msg->measurement_point = msg;
4258+
}
4259+
static sbp_msg_t to_sbp_msg(const sbp_msg_measurement_point_t &msg) {
4260+
sbp_msg_t sbp_msg;
4261+
sbp_msg.measurement_point = msg;
4262+
return sbp_msg;
4263+
}
4264+
static s8 send(sbp_state_t *state, u16 sender_id,
4265+
const sbp_msg_measurement_point_t &msg, sbp_write_fn_t write) {
4266+
return sbp_msg_measurement_point_send(state, sender_id, &msg, write);
4267+
}
4268+
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
4269+
const sbp_msg_measurement_point_t &msg) {
4270+
return sbp_msg_measurement_point_encode(buf, len, n_written, &msg);
4271+
}
4272+
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
4273+
sbp_msg_measurement_point_t *msg) {
4274+
return sbp_msg_measurement_point_decode(buf, len, n_read, msg);
4275+
}
4276+
static size_t encoded_len(const sbp_msg_measurement_point_t &msg) {
4277+
return sbp_msg_measurement_point_encoded_len(&msg);
4278+
}
4279+
};
4280+
42444281
template <>
42454282
struct MessageTraits<sbp_msg_measurement_state_t> {
42464283
static constexpr sbp_msg_type_t id = SbpMsgMeasurementState;

c/include/libsbp/legacy/cpp/message_traits.h

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <libsbp/legacy/observation.h>
2929
#include <libsbp/legacy/orientation.h>
3030
#include <libsbp/legacy/piksi.h>
31+
#include <libsbp/legacy/profiling.h>
3132
#include <libsbp/legacy/sbas.h>
3233
#include <libsbp/legacy/settings.h>
3334
#include <libsbp/legacy/signing.h>
@@ -1299,6 +1300,12 @@ struct MessageTraits<msg_linux_sys_state_t> {
12991300
};
13001301

13011302

1303+
template<>
1304+
struct MessageTraits<msg_measurement_point_t> {
1305+
static constexpr u16 id = 52992;
1306+
};
1307+
1308+
13021309
template<>
13031310
struct MessageTraits<msg_startup_t> {
13041311
static constexpr u16 id = 65280;

c/include/libsbp/legacy/profiling.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
/** \defgroup profiling Profiling
19+
*
20+
* Standardized profiling messages from Swift Navigation devices.
21+
* \{ */
22+
23+
#ifndef LIBSBP_LEGACY_PROFILING_MESSAGES_H
24+
#define LIBSBP_LEGACY_PROFILING_MESSAGES_H
25+
26+
#include <libsbp/common.h>
27+
28+
SBP_MESSAGE(
29+
"The legacy libsbp API has been deprecated. This file and all symbols "
30+
"contained will "
31+
"be removed in version 6. You should immediately switch over to the modern "
32+
"libsbp API.")
33+
34+
#include <libsbp/profiling_macros.h>
35+
36+
SBP_PACK_START
37+
38+
/** Profiling Measurement Point
39+
*
40+
* Tracks execution time of certain code paths in specially built products.
41+
* This message should only be expected and processed on the direction of
42+
* Swift's engineering teams.
43+
*/
44+
45+
typedef struct SBP_ATTR_PACKED SBP_DEPRECATED {
46+
u32 total_time; /**< Total time spent in measurement point
47+
(microseconds) */
48+
u16 num_executions; /**< Number of times measurement point has executed */
49+
u32 min; /**< Minimum execution time (microseconds) */
50+
u32 max; /**< Maximum execution time (microseconds) */
51+
u64 return_addr; /**< Return address */
52+
u64 id; /**< Unique ID */
53+
u64 slice_time; /**< CPU slice time (milliseconds) */
54+
u16 line; /**< Line number */
55+
char func[0]; /**< Function name */
56+
} msg_measurement_point_t;
57+
58+
/** \} */
59+
60+
SBP_PACK_END
61+
62+
#endif /* LIBSBP_LEGACY_PROFILING_MESSAGES_H */

c/include/libsbp/profiling.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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_V4_PROFILING_MESSAGES_H
19+
#define LIBSBP_V4_PROFILING_MESSAGES_H
20+
#include <libsbp/profiling/MSG_MEASUREMENT_POINT.h>
21+
22+
#endif /* LIBSBP_V4_PROFILING_MESSAGES_H */

0 commit comments

Comments
 (0)