Skip to content

Commit

Permalink
CG-531: fix BCH coding input length for sensor packet type
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Wickins committed Dec 6, 2023
1 parent b19a853 commit 7cea39d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/services/argos_tx_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ ArticPacket ArgosPacketBuilder::build_sensor_packet(GPSLogEntry* gps_entry,
BCHCodeWord code_word = BCHEncoder::encode(
BCHEncoder::B255_223_4,
sizeof(BCHEncoder::B255_223_4),
packet, LONG_PACKET_PAYLOAD_BITS);
packet, base_pos);
DEBUG_TRACE("ArgosPacketBuilder::build_sensor_packet: bch=%08x", code_word);

// Append BCH code
Expand Down
27 changes: 20 additions & 7 deletions tests/src/argos_tx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ TEST(ArgosTxService, DepthPileManagerTestSensorValueConversion)
CHECK_EQUAL(113657, (unsigned int)converted->port[0]);
}

TEST(ArgosTxService, BuildSensorPacket) {
TEST(ArgosTxService, BuildSensorPacketAll) {
unsigned int size_bits;
GPSLogEntry e = make_gps_location(1, 12.3, 44.4, 1652105502);
ServiceSensorData als, ph, pressure, sea_temp;
Expand All @@ -1550,25 +1550,38 @@ TEST(ArgosTxService, BuildSensorPacket) {
sea_temp.port[0] = 126000; // 0C

x = ArgosPacketBuilder::build_sensor_packet(&e, nullptr, nullptr, nullptr, nullptr, false, false, size_bits);
CHECK_EQUAL("CC4B8B3633003C0F0012C0526DE9C0"s, Binascii::hexlify(x));
CHECK_EQUAL("CC4B8B3633003C0F0012DB3750A6C0"s, Binascii::hexlify(x));
CHECK_EQUAL(115, size_bits);
x = ArgosPacketBuilder::build_sensor_packet(&e, &als, &ph, &pressure, &sea_temp, false, false, size_bits);
CHECK_EQUAL("DB4B8B3633003C0F0012C27106D601F41F401EC30C55C3A320"s, Binascii::hexlify(x));
CHECK_EQUAL("DB4B8B3633003C0F0012C27106D601F41F401EC30D29A43B60"s, Binascii::hexlify(x));
CHECK_EQUAL(196, size_bits);
x = ArgosPacketBuilder::build_sensor_packet(&e, nullptr, &ph, &pressure, &sea_temp, false, false, size_bits);
CHECK_EQUAL("9D4B8B3633003C0F0012CDAC03E83E803D860BE541EE20"s, Binascii::hexlify(x));
CHECK_EQUAL("9D4B8B3633003C0F0012CDAC03E83E803D86016C0F00A0"s, Binascii::hexlify(x));
CHECK_EQUAL(196 - 17, size_bits);
x = ArgosPacketBuilder::build_sensor_packet(&e, &als, nullptr, &pressure, &sea_temp, false, false, size_bits);
CHECK_EQUAL("014B8B3633003C0F0012C271007D07D007B0C0E49F1BF4"s, Binascii::hexlify(x));
CHECK_EQUAL("014B8B3633003C0F0012C271007D07D007B0C35F8554C8"s, Binascii::hexlify(x));
CHECK_EQUAL(196 - 14, size_bits);
x = ArgosPacketBuilder::build_sensor_packet(&e, &als, &ph, nullptr, &sea_temp, false, false, size_bits);
CHECK_EQUAL("9A4B8B3633003C0F0012C27106D603D861A1C3AD9C"s, Binascii::hexlify(x));
CHECK_EQUAL("9A4B8B3633003C0F0012C27106D603D860B455F0FE"s, Binascii::hexlify(x));
CHECK_EQUAL(196 - 29, size_bits);
x = ArgosPacketBuilder::build_sensor_packet(&e, &als, &ph, &pressure, nullptr, false, false, size_bits);
CHECK_EQUAL("554B8B3633003C0F0012C27106D601F41F40D43B78D6"s, Binascii::hexlify(x));
CHECK_EQUAL("554B8B3633003C0F0012C27106D601F41F41C886E7C4"s, Binascii::hexlify(x));
CHECK_EQUAL(196 - 21, size_bits);
}

TEST(ArgosTxService, BuildSensorPacketSeaTemp) {
unsigned int size_bits;
GPSLogEntry e = make_gps_location(1, 12.3, 44.4, 1652105502);
ServiceSensorData sea_temp;
std::string x;

sea_temp.port[0] = 147100; // 21.1C

x = ArgosPacketBuilder::build_sensor_packet(&e, nullptr, nullptr, nullptr, &sea_temp, false, false, size_bits);
CHECK_EQUAL("0A4B8B3633003C0F0012C23E9CBCE00BD1"s, Binascii::hexlify(x));
CHECK_EQUAL(136, size_bits);
}


TEST(ArgosTxService, PassPredictWithSensorDataPayload)
{
Expand Down

0 comments on commit 7cea39d

Please sign in to comment.