Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
woodfell committed Dec 8, 2023
1 parent 3d8c0be commit 0ab7335
Show file tree
Hide file tree
Showing 46 changed files with 3,418 additions and 13 deletions.
36 changes: 36 additions & 0 deletions c/include/libsbp/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -4241,6 +4241,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
6 changes: 6 additions & 0 deletions c/include/libsbp/legacy/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,12 @@ struct MessageTraits<msg_group_meta_t> {
};


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


template<>
struct MessageTraits<msg_soln_meta_t> {
static constexpr u16 id = 65294;
Expand Down
19 changes: 19 additions & 0 deletions c/include/libsbp/legacy/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,25 @@ typedef struct SBP_ATTR_PACKED {
Solution Group, including GROUP_META itself */
} msg_group_meta_t;

/** 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 {
u32 total_time; /**< Total time spent in measurement point */
u16 num_executions; /**< Number of times measurement point has executed */
u32 min; /**< Minimum execution time */
u32 max; /**< Maximum execution time */
u64 return_addr; /**< Return address */
u64 id; /**< Unique ID */
u64 slice_time; /**< CPU slice time */
u16 line; /**< Line number */
char func[0]; /**< Function name */
} msg_measurement_point_t;

/** \} */

SBP_PACK_END
Expand Down
3 changes: 3 additions & 0 deletions c/include/libsbp/sbp_msg_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ typedef enum {
SbpMsgMagRaw = SBP_MSG_MAG_RAW,
SbpMsgMaskSatelliteDep = SBP_MSG_MASK_SATELLITE_DEP,
SbpMsgMaskSatellite = SBP_MSG_MASK_SATELLITE,
SbpMsgMeasurementPoint = SBP_MSG_MEASUREMENT_POINT,
SbpMsgMeasurementState = SBP_MSG_MEASUREMENT_STATE,
SbpMsgNapDeviceDnaReq = SBP_MSG_NAP_DEVICE_DNA_REQ,
SbpMsgNapDeviceDnaResp = SBP_MSG_NAP_DEVICE_DNA_RESP,
Expand Down Expand Up @@ -528,6 +529,8 @@ static inline const char *sbp_msg_type_to_string(sbp_msg_type_t msg_type) {
return "MSG_MASK_SATELLITE_DEP";
case SbpMsgMaskSatellite:
return "MSG_MASK_SATELLITE";
case SbpMsgMeasurementPoint:
return "MSG_MEASUREMENT_POINT";
case SbpMsgMeasurementState:
return "MSG_MEASUREMENT_STATE";
case SbpMsgNapDeviceDnaReq:
Expand Down
23 changes: 23 additions & 0 deletions c/include/libsbp/system_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -972,4 +972,27 @@
*/
#define SBP_MSG_GROUP_META_ENCODED_OVERHEAD 3u

#define SBP_MSG_MEASUREMENT_POINT 0xFF0B
/**
* The maximum number of items that can be stored in
* sbp_msg_measurement_point_t::func (V4 API) or msg_measurement_point_t::func
* (legacy API) before the maximum SBP message size is exceeded
*/
#define SBP_MSG_MEASUREMENT_POINT_FUNC_MAX 215u

/**
* Encoded length of sbp_msg_measurement_point_t (V4 API) and
* msg_measurement_point_t (legacy API)
*
* This type is not fixed size and an instance of this message may be longer
* than the value indicated by this symbol. Users of the V4 API should call
* #sbp_msg_measurement_point_encoded_len to determine the actual size of an
* instance of this message. Users of the legacy API are required to track the
* encoded message length when interacting with the legacy type.
*
* See the documentation for libsbp for more details regarding the message
* structure and its variable length component(s)
*/
#define SBP_MSG_MEASUREMENT_POINT_ENCODED_OVERHEAD 40u

#endif /* LIBSBP_SYSTEM_MACROS_H */
12 changes: 12 additions & 0 deletions c/include/libsbp/v4/sbp_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ typedef union {
sbp_msg_mag_raw_t mag_raw;
sbp_msg_mask_satellite_dep_t mask_satellite_dep;
sbp_msg_mask_satellite_t mask_satellite;
sbp_msg_measurement_point_t measurement_point;
sbp_msg_measurement_state_t measurement_state;
sbp_msg_nap_device_dna_req_t nap_device_dna_req;
sbp_msg_nap_device_dna_resp_t nap_device_dna_resp;
Expand Down Expand Up @@ -635,6 +636,9 @@ static inline s8 sbp_message_encode(uint8_t *buf, uint8_t len,
case SbpMsgMaskSatellite:
return sbp_msg_mask_satellite_encode(buf, len, n_written,
&msg->mask_satellite);
case SbpMsgMeasurementPoint:
return sbp_msg_measurement_point_encode(buf, len, n_written,
&msg->measurement_point);
case SbpMsgMeasurementState:
return sbp_msg_measurement_state_encode(buf, len, n_written,
&msg->measurement_state);
Expand Down Expand Up @@ -1290,6 +1294,9 @@ static inline s8 sbp_message_decode(const uint8_t *buf, uint8_t len,
case SbpMsgMaskSatellite:
return sbp_msg_mask_satellite_decode(buf, len, n_read,
&msg->mask_satellite);
case SbpMsgMeasurementPoint:
return sbp_msg_measurement_point_decode(buf, len, n_read,
&msg->measurement_point);
case SbpMsgMeasurementState:
return sbp_msg_measurement_state_decode(buf, len, n_read,
&msg->measurement_state);
Expand Down Expand Up @@ -1873,6 +1880,8 @@ static inline size_t sbp_message_encoded_len(sbp_msg_type_t msg_type,
return sbp_msg_mask_satellite_dep_encoded_len(&msg->mask_satellite_dep);
case SbpMsgMaskSatellite:
return sbp_msg_mask_satellite_encoded_len(&msg->mask_satellite);
case SbpMsgMeasurementPoint:
return sbp_msg_measurement_point_encoded_len(&msg->measurement_point);
case SbpMsgMeasurementState:
return sbp_msg_measurement_state_encoded_len(&msg->measurement_state);
case SbpMsgNapDeviceDnaReq:
Expand Down Expand Up @@ -2455,6 +2464,9 @@ static inline int sbp_message_cmp(sbp_msg_type_t msg_type, const sbp_msg_t *a,
&b->mask_satellite_dep);
case SbpMsgMaskSatellite:
return sbp_msg_mask_satellite_cmp(&a->mask_satellite, &b->mask_satellite);
case SbpMsgMeasurementPoint:
return sbp_msg_measurement_point_cmp(&a->measurement_point,
&b->measurement_point);
case SbpMsgMeasurementState:
return sbp_msg_measurement_state_cmp(&a->measurement_state,
&b->measurement_state);
Expand Down
1 change: 1 addition & 0 deletions c/include/libsbp/v4/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <libsbp/v4/system/MSG_HEARTBEAT.h>
#include <libsbp/v4/system/MSG_INS_STATUS.h>
#include <libsbp/v4/system/MSG_INS_UPDATES.h>
#include <libsbp/v4/system/MSG_MEASUREMENT_POINT.h>
#include <libsbp/v4/system/MSG_PPS_TIME.h>
#include <libsbp/v4/system/MSG_SENSOR_AID_EVENT.h>
#include <libsbp/v4/system/MSG_STARTUP.h>
Expand Down
Loading

0 comments on commit 0ab7335

Please sign in to comment.