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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ python/sbp/_version.py
# Spec Validation
previous-spec/
current-spec/

.vscode/
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 @@ -6019,6 +6019,41 @@ struct MessageTraits<sbp_msg_startup_t> {
}
};

template <>
struct MessageTraits<sbp_msg_status_journal_t> {
static constexpr sbp_msg_type_t id = SbpMsgStatusJournal;
static const sbp_msg_status_journal_t &get(const sbp_msg_t &msg) {
return msg.status_journal;
}
static sbp_msg_status_journal_t &get(sbp_msg_t &msg) {
return msg.status_journal;
}
static void to_sbp_msg(const sbp_msg_status_journal_t &msg,
sbp_msg_t *sbp_msg) {
sbp_msg->status_journal = msg;
}
static sbp_msg_t to_sbp_msg(const sbp_msg_status_journal_t &msg) {
sbp_msg_t sbp_msg;
sbp_msg.status_journal = msg;
return sbp_msg;
}
static s8 send(sbp_state_t *state, u16 sender_id,
const sbp_msg_status_journal_t &msg, sbp_write_fn_t write) {
return sbp_msg_status_journal_send(state, sender_id, &msg, write);
}
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_status_journal_t &msg) {
return sbp_msg_status_journal_encode(buf, len, n_written, &msg);
}
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
sbp_msg_status_journal_t *msg) {
return sbp_msg_status_journal_decode(buf, len, n_read, msg);
}
static size_t encoded_len(const sbp_msg_status_journal_t &msg) {
return sbp_msg_status_journal_encoded_len(&msg);
}
};

template <>
struct MessageTraits<sbp_msg_status_report_t> {
static constexpr sbp_msg_type_t id = SbpMsgStatusReport;
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 @@ -1200,6 +1200,12 @@ struct MessageTraits<msg_soln_meta_dep_a_t> {
};


template<>
struct MessageTraits<msg_status_journal_t> {
static constexpr u16 id = 65533;
};


template<>
struct MessageTraits<msg_status_report_t> {
static constexpr u16 id = 65534;
Expand Down
39 changes: 35 additions & 4 deletions c/include/libsbp/legacy/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ typedef struct SBP_ATTR_PACKED {
u32 flags; /**< Status flags */
} msg_heartbeat_t;

/** Sub-system Status report
/** Subsystem Status report
*
* Report the general and specific state of a sub-system. If the generic
* state is reported as initializing, the specific state should be ignored.
* Report the general and specific state of a subsystem. If the generic state
* is reported as initializing, the specific state should be ignored.
*/

typedef struct SBP_ATTR_PACKED {
Expand All @@ -90,7 +90,7 @@ typedef struct SBP_ATTR_PACKED {
* The status report is sent periodically to inform the host or other attached
* devices that the system is running. It is used to monitor system
* malfunctions. It contains status reports that indicate to the host the
* status of each sub-system and whether it is operating correctly.
* status of each subsystem and whether it is operating correctly.
*
* Interpretation of the subsystem specific status code is product dependent,
* but if the generic status code is initializing, it should be ignored.
Expand All @@ -106,6 +106,37 @@ typedef struct SBP_ATTR_PACKED {
subsystems */
} msg_status_report_t;

/** Subsystem Status report
*
* Reports the uptime and the state of a subsystem via generic and specific
* status codes. If the generic state is reported as initializing, the
* specific state should be ignored.
*/

typedef struct SBP_ATTR_PACKED {
u32 uptime; /**< Milliseconds since system startup */
sub_system_report_t report;
} status_journal_item_t;

/** Status report journal
*
* The status journal message contains past status reports (see
* MSG_STATUS_REPORT) and functions as a error/event storage for telemetry
* purposes.
*/

typedef struct SBP_ATTR_PACKED {
u16 reporting_system; /**< Identity of reporting system */
u16 sbp_version; /**< SBP protocol version */
u32 total_status_reports; /**< Total number of status reports sent since
system startup */
u8 sequence_descriptor; /**< Index and number of messages in this
sequence. First nibble is the size of the
sequence (n), second nibble is the zero-
indexed counter (ith packet of n) */
status_journal_item_t journal[0]; /**< Status journal */
} msg_status_journal_t;

/** Inertial Navigation System status message
*
* The INS status message describes the state of the operation and
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 @@ -221,6 +221,7 @@ typedef enum {
SbpMsgSsrStecCorrection = SBP_MSG_SSR_STEC_CORRECTION,
SbpMsgSsrTileDefinition = SBP_MSG_SSR_TILE_DEFINITION,
SbpMsgStartup = SBP_MSG_STARTUP,
SbpMsgStatusJournal = SBP_MSG_STATUS_JOURNAL,
SbpMsgStatusReport = SBP_MSG_STATUS_REPORT,
SbpMsgStmFlashLockSector = SBP_MSG_STM_FLASH_LOCK_SECTOR,
SbpMsgStmFlashUnlockSector = SBP_MSG_STM_FLASH_UNLOCK_SECTOR,
Expand Down
76 changes: 76 additions & 0 deletions c/include/libsbp/system_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,82 @@
*/
#define SBP_MSG_STATUS_REPORT_ENCODED_OVERHEAD 12u

/**
* Encoded length of sbp_status_journal_item_t (V4 API) and
* status_journal_item_t (legacy API)
*/
#define SBP_STATUS_JOURNAL_ITEM_ENCODED_LEN 8u

#define SBP_MSG_STATUS_JOURNAL 0xFFFD
#define SBP_STATUS_JOURNAL_SYSTEM_MASK (0xffffu)
#define SBP_STATUS_JOURNAL_SYSTEM_SHIFT (0u)
#define SBP_STATUS_JOURNAL_SYSTEM_GET(flags) \
((u16)((u16)((flags) >> SBP_STATUS_JOURNAL_SYSTEM_SHIFT) & \
SBP_STATUS_JOURNAL_SYSTEM_MASK))
#define SBP_STATUS_JOURNAL_SYSTEM_SET(flags, val) \
do { \
(flags) = (u16)((flags & (~(SBP_STATUS_JOURNAL_SYSTEM_MASK \
<< SBP_STATUS_JOURNAL_SYSTEM_SHIFT))) | \
(((val) & (SBP_STATUS_JOURNAL_SYSTEM_MASK)) \
<< (SBP_STATUS_JOURNAL_SYSTEM_SHIFT))); \
} while (0)

#define SBP_STATUS_JOURNAL_SYSTEM_STARLING (0)
#define SBP_STATUS_JOURNAL_SYSTEM_PRECISION_GNSS_MODULE (1)
#define SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK (0xffu)
#define SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SHIFT (8u)
#define SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_GET(flags) \
((u16)((u16)((flags) >> \
SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SHIFT) & \
SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK))
#define SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SET(flags, val) \
do { \
(flags) = (u16)( \
(flags & \
(~(SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK \
<< SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SHIFT))) | \
(((val) & (SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK)) \
<< (SBP_STATUS_JOURNAL_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SHIFT))); \
} while (0)

#define SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_MASK (0xffu)
#define SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_SHIFT (0u)
#define SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_GET(flags) \
((u16)((u16)((flags) >> \
SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_SHIFT) & \
SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_MASK))
#define SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_SET(flags, val) \
do { \
(flags) = (u16)( \
(flags & \
(~(SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_MASK \
<< SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_SHIFT))) | \
(((val) & (SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_MASK)) \
<< (SBP_STATUS_JOURNAL_SBP_MINOR_PROTOCOL_VERSION_NUMBER_SHIFT))); \
} while (0)

/**
* The maximum number of items that can be stored in
* sbp_msg_status_journal_t::journal (V4 API) or msg_status_journal_t::journal
* (legacy API) before the maximum SBP message size is exceeded
*/
#define SBP_MSG_STATUS_JOURNAL_JOURNAL_MAX 30u

/**
* Encoded length of sbp_msg_status_journal_t (V4 API) and
* msg_status_journal_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_status_journal_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_STATUS_JOURNAL_ENCODED_OVERHEAD 9u

#define SBP_MSG_INS_STATUS 0xFF03
#define SBP_INS_STATUS_INS_TYPE_MASK (0x7u)
#define SBP_INS_STATUS_INS_TYPE_SHIFT (29u)
Expand Down
11 changes: 11 additions & 0 deletions c/include/libsbp/v4/sbp_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ typedef union {
sbp_msg_ssr_stec_correction_t ssr_stec_correction;
sbp_msg_ssr_tile_definition_t ssr_tile_definition;
sbp_msg_startup_t startup;
sbp_msg_status_journal_t status_journal;
sbp_msg_status_report_t status_report;
sbp_msg_stm_flash_lock_sector_t stm_flash_lock_sector;
sbp_msg_stm_flash_unlock_sector_t stm_flash_unlock_sector;
Expand Down Expand Up @@ -740,6 +741,9 @@ static inline s8 sbp_message_encode(uint8_t *buf, uint8_t len,
&msg->ssr_tile_definition);
case SbpMsgStartup:
return sbp_msg_startup_encode(buf, len, n_written, &msg->startup);
case SbpMsgStatusJournal:
return sbp_msg_status_journal_encode(buf, len, n_written,
&msg->status_journal);
case SbpMsgStatusReport:
return sbp_msg_status_report_encode(buf, len, n_written,
&msg->status_report);
Expand Down Expand Up @@ -1307,6 +1311,9 @@ static inline s8 sbp_message_decode(const uint8_t *buf, uint8_t len,
&msg->ssr_tile_definition);
case SbpMsgStartup:
return sbp_msg_startup_decode(buf, len, n_read, &msg->startup);
case SbpMsgStatusJournal:
return sbp_msg_status_journal_decode(buf, len, n_read,
&msg->status_journal);
case SbpMsgStatusReport:
return sbp_msg_status_report_decode(buf, len, n_read,
&msg->status_report);
Expand Down Expand Up @@ -1782,6 +1789,8 @@ static inline size_t sbp_message_encoded_len(sbp_msg_type_t msg_type,
return sbp_msg_ssr_tile_definition_encoded_len(&msg->ssr_tile_definition);
case SbpMsgStartup:
return sbp_msg_startup_encoded_len(&msg->startup);
case SbpMsgStatusJournal:
return sbp_msg_status_journal_encoded_len(&msg->status_journal);
case SbpMsgStatusReport:
return sbp_msg_status_report_encoded_len(&msg->status_report);
case SbpMsgStmFlashLockSector:
Expand Down Expand Up @@ -2305,6 +2314,8 @@ static inline int sbp_message_cmp(sbp_msg_type_t msg_type, const sbp_msg_t *a,
&b->ssr_tile_definition);
case SbpMsgStartup:
return sbp_msg_startup_cmp(&a->startup, &b->startup);
case SbpMsgStatusJournal:
return sbp_msg_status_journal_cmp(&a->status_journal, &b->status_journal);
case SbpMsgStatusReport:
return sbp_msg_status_report_cmp(&a->status_report, &b->status_report);
case SbpMsgStmFlashLockSector:
Expand Down
2 changes: 2 additions & 0 deletions c/include/libsbp/v4/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#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_JOURNAL.h>
#include <libsbp/v4/system/MSG_STATUS_REPORT.h>
#include <libsbp/v4/system/StatusJournalItem.h>
#include <libsbp/v4/system/SubSystemReport.h>

#endif /* LIBSBP_V4_SYSTEM_MESSAGES_H */
Loading