Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -2688,6 +2688,41 @@ struct MessageTraits<sbp_msg_gnss_time_offset_t> {
}
};

template <>
struct MessageTraits<sbp_msg_gps_leap_second_t> {
static constexpr sbp_msg_type_t id = SbpMsgGpsLeapSecond;
static const sbp_msg_gps_leap_second_t &get(const sbp_msg_t &msg) {
return msg.gps_leap_second;
}
static sbp_msg_gps_leap_second_t &get(sbp_msg_t &msg) {
return msg.gps_leap_second;
}
static void to_sbp_msg(const sbp_msg_gps_leap_second_t &msg,
sbp_msg_t *sbp_msg) {
sbp_msg->gps_leap_second = msg;
}
static sbp_msg_t to_sbp_msg(const sbp_msg_gps_leap_second_t &msg) {
sbp_msg_t sbp_msg;
sbp_msg.gps_leap_second = msg;
return sbp_msg;
}
static s8 send(sbp_state_t *state, u16 sender_id,
const sbp_msg_gps_leap_second_t &msg, sbp_write_fn_t write) {
return sbp_msg_gps_leap_second_send(state, sender_id, &msg, write);
}
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_gps_leap_second_t &msg) {
return sbp_msg_gps_leap_second_encode(buf, len, n_written, &msg);
}
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
sbp_msg_gps_leap_second_t *msg) {
return sbp_msg_gps_leap_second_decode(buf, len, n_read, msg);
}
static size_t encoded_len(const sbp_msg_gps_leap_second_t &msg) {
return sbp_msg_gps_leap_second_encoded_len(&msg);
}
};

template <>
struct MessageTraits<sbp_msg_gps_time_dep_a_t> {
static constexpr sbp_msg_type_t id = SbpMsgGpsTimeDepA;
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 @@ -913,6 +913,12 @@ struct MessageTraits<msg_vel_ecef_cov_gnss_t> {
};


template<>
struct MessageTraits<msg_gps_leap_second_t> {
static constexpr u16 id = 570;
};


template<>
struct MessageTraits<msg_itrf_t> {
static constexpr u16 id = 580;
Expand Down
23 changes: 23 additions & 0 deletions c/include/libsbp/legacy/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,29 @@ typedef struct SBP_ATTR_PACKED {
u32 flags; /**< Status flags */
} msg_protection_level_t;

/** Leap second SBP message.

*
* Emulates the GPS CNAV message, reserving bytes for future broadcast of the
* drift model parameters.
*/

typedef struct SBP_ATTR_PACKED {
s16 bias_coeff; /**< Reserved. Bias coefficient of GPS time scale
with respect to UTC drift model. [2^-35 s] */
s16 drift_coeff; /**< Reserved. Drift coefficient of GPS time scale
with respect to UTC drift model. [2^-51 s/s] */
s8 drift_rate_coeff; /**< Reserved. Drift rate correction coefficient of
GPS time scale with respect to UTC drift model.
[2^-68 s/s^2] */
s8 count_before; /**< Leap second count before insertion. [s] */
u16 tow_s; /**< Reserved. Drift model reference week second. [s] */
u16 wn; /**< Reserved. Drift model reference week number. [weeks] */
u16 ref_wn; /**< Leap second reference week number. [weeks] */
u8 ref_dn; /**< Leap second reference day number. [days] */
s8 count_after; /**< Leap second count after insertion. [s] */
} msg_gps_leap_second_t;

typedef struct SBP_ATTR_PACKED {
u8 ssr_iod; /**< SSR IOD parameter. */
u8 sn_counter_n; /**< Source-Name Counter N. */
Expand Down
7 changes: 7 additions & 0 deletions c/include/libsbp/navigation_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,13 @@
*/
#define SBP_MSG_PROTECTION_LEVEL_ENCODED_LEN 76u

#define SBP_MSG_GPS_LEAP_SECOND 0x023A
/**
* Encoded length of sbp_msg_gps_leap_second_t (V4 API) and
* msg_gps_leap_second_t (legacy API)
*/
#define SBP_MSG_GPS_LEAP_SECOND_ENCODED_LEN 14u

#define SBP_MSG_ITRF 0x0244
/**
* The maximum number of items that can be stored in sbp_msg_itrf_t::sn (V4 API)
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 @@ -127,6 +127,7 @@ typedef enum {
SbpMsgGloBiases = SBP_MSG_GLO_BIASES,
SbpMsgGnssCapb = SBP_MSG_GNSS_CAPB,
SbpMsgGnssTimeOffset = SBP_MSG_GNSS_TIME_OFFSET,
SbpMsgGpsLeapSecond = SBP_MSG_GPS_LEAP_SECOND,
SbpMsgGpsTimeDepA = SBP_MSG_GPS_TIME_DEP_A,
SbpMsgGpsTimeGnss = SBP_MSG_GPS_TIME_GNSS,
SbpMsgGpsTime = SBP_MSG_GPS_TIME,
Expand Down
1 change: 1 addition & 0 deletions c/include/libsbp/v4/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <libsbp/v4/navigation/MSG_BASELINE_NED_DEP_A.h>
#include <libsbp/v4/navigation/MSG_DOPS.h>
#include <libsbp/v4/navigation/MSG_DOPS_DEP_A.h>
#include <libsbp/v4/navigation/MSG_GPS_LEAP_SECOND.h>
#include <libsbp/v4/navigation/MSG_GPS_TIME.h>
#include <libsbp/v4/navigation/MSG_GPS_TIME_DEP_A.h>
#include <libsbp/v4/navigation/MSG_GPS_TIME_GNSS.h>
Expand Down
223 changes: 223 additions & 0 deletions c/include/libsbp/v4/navigation/MSG_GPS_LEAP_SECOND.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
/*
* 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/navigation.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/

#ifndef LIBSBP_V4_NAVIGATION_MSG_GPS_LEAP_SECOND_H
#define LIBSBP_V4_NAVIGATION_MSG_GPS_LEAP_SECOND_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/navigation_macros.h>
#include <libsbp/v4/string/sbp_string.h>

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
*
* SBP_MSG_GPS_LEAP_SECOND
*
*****************************************************************************/
/** Leap second SBP message.

*
* Emulates the GPS CNAV message, reserving bytes for future broadcast of the
drift model parameters.
*/
typedef struct {
/**
* Reserved. Bias coefficient of GPS time scale with respect to UTC drift
* model. [2^-35 s]
*/
s16 bias_coeff;

/**
* Reserved. Drift coefficient of GPS time scale with respect to UTC drift
* model. [2^-51 s/s]
*/
s16 drift_coeff;

/**
* Reserved. Drift rate correction coefficient of GPS time scale with respect
* to UTC drift model. [2^-68 s/s^2]
*/
s8 drift_rate_coeff;

/**
* Leap second count before insertion. [s]
*/
s8 count_before;

/**
* Reserved. Drift model reference week second. [s]
*/
u16 tow_s;

/**
* Reserved. Drift model reference week number. [weeks]
*/
u16 wn;

/**
* Leap second reference week number. [weeks]
*/
u16 ref_wn;

/**
* Leap second reference day number. [days]
*/
u8 ref_dn;

/**
* Leap second count after insertion. [s]
*/
s8 count_after;
} sbp_msg_gps_leap_second_t;

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

/**
* Encode an instance of sbp_msg_gps_leap_second_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_gps_leap_second_t to encode
* @return SBP_OK on success, or other libsbp error code
*/
SBP_EXPORT s8
sbp_msg_gps_leap_second_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_gps_leap_second_t *msg);

/**
* Decode an instance of sbp_msg_gps_leap_second_t from wire representation
*
* This function decodes the wire representation of a sbp_msg_gps_leap_second_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_gps_leap_second_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_gps_leap_second_decode(const uint8_t *buf, uint8_t len,
uint8_t *n_read,
sbp_msg_gps_leap_second_t *msg);
/**
* Send an instance of sbp_msg_gps_leap_second_t with the given write function
*
* An equivalent of #sbp_message_send which operates specifically on
* sbp_msg_gps_leap_second_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_gps_leap_second_send(sbp_state_t *s, u16 sender_id,
const sbp_msg_gps_leap_second_t *msg,
sbp_write_fn_t write);

/**
* Compare two instances of sbp_msg_gps_leap_second_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_gps_leap_second_t instance
* @param b sbp_msg_gps_leap_second_t instance
* @return 0, <0, >0
*/
SBP_EXPORT int sbp_msg_gps_leap_second_cmp(const sbp_msg_gps_leap_second_t *a,
const sbp_msg_gps_leap_second_t *b);

#ifdef __cplusplus
}

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

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

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

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

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

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

#endif // ifdef __cplusplus

#endif /* LIBSBP_V4_NAVIGATION_MSG_GPS_LEAP_SECOND_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 @@ -133,6 +133,7 @@ typedef union {
sbp_msg_glo_biases_t glo_biases;
sbp_msg_gnss_capb_t gnss_capb;
sbp_msg_gnss_time_offset_t gnss_time_offset;
sbp_msg_gps_leap_second_t gps_leap_second;
sbp_msg_gps_time_dep_a_t gps_time_dep_a;
sbp_msg_gps_time_gnss_t gps_time_gnss;
sbp_msg_gps_time_t gps_time;
Expand Down Expand Up @@ -508,6 +509,9 @@ static inline s8 sbp_message_encode(uint8_t *buf, uint8_t len,
case SbpMsgGnssTimeOffset:
return sbp_msg_gnss_time_offset_encode(buf, len, n_written,
&msg->gnss_time_offset);
case SbpMsgGpsLeapSecond:
return sbp_msg_gps_leap_second_encode(buf, len, n_written,
&msg->gps_leap_second);
case SbpMsgGpsTimeDepA:
return sbp_msg_gps_time_dep_a_encode(buf, len, n_written,
&msg->gps_time_dep_a);
Expand Down Expand Up @@ -1119,6 +1123,9 @@ static inline s8 sbp_message_decode(const uint8_t *buf, uint8_t len,
case SbpMsgGnssTimeOffset:
return sbp_msg_gnss_time_offset_decode(buf, len, n_read,
&msg->gnss_time_offset);
case SbpMsgGpsLeapSecond:
return sbp_msg_gps_leap_second_decode(buf, len, n_read,
&msg->gps_leap_second);
case SbpMsgGpsTimeDepA:
return sbp_msg_gps_time_dep_a_decode(buf, len, n_read,
&msg->gps_time_dep_a);
Expand Down Expand Up @@ -1672,6 +1679,8 @@ static inline size_t sbp_message_encoded_len(sbp_msg_type_t msg_type,
return sbp_msg_gnss_capb_encoded_len(&msg->gnss_capb);
case SbpMsgGnssTimeOffset:
return sbp_msg_gnss_time_offset_encoded_len(&msg->gnss_time_offset);
case SbpMsgGpsLeapSecond:
return sbp_msg_gps_leap_second_encoded_len(&msg->gps_leap_second);
case SbpMsgGpsTimeDepA:
return sbp_msg_gps_time_dep_a_encoded_len(&msg->gps_time_dep_a);
case SbpMsgGpsTimeGnss:
Expand Down Expand Up @@ -2205,6 +2214,9 @@ static inline int sbp_message_cmp(sbp_msg_type_t msg_type, const sbp_msg_t *a,
case SbpMsgGnssTimeOffset:
return sbp_msg_gnss_time_offset_cmp(&a->gnss_time_offset,
&b->gnss_time_offset);
case SbpMsgGpsLeapSecond:
return sbp_msg_gps_leap_second_cmp(&a->gps_leap_second,
&b->gps_leap_second);
case SbpMsgGpsTimeDepA:
return sbp_msg_gps_time_dep_a_cmp(&a->gps_time_dep_a, &b->gps_time_dep_a);
case SbpMsgGpsTimeGnss:
Expand Down
Loading