Skip to content

Commit

Permalink
fixed include
Browse files Browse the repository at this point in the history
  • Loading branch information
r4stered committed Aug 3, 2024
1 parent 8de98bf commit 0615497
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
#include <frc/simulation/RoboRioSim.h>
#include <frc2/command/CommandScheduler.h>

#include "str/DataUtils.h"

void Robot::RobotInit() {
str::DataUtils::LogGitInfo();
frc2::CommandScheduler::GetInstance().SetPeriod(consts::LOOP_PERIOD);
frc::DataLogManager::Start();
frc::DriverStation::StartDataLog(frc::DataLogManager::GetLog());
Expand Down
41 changes: 41 additions & 0 deletions src/main/cpp/str/DataUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) FRC 2053.
// Open Source Software; you can modify and/or share it under the terms of
// the MIT License file in the root of this project

#include "str/DataUtils.h"

#include <frc/DataLogManager.h>
#include <frc/DriverStation.h>
#include <frc/Filesystem.h>

#include <fstream>
#include <sstream>

using namespace str;

void DataUtils::LogGitInfo() {
std::string branchFileName =
frc::filesystem::GetDeployDirectory() + "/" + "branch.txt";

std::ifstream branchFile(branchFileName);
if (branchFile.fail()) {
frc::DataLogManager::Log(fmt::format("Error opening branch file!"));
}

std::stringstream branchStream;
branchStream << branchFile.rdbuf();

std::string commitFileName =
frc::filesystem::GetDeployDirectory() + "/" + "commit.txt";
std::ifstream commitFile(commitFileName);
if (commitFile.fail()) {
frc::DataLogManager::Log(fmt::format("Error opening branch file!"));
}

std::stringstream commitStream;
commitStream << commitFile.rdbuf();

frc::DataLogManager::Log(
fmt::format("Robot is running code on branch {} with commit {}",
branchStream.str(), commitStream.str()));
}
2 changes: 1 addition & 1 deletion src/main/deploy/commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ce73ac9
8de98bf
13 changes: 13 additions & 0 deletions src/main/include/str/DataUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) FRC 2053.
// Open Source Software; you can modify and/or share it under the terms of
// the MIT License file in the root of this project

#pragma once

namespace str {
class DataUtils {
public:
DataUtils() = delete;
static void LogGitInfo();
};
} // namespace str
2 changes: 1 addition & 1 deletion src/main/include/str/DriverstationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <frc/Driverstation.h>
#include <frc/DriverStation.h>

#include <functional>

Expand Down

0 comments on commit 0615497

Please sign in to comment.