Skip to content

Commit 3ab3d89

Browse files
committed
refactor: fix files previously using helpers
1 parent 19e04e1 commit 3ab3d89

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

src/IO/ArduinoEncoder.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#pragma once
22

33
#include "cobs.h"
4-
#include "helpers/Helper.h"
54
#include <memory>
65
#include <spdlog/spdlog.h>
76

87
class ArduinoEncoder
98
{
109
public:
1110
template <typename T>
12-
static helper::SharedArray<char> encode(const T &dataOut);
11+
static SharedArray<char> encode(const T &dataOut);
1312

1413
template <typename T>
1514
static T decode(const char *buffer, int length);
@@ -20,7 +19,7 @@ class ArduinoEncoder
2019
* applied to it, and INCLUDES the ending 0x0 byte, so it can be sent as is.
2120
*/
2221
template <typename T>
23-
helper::SharedArray<char> ArduinoEncoder::encode(const T &dataOut)
22+
SharedArray<char> ArduinoEncoder::encode(const T &dataOut)
2423
{
2524
// Convert from Protobuf to byte array
2625
size_t protoSize = dataOut.ByteSizeLong();
@@ -37,7 +36,7 @@ helper::SharedArray<char> ArduinoEncoder::encode(const T &dataOut)
3736
cobs_encode(&cobsData[0], cobsSize, &protoData[0], protoSize);
3837
cobsData[cobsSize - 1] = 0x0;
3938

40-
return helper::SharedArray<char>{cobsData, static_cast<size_t>(cobsSize)};
39+
return SharedArray<char>{cobsData, static_cast<size_t>(cobsSize)};
4140
}
4241

4342
/**

src/IO/ArduinoProxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void ArduinoProxy::send(const RocketryProto::ArduinoIn &data)
120120
{
121121
std::lock_guard<std::mutex> lockGuard(serialMutex);
122122

123-
helper::SharedArray<char> encodedData = ArduinoEncoder::encode(data);
123+
SharedArray<char> encodedData = ArduinoEncoder::encode(data);
124124

125125
serialPutchar(fd, 0);
126126
for (int i = 0; i < encodedData.length; i++)

src/IO/InterfaceImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "IO/TestingSensors.h"
66
#include "InterfaceImpl.h"
77
#include "common/pch.h"
8+
#include "common/utils.h"
89
#include "data/UOSMData.h"
910
#include <chrono>
1011
#include <iostream>
@@ -88,8 +89,7 @@ bool InterfaceImpl::updateInputs()
8889
{
8990
latestState = std::make_shared<StateData>();
9091

91-
latestState->timeStamp =
92-
std::chrono::duration_cast<time_point::duration>(std::chrono::steady_clock::now().time_since_epoch()).count();
92+
latestState->timeStamp = utils::getMonotonicTimeStamp();
9393

9494
#if USE_SBG == 1
9595
latestState->sbg = mySbgSensor.getData();

src/IO/SensorLogger.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
#include "SensorLogger.h"
55

6-
#include "helpers/Helper.h"
7-
86
#include "boost/filesystem.hpp"
7+
#include "common/utils.h"
98
#include <iostream>
109
#include <mutex>
1110
#include <spdlog/spdlog.h>
@@ -28,7 +27,7 @@ bool SensorLogger::isInitialized()
2827

2928
void SensorLogger::run()
3029
{
31-
auto path = helper::getEnvOrDefault<std::string>("LOG_PATH", "./sensor-data");
30+
auto path = utils::getEnvOrDefault<std::string>("LOG_PATH", "./sensor-data");
3231
std::string ext = ".uorocketlog";
3332
if (path.back() != '/')
3433
path += "/";

src/IO/TestingSensors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#if TESTING == 1
33

44
#include "TestingSensors.h"
5+
#include "common/utils.h"
56
#include "data/StateData.h"
6-
#include "helpers/Helper.h"
77

88
#include <boost/algorithm/string.hpp>
99
#include <boost/lexical_cast.hpp>
@@ -16,7 +16,7 @@ void TestingSensors::run()
1616
void TestingSensors::initialize()
1717
{
1818
createThread = false;
19-
auto fileName = helper::getEnvOrDefault<std::string>("TESTING_INPUT_FILE", "./data/test-data.csv");
19+
auto fileName = utils::getEnvOrDefault<std::string>("TESTING_INPUT_FILE", "./data/test-data.csv");
2020
std::ifstream logFile(fileName.c_str());
2121

2222
std::string line;

src/IO/gpio/Gpio.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "Gpio.h"
55

6-
#include "helpers/Helper.h"
76
#include <iostream>
87
#include <string>
98

unitTesting/arduinoEncoderDecoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TEST_CASE("Encode and decode protobuf message", "[protobuf]")
1212
arduinoIn.mutable_servoinit()->set_pin(1823);
1313
arduinoIn.mutable_servoinit()->set_safeposition(1231);
1414

15-
helper::SharedArray<char> encodedData = ArduinoEncoder::encode(arduinoIn);
15+
SharedArray<char> encodedData = ArduinoEncoder::encode(arduinoIn);
1616

1717
auto arduinoIn2 = ArduinoEncoder::decode<ArduinoIn>(encodedData.data.get(), encodedData.length);
1818

@@ -29,7 +29,7 @@ TEST_CASE("Last byte is 0x0 when encoding protobuf message", "[protobuf]")
2929
arduinoIn.mutable_servoinit()->set_pin(1823);
3030
arduinoIn.mutable_servoinit()->set_safeposition(1231);
3131

32-
helper::SharedArray<char> encodedData = ArduinoEncoder::encode(arduinoIn);
32+
SharedArray<char> encodedData = ArduinoEncoder::encode(arduinoIn);
3333

3434
REQUIRE(encodedData.data.get()[encodedData.length - 1] == 0x0);
3535
}

0 commit comments

Comments
 (0)