Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new update status message [ASF-128] #1095

Merged
merged 7 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions c/include/libsbp/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -4983,6 +4983,41 @@ struct MessageTraits<sbp_msg_sbas_raw_t> {
}
};

template <>
struct MessageTraits<sbp_msg_sensor_aid_event_t> {
static constexpr sbp_msg_type_t id = SbpMsgSensorAidEvent;
static const sbp_msg_sensor_aid_event_t &get(const sbp_msg_t &msg) {
return msg.sensor_aid_event;
}
static sbp_msg_sensor_aid_event_t &get(sbp_msg_t &msg) {
return msg.sensor_aid_event;
}
static void to_sbp_msg(const sbp_msg_sensor_aid_event_t &msg,
sbp_msg_t *sbp_msg) {
sbp_msg->sensor_aid_event = msg;
}
static sbp_msg_t to_sbp_msg(const sbp_msg_sensor_aid_event_t &msg) {
sbp_msg_t sbp_msg;
sbp_msg.sensor_aid_event = msg;
return sbp_msg;
}
static s8 send(sbp_state_t *state, u16 sender_id,
const sbp_msg_sensor_aid_event_t &msg, sbp_write_fn_t write) {
return sbp_msg_sensor_aid_event_send(state, sender_id, &msg, write);
}
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_sensor_aid_event_t &msg) {
return sbp_msg_sensor_aid_event_encode(buf, len, n_written, &msg);
}
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
sbp_msg_sensor_aid_event_t *msg) {
return sbp_msg_sensor_aid_event_decode(buf, len, n_read, msg);
}
static size_t encoded_len(const sbp_msg_sensor_aid_event_t &msg) {
return sbp_msg_sensor_aid_event_encoded_len(&msg);
}
};

template <>
struct MessageTraits<sbp_msg_set_time_t> {
static constexpr sbp_msg_type_t id = SbpMsgSetTime;
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 @@ -1176,6 +1176,12 @@ struct MessageTraits<msg_pps_time_t> {
};


template<>
struct MessageTraits<msg_sensor_aid_event_t> {
static constexpr u16 id = 65289;
};


template<>
struct MessageTraits<msg_group_meta_t> {
static constexpr u16 id = 65290;
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 @@ -196,6 +196,25 @@ typedef struct SBP_ATTR_PACKED {
u8 flags; /**< Status flags */
} msg_pps_time_t;

/** Sensor state and update status data
*
* This diagnostic message contains state and update status information for
* all sensors that are being used by the fusion engine. This message will be
* generated asynchronously to the solution messages and will be emitted
* anytime a sensor update is being processed.
*/

typedef struct SBP_ATTR_PACKED {
u32 time; /**< Update timestamp in milliseconds. [milliseconds] */
u8 sensor_type; /**< Sensor type */
u16 sensor_id; /**< Sensor identifier */
u8 sensor_state; /**< Reserved for future use */
u8 n_available_meas; /**< Number of available measurements in this epoch */
u8 n_attempted_meas; /**< Number of attempted measurements in this epoch */
u8 n_accepted_meas; /**< Number of accepted measurements in this epoch */
u32 flags; /**< Reserved for future use */
} msg_sensor_aid_event_t;

/** Solution Group Metadata
*
* This leading message lists the time metadata of the Solution Group. It also
Expand Down
1 change: 1 addition & 0 deletions c/include/libsbp/sbp_msg_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ typedef enum {
SbpMsgResetFilters = SBP_MSG_RESET_FILTERS,
SbpMsgReset = SBP_MSG_RESET,
SbpMsgSbasRaw = SBP_MSG_SBAS_RAW,
SbpMsgSensorAidEvent = SBP_MSG_SENSOR_AID_EVENT,
SbpMsgSetTime = SBP_MSG_SET_TIME,
SbpMsgSettingsReadByIndexDone = SBP_MSG_SETTINGS_READ_BY_INDEX_DONE,
SbpMsgSettingsReadByIndexReq = SBP_MSG_SETTINGS_READ_BY_INDEX_REQ,
Expand Down
27 changes: 27 additions & 0 deletions c/include/libsbp/system_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,33 @@
*/
#define SBP_MSG_PPS_TIME_ENCODED_LEN 9u

#define SBP_MSG_SENSOR_AID_EVENT 0xFF09
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_MASK (0xff)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_SHIFT (0u)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_GET(flags) \
((u8)(((flags) >> SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_SHIFT) & \
SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_MASK))
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_SET(flags, val) \
do { \
(flags) = \
(u8)((flags) | (((val) & (SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_MASK)) \
<< (SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_SHIFT))); \
} while (0)

#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_GNSS_POSITION (0)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_GNSS_AVERAGE_VELOCITY (1)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_GNSS_INSTANTANEOUS_VELOCITY (2)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_WHEEL_TICKS (3)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_WHEEL_SPEED (4)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_IMU (5)
#define SBP_SENSOR_AID_EVENT_TYPE_IDENTIFIER_TIME_DIFFERENCES_OF_CARRIER_PHASE \
(6)
/**
* Encoded length of sbp_msg_sensor_aid_event_t (V4 API) and
* msg_sensor_aid_event_t (legacy API)
*/
#define SBP_MSG_SENSOR_AID_EVENT_ENCODED_LEN 15u

#define SBP_MSG_GROUP_META 0xFF0A
#define SBP_GROUP_META_SOLUTION_GROUP_TYPE_MASK (0x3)
#define SBP_GROUP_META_SOLUTION_GROUP_TYPE_SHIFT (0u)
Expand Down
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 @@ -197,6 +197,7 @@ typedef union {
sbp_msg_reset_filters_t reset_filters;
sbp_msg_reset_t reset;
sbp_msg_sbas_raw_t sbas_raw;
sbp_msg_sensor_aid_event_t sensor_aid_event;
sbp_msg_set_time_t set_time;
sbp_msg_settings_read_by_index_done_t settings_read_by_index_done;
sbp_msg_settings_read_by_index_req_t settings_read_by_index_req;
Expand Down Expand Up @@ -657,6 +658,9 @@ static inline s8 sbp_message_encode(uint8_t *buf, uint8_t len,
return sbp_msg_reset_encode(buf, len, n_written, &msg->reset);
case SbpMsgSbasRaw:
return sbp_msg_sbas_raw_encode(buf, len, n_written, &msg->sbas_raw);
case SbpMsgSensorAidEvent:
return sbp_msg_sensor_aid_event_encode(buf, len, n_written,
&msg->sensor_aid_event);
case SbpMsgSetTime:
return sbp_msg_set_time_encode(buf, len, n_written, &msg->set_time);
case SbpMsgSettingsReadByIndexDone:
Expand Down Expand Up @@ -1219,6 +1223,9 @@ static inline s8 sbp_message_decode(const uint8_t *buf, uint8_t len,
return sbp_msg_reset_decode(buf, len, n_read, &msg->reset);
case SbpMsgSbasRaw:
return sbp_msg_sbas_raw_decode(buf, len, n_read, &msg->sbas_raw);
case SbpMsgSensorAidEvent:
return sbp_msg_sensor_aid_event_decode(buf, len, n_read,
&msg->sensor_aid_event);
case SbpMsgSetTime:
return sbp_msg_set_time_decode(buf, len, n_read, &msg->set_time);
case SbpMsgSettingsReadByIndexDone:
Expand Down Expand Up @@ -1703,6 +1710,8 @@ static inline size_t sbp_message_encoded_len(sbp_msg_type_t msg_type,
return sbp_msg_reset_encoded_len(&msg->reset);
case SbpMsgSbasRaw:
return sbp_msg_sbas_raw_encoded_len(&msg->sbas_raw);
case SbpMsgSensorAidEvent:
return sbp_msg_sensor_aid_event_encoded_len(&msg->sensor_aid_event);
case SbpMsgSetTime:
return sbp_msg_set_time_encoded_len(&msg->set_time);
case SbpMsgSettingsReadByIndexDone:
Expand Down Expand Up @@ -2209,6 +2218,9 @@ static inline int sbp_message_cmp(sbp_msg_type_t msg_type, const sbp_msg_t *a,
return sbp_msg_reset_cmp(&a->reset, &b->reset);
case SbpMsgSbasRaw:
return sbp_msg_sbas_raw_cmp(&a->sbas_raw, &b->sbas_raw);
case SbpMsgSensorAidEvent:
return sbp_msg_sensor_aid_event_cmp(&a->sensor_aid_event,
&b->sensor_aid_event);
case SbpMsgSetTime:
return sbp_msg_set_time_cmp(&a->set_time, &b->set_time);
case SbpMsgSettingsReadByIndexDone:
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 @@ -26,6 +26,7 @@
#include <libsbp/v4/system/MSG_INS_STATUS.h>
#include <libsbp/v4/system/MSG_INS_UPDATES.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>
#include <libsbp/v4/system/MSG_STATUS_REPORT.h>
#include <libsbp/v4/system/SubSystemReport.h>
Expand Down
216 changes: 216 additions & 0 deletions c/include/libsbp/v4/system/MSG_SENSOR_AID_EVENT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/*
* 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/system.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/

#ifndef LIBSBP_V4_SYSTEM_MSG_SENSOR_AID_EVENT_H
#define LIBSBP_V4_SYSTEM_MSG_SENSOR_AID_EVENT_H

#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <libsbp/common.h>
#include <libsbp/system_macros.h>
#include <libsbp/v4/string/sbp_string.h>

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
*
* SBP_MSG_SENSOR_AID_EVENT
*
*****************************************************************************/
/** Sensor state and update status data
*
* This diagnostic message contains state and update status information for all
* sensors that are being used by the fusion engine. This message will be
* generated asynchronously to the solution messages and will be emitted anytime
* a sensor update is being processed.
*/
typedef struct {
/**
* Update timestamp in milliseconds. [milliseconds]
*/
u32 time;

/**
* Sensor type
*/
u8 sensor_type;

/**
* Sensor identifier
*/
u16 sensor_id;

/**
* Reserved for future use
*/
u8 sensor_state;

/**
* Number of available measurements in this epoch
*/
u8 n_available_meas;

/**
* Number of attempted measurements in this epoch
*/
u8 n_attempted_meas;

/**
* Number of accepted measurements in this epoch
*/
u8 n_accepted_meas;

/**
* Reserved for future use
*/
u32 flags;
} sbp_msg_sensor_aid_event_t;

/**
* Get encoded size of an instance of sbp_msg_sensor_aid_event_t
*
* @param msg sbp_msg_sensor_aid_event_t instance
* @return Length of on-wire representation
*/
static inline size_t sbp_msg_sensor_aid_event_encoded_len(
const sbp_msg_sensor_aid_event_t *msg) {
(void)msg;
return SBP_MSG_SENSOR_AID_EVENT_ENCODED_LEN;
}

/**
* Encode an instance of sbp_msg_sensor_aid_event_t to wire representation
*
* This function encodes the given instance in to the user provided buffer. The
* buffer provided to this function must be large enough to store the encoded
* message otherwise it will return SBP_ENCODE_ERROR without writing anything to
* the buffer.
*
* Specify the length of the destination buffer in the \p len parameter. If
* non-null the number of bytes written to the buffer will be returned in \p
* n_written.
*
* @param buf Destination buffer
* @param len Length of \p buf
* @param n_written If not null, on success will be set to the number of bytes
* written to \p buf
* @param msg Instance of sbp_msg_sensor_aid_event_t to encode
* @return SBP_OK on success, or other libsbp error code
*/
SBP_EXPORT s8
sbp_msg_sensor_aid_event_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_sensor_aid_event_t *msg);

/**
* Decode an instance of sbp_msg_sensor_aid_event_t from wire representation
*
* This function decodes the wire representation of a sbp_msg_sensor_aid_event_t
* message to the given instance. The caller must specify the length of the
* buffer in the \p len parameter. If non-null the number of bytes read from the
* buffer will be returned in \p n_read.
*
* @param buf Wire representation of the sbp_msg_sensor_aid_event_t instance
* @param len Length of \p buf
* @param n_read If not null, on success will be set to the number of bytes read
* from \p buf
* @param msg Destination
* @return SBP_OK on success, or other libsbp error code
*/
SBP_EXPORT s8 sbp_msg_sensor_aid_event_decode(const uint8_t *buf, uint8_t len,
uint8_t *n_read,
sbp_msg_sensor_aid_event_t *msg);
/**
* Send an instance of sbp_msg_sensor_aid_event_t with the given write function
*
* An equivalent of #sbp_message_send which operates specifically on
* sbp_msg_sensor_aid_event_t
*
* The given message will be encoded to wire representation and passed in to the
* given write function callback. The write callback will be called several
* times for each invocation of this function.
*
* @param s SBP state
* @param sender_id SBP sender id
* @param msg Message to send
* @param write Write function
* @return SBP_OK on success, or other libsbp error code
*/
SBP_EXPORT s8 sbp_msg_sensor_aid_event_send(
sbp_state_t *s, u16 sender_id, const sbp_msg_sensor_aid_event_t *msg,
sbp_write_fn_t write);

/**
* Compare two instances of sbp_msg_sensor_aid_event_t
*
* The two instances will be compared and a value returned consistent with the
* return codes of comparison functions from the C standard library
*
* 0 will be returned if \p a and \p b are considered equal
* A value less than 0 will be returned if \p a is considered to be less than \p
* b A value greater than 0 will be returned if \p b is considered to be greater
* than \p b
*
* @param a sbp_msg_sensor_aid_event_t instance
* @param b sbp_msg_sensor_aid_event_t instance
* @return 0, <0, >0
*/
SBP_EXPORT int sbp_msg_sensor_aid_event_cmp(
const sbp_msg_sensor_aid_event_t *a, const sbp_msg_sensor_aid_event_t *b);

#ifdef __cplusplus
}

static inline bool operator==(const sbp_msg_sensor_aid_event_t &lhs,
const sbp_msg_sensor_aid_event_t &rhs) {
return sbp_msg_sensor_aid_event_cmp(&lhs, &rhs) == 0;
}

static inline bool operator!=(const sbp_msg_sensor_aid_event_t &lhs,
const sbp_msg_sensor_aid_event_t &rhs) {
return sbp_msg_sensor_aid_event_cmp(&lhs, &rhs) != 0;
}

static inline bool operator<(const sbp_msg_sensor_aid_event_t &lhs,
const sbp_msg_sensor_aid_event_t &rhs) {
return sbp_msg_sensor_aid_event_cmp(&lhs, &rhs) < 0;
}

static inline bool operator<=(const sbp_msg_sensor_aid_event_t &lhs,
const sbp_msg_sensor_aid_event_t &rhs) {
return sbp_msg_sensor_aid_event_cmp(&lhs, &rhs) <= 0;
}

static inline bool operator>(const sbp_msg_sensor_aid_event_t &lhs,
const sbp_msg_sensor_aid_event_t &rhs) {
return sbp_msg_sensor_aid_event_cmp(&lhs, &rhs) > 0;
}

static inline bool operator>=(const sbp_msg_sensor_aid_event_t &lhs,
const sbp_msg_sensor_aid_event_t &rhs) {
return sbp_msg_sensor_aid_event_cmp(&lhs, &rhs) >= 0;
}

#endif // ifdef __cplusplus

#endif /* LIBSBP_V4_SYSTEM_MSG_SENSOR_AID_EVENT_H */
Loading