Skip to content

Commit

Permalink
Fixed compilation & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaremadzulynsky committed Jul 14, 2024
1 parent 38561a0 commit ac0f11f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
1 change: 0 additions & 1 deletion TelemetryManager/Inc/TelemetryManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "GroundStationCommunication.hpp"
#include "MavlinkTranslator.hpp"
#include "TelemetryTask.hpp"

class TelemetryManager {
private:
Expand Down
2 changes: 1 addition & 1 deletion TelemetryManager/Src/MavlinkTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MavlinkTranslator::~MavlinkTranslator() {

void MavlinkTranslator::bytesToMavlinkMsg(TMCircularBuffer &rxFromGroundByteQueue) {
// Take bytes in rxFromGroundByteQueue and convert them to Mavlink messages
MavlinkDecoder decoder;
// MavlinkDecoder decoder;
bool success = true;
uint8_t bytesUntilEnd = 0;

Expand Down
9 changes: 7 additions & 2 deletions TelemetryManager/Src/TelemetryManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "TelemetryManager.hpp"
#include "TelemetryTask.hpp"

/**
* @brief This task is called every 500ms. It is responsible for
Expand All @@ -17,7 +18,9 @@ TelemetryManager::TelemetryManager(uint8_t& altitude)
GSC(*DMAReceiveBuffer, lowPriorityTransmitBuffer, highPriorityTransmitBuffer,
RFD900_BUF_SIZE),
MT(),
altitude(altitude) {}
altitude(altitude) {

}

TelemetryManager::~TelemetryManager() {
// Destructor
Expand Down Expand Up @@ -97,4 +100,6 @@ void TelemetryManager::update() {
GSC.transmit(GSC.lowPriorityTransmitBuffer);
}

void TelemetryManager::teardownTasks() { delete routineDataTransmission; }
void TelemetryManager::teardownTasks() {
delete routineDataTransmission;
}
29 changes: 4 additions & 25 deletions TelemetryManager/Tests/MavlinkTranslatorTest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <gtest/gtest.h>

#include <MavlinkTranslator.hpp>

TEST(MavlinkTranslatorTest, EncodeThenDecodeTest) {
Expand All @@ -24,8 +25,9 @@ TEST(MavlinkTranslatorTest, EncodeThenDecodeTest) {
// start bit and therefore determine when the second message ends

translator.bytesToMavlinkMsg(buffer);
ASSERT_EQ(translator.decodedMessages, expectedNumberOfMessagesDecoded);

ASSERT_EQ(translator.decoder.messagesHandledSuccessfully, expectedNumberOfMessagesDecoded);
ASSERT_EQ(translator.decodedMessages, expectedNumberOfMessagesDecoded);
}

TEST(MavlinkTranslatorTest, ParseBytesToMavlinkMsgsTest) {
Expand Down Expand Up @@ -55,33 +57,10 @@ TEST(MavlinkTranslatorTest, ParseBytesToMavlinkMsgsTest) {

translator.bytesToMavlinkMsg(buffer);

ASSERT_EQ(translator.decoder.messagesHandledSuccessfully, expectedNumberOfMessagesDecoded);
ASSERT_EQ(translator.decodedMessages, expectedNumberOfMessagesDecoded);
}

TEST(MavlinkTranslatorTest, global_position_int) {
mavlink_message_t msg;
mavlink_msg_global_position_int_pack(0, 0, &msg, 1, 2, 3, 4, 5, 6, 7, 8, 9);

// Create a buffer to hold the message data
uint8_t expectedBuffer[MAVLINK_MAX_PACKET_LEN] = {0};


// Decode the message
mavlink_global_position_int_t globalPositionInt;
mavlink_msg_global_position_int_decode(&msg, &globalPositionInt);

// Assertions
ASSERT_EQ(globalPositionInt.time_boot_ms, 1);
ASSERT_EQ(globalPositionInt.lat, 2);
ASSERT_EQ(globalPositionInt.lon, 3);
ASSERT_EQ(globalPositionInt.alt, 4);
ASSERT_EQ(globalPositionInt.relative_alt, 5);
ASSERT_EQ(globalPositionInt.vx, 6);
ASSERT_EQ(globalPositionInt.vy, 7);
ASSERT_EQ(globalPositionInt.vz, 8);
ASSERT_EQ(globalPositionInt.hdg, 9);
}

TEST(MavlinkTranslatorTest, AddMavlinkMsgToByteQueueTest) {
MavlinkTranslator translator;
uint8_t _buffer[256];
Expand Down

0 comments on commit ac0f11f

Please sign in to comment.