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

Removes units and details of probable future use from reserved message fields [OTA-197] #1202

Merged
merged 6 commits into from
Aug 10, 2022
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
32 changes: 14 additions & 18 deletions c/include/libsbp/legacy/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -922,24 +922,20 @@ typedef struct SBP_ATTR_PACKED {
/** 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] */
* UTC-GPST leap seconds before and after the most recent (past, or future,
* for announced insertions) UTC leap second insertion.
*/

typedef struct SBP_ATTR_PACKED {
s16 reserved_0; /**< Reserved. */
s16 reserved_1; /**< Reserved. */
s8 reserved_2; /**< Reserved. */
s8 count_before; /**< Leap second count before insertion. [s] */
u16 reserved_3; /**< Reserved. */
u16 reserved_4; /**< Reserved. */
u16 ref_wn; /**< Leap second reference GPS week number. [weeks] */
u8 ref_dn; /**< Leap second reference day number. [days] */
s8 count_after; /**< Leap second count after insertion. [s] */
} msg_utc_leap_second_t;

typedef struct SBP_ATTR_PACKED {
Expand Down
29 changes: 13 additions & 16 deletions c/include/libsbp/v4/navigation/MSG_UTC_LEAP_SECOND.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,45 +41,42 @@ extern "C" {
/** Leap second SBP message.

*
* Emulates the GPS CNAV message, reserving bytes for future broadcast of the
drift model parameters.
* UTC-GPST leap seconds before and after the most recent (past, or future, for
announced insertions) UTC leap second insertion.
*/
typedef struct {
/**
* Reserved. Bias coefficient of GPS time scale with respect to UTC drift
* model. [2^-35 s]
* Reserved.
*/
s16 bias_coeff;
s16 reserved_0;

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

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

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

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

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

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

Expand Down
30 changes: 15 additions & 15 deletions c/src/v4/navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -5974,22 +5974,22 @@ int sbp_msg_protection_level_cmp(const sbp_msg_protection_level_t *a,

bool sbp_msg_utc_leap_second_encode_internal(
sbp_encode_ctx_t *ctx, const sbp_msg_utc_leap_second_t *msg) {
if (!sbp_s16_encode(ctx, &msg->bias_coeff)) {
if (!sbp_s16_encode(ctx, &msg->reserved_0)) {
return false;
}
if (!sbp_s16_encode(ctx, &msg->drift_coeff)) {
if (!sbp_s16_encode(ctx, &msg->reserved_1)) {
return false;
}
if (!sbp_s8_encode(ctx, &msg->drift_rate_coeff)) {
if (!sbp_s8_encode(ctx, &msg->reserved_2)) {
return false;
}
if (!sbp_s8_encode(ctx, &msg->count_before)) {
return false;
}
if (!sbp_u16_encode(ctx, &msg->tow_s)) {
if (!sbp_u16_encode(ctx, &msg->reserved_3)) {
return false;
}
if (!sbp_u16_encode(ctx, &msg->wn)) {
if (!sbp_u16_encode(ctx, &msg->reserved_4)) {
return false;
}
if (!sbp_u16_encode(ctx, &msg->ref_wn)) {
Expand Down Expand Up @@ -6021,22 +6021,22 @@ s8 sbp_msg_utc_leap_second_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,

bool sbp_msg_utc_leap_second_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_utc_leap_second_t *msg) {
if (!sbp_s16_decode(ctx, &msg->bias_coeff)) {
if (!sbp_s16_decode(ctx, &msg->reserved_0)) {
return false;
}
if (!sbp_s16_decode(ctx, &msg->drift_coeff)) {
if (!sbp_s16_decode(ctx, &msg->reserved_1)) {
return false;
}
if (!sbp_s8_decode(ctx, &msg->drift_rate_coeff)) {
if (!sbp_s8_decode(ctx, &msg->reserved_2)) {
return false;
}
if (!sbp_s8_decode(ctx, &msg->count_before)) {
return false;
}
if (!sbp_u16_decode(ctx, &msg->tow_s)) {
if (!sbp_u16_decode(ctx, &msg->reserved_3)) {
return false;
}
if (!sbp_u16_decode(ctx, &msg->wn)) {
if (!sbp_u16_decode(ctx, &msg->reserved_4)) {
return false;
}
if (!sbp_u16_decode(ctx, &msg->ref_wn)) {
Expand Down Expand Up @@ -6085,17 +6085,17 @@ int sbp_msg_utc_leap_second_cmp(const sbp_msg_utc_leap_second_t *a,
const sbp_msg_utc_leap_second_t *b) {
int ret = 0;

ret = sbp_s16_cmp(&a->bias_coeff, &b->bias_coeff);
ret = sbp_s16_cmp(&a->reserved_0, &b->reserved_0);
if (ret != 0) {
return ret;
}

ret = sbp_s16_cmp(&a->drift_coeff, &b->drift_coeff);
ret = sbp_s16_cmp(&a->reserved_1, &b->reserved_1);
if (ret != 0) {
return ret;
}

ret = sbp_s8_cmp(&a->drift_rate_coeff, &b->drift_rate_coeff);
ret = sbp_s8_cmp(&a->reserved_2, &b->reserved_2);
if (ret != 0) {
return ret;
}
Expand All @@ -6105,12 +6105,12 @@ int sbp_msg_utc_leap_second_cmp(const sbp_msg_utc_leap_second_t *a,
return ret;
}

ret = sbp_u16_cmp(&a->tow_s, &b->tow_s);
ret = sbp_u16_cmp(&a->reserved_3, &b->reserved_3);
if (ret != 0) {
return ret;
}

ret = sbp_u16_cmp(&a->wn, &b->wn);
ret = sbp_u16_cmp(&a->reserved_4, &b->reserved_4);
if (ret != 0) {
return ret;
}
Expand Down
63 changes: 31 additions & 32 deletions c/test/auto_check_sbp_navigation_MsgUTCLeapSecond.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ START_TEST(test_auto_check_sbp_navigation_MsgUTCLeapSecond) {
sbp_msg_t test_msg;
memset(&test_msg, 0, sizeof(test_msg));

test_msg.utc_leap_second.bias_coeff = 1;

test_msg.utc_leap_second.count_after = 9;

test_msg.utc_leap_second.count_before = 4;

test_msg.utc_leap_second.drift_coeff = 2;

test_msg.utc_leap_second.drift_rate_coeff = 3;

test_msg.utc_leap_second.ref_dn = 8;

test_msg.utc_leap_second.ref_wn = 7;

test_msg.utc_leap_second.tow_s = 5;
test_msg.utc_leap_second.reserved_0 = 1;

test_msg.utc_leap_second.reserved_1 = 2;

test_msg.utc_leap_second.reserved_2 = 3;

test_msg.utc_leap_second.wn = 6;
test_msg.utc_leap_second.reserved_3 = 5;

test_msg.utc_leap_second.reserved_4 = 6;

sbp_message_send(&sbp_state, SbpMsgUtcLeapSecond, 66, &test_msg,
&dummy_write);
Expand All @@ -144,11 +144,6 @@ START_TEST(test_auto_check_sbp_navigation_MsgUTCLeapSecond) {
sbp_message_cmp(SbpMsgUtcLeapSecond, &last_msg.msg, &test_msg) == 0,
"Sent and received messages did not compare equal");

ck_assert_msg(last_msg.msg.utc_leap_second.bias_coeff == 1,
"incorrect value for "
"last_msg.msg.utc_leap_second.bias_coeff, expected 1, is %d",
last_msg.msg.utc_leap_second.bias_coeff);

ck_assert_msg(last_msg.msg.utc_leap_second.count_after == 9,
"incorrect value for "
"last_msg.msg.utc_leap_second.count_after, expected 9, is %d",
Expand All @@ -160,17 +155,6 @@ START_TEST(test_auto_check_sbp_navigation_MsgUTCLeapSecond) {
"expected 4, is %d",
last_msg.msg.utc_leap_second.count_before);

ck_assert_msg(last_msg.msg.utc_leap_second.drift_coeff == 2,
"incorrect value for "
"last_msg.msg.utc_leap_second.drift_coeff, expected 2, is %d",
last_msg.msg.utc_leap_second.drift_coeff);

ck_assert_msg(
last_msg.msg.utc_leap_second.drift_rate_coeff == 3,
"incorrect value for last_msg.msg.utc_leap_second.drift_rate_coeff, "
"expected 3, is %d",
last_msg.msg.utc_leap_second.drift_rate_coeff);

ck_assert_msg(last_msg.msg.utc_leap_second.ref_dn == 8,
"incorrect value for last_msg.msg.utc_leap_second.ref_dn, "
"expected 8, is %d",
Expand All @@ -181,15 +165,30 @@ START_TEST(test_auto_check_sbp_navigation_MsgUTCLeapSecond) {
"expected 7, is %d",
last_msg.msg.utc_leap_second.ref_wn);

ck_assert_msg(last_msg.msg.utc_leap_second.tow_s == 5,
"incorrect value for last_msg.msg.utc_leap_second.tow_s, "
"expected 5, is %d",
last_msg.msg.utc_leap_second.tow_s);
ck_assert_msg(last_msg.msg.utc_leap_second.reserved_0 == 1,
"incorrect value for "
"last_msg.msg.utc_leap_second.reserved_0, expected 1, is %d",
last_msg.msg.utc_leap_second.reserved_0);

ck_assert_msg(last_msg.msg.utc_leap_second.reserved_1 == 2,
"incorrect value for "
"last_msg.msg.utc_leap_second.reserved_1, expected 2, is %d",
last_msg.msg.utc_leap_second.reserved_1);

ck_assert_msg(last_msg.msg.utc_leap_second.reserved_2 == 3,
"incorrect value for "
"last_msg.msg.utc_leap_second.reserved_2, expected 3, is %d",
last_msg.msg.utc_leap_second.reserved_2);

ck_assert_msg(last_msg.msg.utc_leap_second.wn == 6,
"incorrect value for last_msg.msg.utc_leap_second.wn, "
"expected 6, is %d",
last_msg.msg.utc_leap_second.wn);
ck_assert_msg(last_msg.msg.utc_leap_second.reserved_3 == 5,
"incorrect value for "
"last_msg.msg.utc_leap_second.reserved_3, expected 5, is %d",
last_msg.msg.utc_leap_second.reserved_3);

ck_assert_msg(last_msg.msg.utc_leap_second.reserved_4 == 6,
"incorrect value for "
"last_msg.msg.utc_leap_second.reserved_4, expected 6, is %d",
last_msg.msg.utc_leap_second.reserved_4);
}
}
END_TEST
Expand Down
39 changes: 20 additions & 19 deletions c/test/cpp/auto_check_sbp_navigation_MsgUTCLeapSecond.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ TEST_F(Test_auto_check_sbp_navigation_MsgUTCLeapSecond0, Test) {
};

sbp_msg_utc_leap_second_t test_msg{};
test_msg.bias_coeff = 1;
test_msg.count_after = 9;
test_msg.count_before = 4;
test_msg.drift_coeff = 2;
test_msg.drift_rate_coeff = 3;
test_msg.ref_dn = 8;
test_msg.ref_wn = 7;
test_msg.tow_s = 5;
test_msg.wn = 6;
test_msg.reserved_0 = 1;
test_msg.reserved_1 = 2;
test_msg.reserved_2 = 3;
test_msg.reserved_3 = 5;
test_msg.reserved_4 = 6;

EXPECT_EQ(send_message(66, test_msg), SBP_OK);

Expand All @@ -102,30 +102,31 @@ TEST_F(Test_auto_check_sbp_navigation_MsgUTCLeapSecond0, Test) {
EXPECT_EQ(n_callbacks_logged_, 1);
EXPECT_EQ(last_sender_id_, 66);
EXPECT_EQ(last_msg_, test_msg);
EXPECT_EQ(last_msg_.bias_coeff, 1)
<< "incorrect value for last_msg_.bias_coeff, expected 1, is "
<< last_msg_.bias_coeff;
EXPECT_EQ(last_msg_.count_after, 9)
<< "incorrect value for last_msg_.count_after, expected 9, is "
<< last_msg_.count_after;
EXPECT_EQ(last_msg_.count_before, 4)
<< "incorrect value for last_msg_.count_before, expected 4, is "
<< last_msg_.count_before;
EXPECT_EQ(last_msg_.drift_coeff, 2)
<< "incorrect value for last_msg_.drift_coeff, expected 2, is "
<< last_msg_.drift_coeff;
EXPECT_EQ(last_msg_.drift_rate_coeff, 3)
<< "incorrect value for last_msg_.drift_rate_coeff, expected 3, is "
<< last_msg_.drift_rate_coeff;
EXPECT_EQ(last_msg_.ref_dn, 8)
<< "incorrect value for last_msg_.ref_dn, expected 8, is "
<< last_msg_.ref_dn;
EXPECT_EQ(last_msg_.ref_wn, 7)
<< "incorrect value for last_msg_.ref_wn, expected 7, is "
<< last_msg_.ref_wn;
EXPECT_EQ(last_msg_.tow_s, 5)
<< "incorrect value for last_msg_.tow_s, expected 5, is "
<< last_msg_.tow_s;
EXPECT_EQ(last_msg_.wn, 6)
<< "incorrect value for last_msg_.wn, expected 6, is " << last_msg_.wn;
EXPECT_EQ(last_msg_.reserved_0, 1)
<< "incorrect value for last_msg_.reserved_0, expected 1, is "
<< last_msg_.reserved_0;
EXPECT_EQ(last_msg_.reserved_1, 2)
<< "incorrect value for last_msg_.reserved_1, expected 2, is "
<< last_msg_.reserved_1;
EXPECT_EQ(last_msg_.reserved_2, 3)
<< "incorrect value for last_msg_.reserved_2, expected 3, is "
<< last_msg_.reserved_2;
EXPECT_EQ(last_msg_.reserved_3, 5)
<< "incorrect value for last_msg_.reserved_3, expected 5, is "
<< last_msg_.reserved_3;
EXPECT_EQ(last_msg_.reserved_4, 6)
<< "incorrect value for last_msg_.reserved_4, expected 6, is "
<< last_msg_.reserved_4;
}
Loading