Skip to content

Commit

Permalink
Add MsgMeasurementPoint [AP-653] (#1388)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
woodfell committed Jan 5, 2024
1 parent d9875ec commit eeeea1c
Show file tree
Hide file tree
Showing 59 changed files with 4,273 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ quicktype-javascript: deps-quicktype-javascript gen-quicktype-javascript test-qu
quicktype-elm: deps-quicktype-elm gen-quicktype-elm test-quicktype-elm
quicktype: quicktype-typescript quicktype-javascript quicktype-elm

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

# Prerequisite verification
verify-prereq-generator:
ifeq ($(OS), Windows_NT)
Expand Down
1 change: 1 addition & 0 deletions c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ swift_c_library(
"src/observation.c",
"src/orientation.c",
"src/piksi.c",
"src/profiling.c",
"src/sbas.c",
"src/settings.c",
"src/signing.c",
Expand Down
37 changes: 37 additions & 0 deletions c/include/libsbp/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <libsbp/observation.h>
#include <libsbp/orientation.h>
#include <libsbp/piksi.h>
#include <libsbp/profiling.h>
#include <libsbp/sbas.h>
#include <libsbp/sbp_msg.h>
#include <libsbp/sbp_msg_type.h>
Expand Down Expand Up @@ -4241,6 +4242,42 @@ struct MessageTraits<sbp_msg_mask_satellite_t> {
}
};

template <>
struct MessageTraits<sbp_msg_measurement_point_t> {
static constexpr sbp_msg_type_t id = SbpMsgMeasurementPoint;
static constexpr const char *name = "MSG_MEASUREMENT_POINT";
static const sbp_msg_measurement_point_t &get(const sbp_msg_t &msg) {
return msg.measurement_point;
}
static sbp_msg_measurement_point_t &get(sbp_msg_t &msg) {
return msg.measurement_point;
}
static void to_sbp_msg(const sbp_msg_measurement_point_t &msg,
sbp_msg_t *sbp_msg) {
sbp_msg->measurement_point = msg;
}
static sbp_msg_t to_sbp_msg(const sbp_msg_measurement_point_t &msg) {
sbp_msg_t sbp_msg;
sbp_msg.measurement_point = msg;
return sbp_msg;
}
static s8 send(sbp_state_t *state, u16 sender_id,
const sbp_msg_measurement_point_t &msg, sbp_write_fn_t write) {
return sbp_msg_measurement_point_send(state, sender_id, &msg, write);
}
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_measurement_point_t &msg) {
return sbp_msg_measurement_point_encode(buf, len, n_written, &msg);
}
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
sbp_msg_measurement_point_t *msg) {
return sbp_msg_measurement_point_decode(buf, len, n_read, msg);
}
static size_t encoded_len(const sbp_msg_measurement_point_t &msg) {
return sbp_msg_measurement_point_encoded_len(&msg);
}
};

template <>
struct MessageTraits<sbp_msg_measurement_state_t> {
static constexpr sbp_msg_type_t id = SbpMsgMeasurementState;
Expand Down
7 changes: 7 additions & 0 deletions c/include/libsbp/legacy/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <libsbp/legacy/observation.h>
#include <libsbp/legacy/orientation.h>
#include <libsbp/legacy/piksi.h>
#include <libsbp/legacy/profiling.h>
#include <libsbp/legacy/sbas.h>
#include <libsbp/legacy/settings.h>
#include <libsbp/legacy/signing.h>
Expand Down Expand Up @@ -1299,6 +1300,12 @@ struct MessageTraits<msg_linux_sys_state_t> {
};


template<>
struct MessageTraits<msg_measurement_point_t> {
static constexpr u16 id = 52992;
};


template<>
struct MessageTraits<msg_startup_t> {
static constexpr u16 id = 65280;
Expand Down
62 changes: 62 additions & 0 deletions c/include/libsbp/legacy/profiling.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2015-2021 Swift Navigation Inc.
* Contact: https://support.swiftnav.com
*
* This source is subject to the license found in the file 'LICENSE' which must
* be be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

/*****************************************************************************
* Automatically generated from yaml/swiftnav/sbp/profiling.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/

/** \defgroup profiling Profiling
*
* Standardized profiling messages from Swift Navigation devices.
* \{ */

#ifndef LIBSBP_LEGACY_PROFILING_MESSAGES_H
#define LIBSBP_LEGACY_PROFILING_MESSAGES_H

#include <libsbp/common.h>

SBP_MESSAGE(
"The legacy libsbp API has been deprecated. This file and all symbols "
"contained will "
"be removed in version 6. You should immediately switch over to the modern "
"libsbp API.")

#include <libsbp/profiling_macros.h>

SBP_PACK_START

/** Profiling Measurement Point
*
* Tracks execution time of certain code paths in specially built products.
* This message should only be expected and processed on the direction of
* Swift's engineering teams.
*/

typedef struct SBP_ATTR_PACKED SBP_DEPRECATED {
u32 total_time; /**< Total time spent in measurement point
(microseconds) */
u16 num_executions; /**< Number of times measurement point has executed */
u32 min; /**< Minimum execution time (microseconds) */
u32 max; /**< Maximum execution time (microseconds) */
u64 return_addr; /**< Return address */
u64 id; /**< Unique ID */
u64 slice_time; /**< CPU slice time (milliseconds) */
u16 line; /**< Line number */
char func[0]; /**< Function name */
} msg_measurement_point_t;

/** \} */

SBP_PACK_END

#endif /* LIBSBP_LEGACY_PROFILING_MESSAGES_H */
22 changes: 22 additions & 0 deletions c/include/libsbp/profiling.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2015-2021 Swift Navigation Inc.
* Contact: https://support.swiftnav.com
*
* This source is subject to the license found in the file 'LICENSE' which must
* be be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

/*****************************************************************************
* Automatically generated from yaml/swiftnav/sbp/profiling.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/

#ifndef LIBSBP_V4_PROFILING_MESSAGES_H
#define LIBSBP_V4_PROFILING_MESSAGES_H
#include <libsbp/profiling/MSG_MEASUREMENT_POINT.h>

#endif /* LIBSBP_V4_PROFILING_MESSAGES_H */
Loading

0 comments on commit eeeea1c

Please sign in to comment.