Skip to content

Commit

Permalink
Merge pull request #387 from PW-Sat2/fix-experiment-file-packet-size
Browse files Browse the repository at this point in the history
Fixed packet length for ExperimentFile
  • Loading branch information
zaq32 authored Dec 22, 2017
2 parents b8b4456 + ae86301 commit 0720865
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/experiments/fs/Include/fs/ExperimentFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace experiments
{
public:
/** @brief Data packet length. */
static constexpr uint16_t PacketLength = 231;
static constexpr uint16_t PacketLength = 230;

/** @brief Packet Id. */
enum class PID : std::uint8_t
Expand Down
2 changes: 1 addition & 1 deletion src/checks/checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace
{
static_assert(experiments::fs::ExperimentFile::PacketLength == telecommunication::downlink::CorrelatedDownlinkFrame::MaxPayloadSize,
static_assert(experiments::fs::ExperimentFile::PacketLength + 1 == telecommunication::downlink::CorrelatedDownlinkFrame::MaxPayloadSize,
"Packet Length is not equal to downlink frame size");
}
19 changes: 17 additions & 2 deletions unit_tests/mission/Experiments/fs/ExperimentFileTest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <gsl/span>
#include <iostream>
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fs/ExperimentFile.hpp"
Expand Down Expand Up @@ -112,11 +113,15 @@ namespace
file.Open(_fs, TestFileName, FileOpen::CreateAlways, FileAccess::WriteOnly);

std::array<uint8_t, 9> data = {1, 2, 3, 4, 5, 6, 7, 8, 9};
for (int i = 0; i < 23; ++i)
for (int i = 0; i < 21; ++i)
{
file.Write(ExperimentFile::PID::Reserved, data);
}

file.Write(ExperimentFile::PID::Reserved, gsl::make_span(data).subspan(0, 8));

file.Write(ExperimentFile::PID::Reserved, data);

file.Close();

std::array<uint8_t, 2 * ExperimentFile::PacketLength> expected;
Expand All @@ -126,12 +131,15 @@ namespace
w.WriteByte(num(ExperimentFile::PID::Synchronization));
w.WriteByte(num(ExperimentFile::PID::Timestamp));
w.WriteQuadWordLE(65536);
for (int i = 0; i < 22; ++i)
for (int i = 0; i < 21; ++i)
{
w.WriteByte(num(ExperimentFile::PID::Reserved));
w.WriteArray(data);
}

w.WriteByte(num(ExperimentFile::PID::Reserved));
w.WriteArray(gsl::make_span(data).subspan(0, 8));

w.WriteByte(0xFF);

// second packet
Expand All @@ -141,6 +149,13 @@ namespace
w.WriteByte(num(ExperimentFile::PID::Reserved));
w.WriteArray(data);

for (auto i = 0U; i < expected.size(); i++)
{
std::cout << i << "\t"
<< "A = " << (int)_buffer[i] << "\t"
<< "E = " << (int)expected[i] << std::endl;
}

ASSERT_THAT(_buffer, Eq(expected));
}

Expand Down

0 comments on commit 0720865

Please sign in to comment.