Replaced STL streams with LLVM's raw_ostream (#344)

std::cout and std::printf were replaced with llvm::outs() and std::cerr was replaced with llvm::errs().
This commit is contained in:
Tyler Veness
2017-06-30 22:33:43 -04:00
committed by Peter Johnson
parent c57a7f0a41
commit 9d93820717
27 changed files with 118 additions and 118 deletions

View File

@@ -8,8 +8,6 @@
#pragma once
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>
#include "llvm/SmallString.h"
@@ -60,7 +58,7 @@ inline llvm::raw_ostream& Log::Get(TLogLevel level) {
inline Log::~Log() {
oss << "\n";
std::cerr << oss.str();
llvm::errs() << oss.str();
}
inline TLogLevel& Log::ReportingLevel() {

View File

@@ -7,7 +7,6 @@
#include <atomic>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <limits>
@@ -16,6 +15,7 @@
#include "HAL/DriverStation.h"
#include "HAL/cpp/priority_condition_variable.h"
#include "HAL/cpp/priority_mutex.h"
#include "llvm/raw_ostream.h"
static_assert(sizeof(int32_t) >= sizeof(int),
"FRC_NetworkComm status variable is larger than 32 bits");
@@ -66,12 +66,12 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
details, location, callStack);
if (printMsg) {
if (location && location[0] != '\0') {
std::fprintf(stderr, "%s at %s: ", isError ? "Error" : "Warning",
location);
llvm::errs() << (isError ? "Error" : "Warning") << " at " << location
<< ": ";
}
std::fprintf(stderr, "%s\n", details);
llvm::errs() << details << "\n";
if (callStack && callStack[0] != '\0') {
std::fprintf(stderr, "%s\n", callStack);
llvm::errs() << callStack << "\n";
}
}
if (i == KEEP_MSGS) {

View File

@@ -14,7 +14,6 @@
#include <atomic>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <mutex>
#include <thread>
@@ -29,6 +28,7 @@
#include "HAL/cpp/priority_mutex.h"
#include "HAL/handles/HandlesInternal.h"
#include "ctre/ctre.h"
#include "llvm/raw_ostream.h"
#include "visa/visa.h"
using namespace hal;
@@ -328,20 +328,20 @@ int32_t HAL_Initialize(int32_t mode) {
// see if the pid is around, but we don't want to mess with init id=1, or
// ourselves
if (pid >= 2 && kill(pid, 0) == 0 && pid != getpid()) {
std::cout << "Killing previously running FRC program..." << std::endl;
llvm::outs() << "Killing previously running FRC program...\n";
kill(pid, SIGTERM); // try to kill it
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (kill(pid, 0) == 0) {
// still not successfull
if (mode == 0) {
std::cout << "FRC pid " << pid
<< " did not die within 110ms. Aborting" << std::endl;
llvm::outs() << "FRC pid " << pid
<< " did not die within 110ms. Aborting\n";
return 0; // just fail
} else if (mode == 1) { // kill -9 it
kill(pid, SIGKILL);
} else {
std::cout << "WARNING: FRC pid " << pid
<< " did not die within 110ms." << std::endl;
llvm::outs() << "WARNING: FRC pid " << pid
<< " did not die within 110ms.\n";
}
}
}

View File

@@ -8,7 +8,6 @@
#include "HAL/SPI.h"
#include <atomic>
#include <cstdio>
#include "DigitalInternal.h"
#include "HAL/DIO.h"
@@ -17,6 +16,7 @@
#include "HAL/cpp/make_unique.h"
#include "HAL/cpp/priority_mutex.h"
#include "HAL/handles/HandlesInternal.h"
#include "llvm/raw_ostream.h"
#include "spilib/spi-lib.h"
using namespace hal;
@@ -165,20 +165,20 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
if ((digitalHandles[5] = HAL_InitializeDIOPort(createPortHandleForSPI(14),
false, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 14\n");
llvm::outs() << "Failed to allocate DIO 14\n";
return;
}
if ((digitalHandles[6] = HAL_InitializeDIOPort(createPortHandleForSPI(15),
false, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 15\n");
llvm::outs() << "Failed to allocate DIO 15\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
return;
}
if ((digitalHandles[7] = HAL_InitializeDIOPort(createPortHandleForSPI(16),
false, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 16\n");
llvm::outs() << "Failed to allocate DIO 16\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated
return;
@@ -186,7 +186,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
if ((digitalHandles[8] = HAL_InitializeDIOPort(createPortHandleForSPI(17),
false, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 17\n");
llvm::outs() << "Failed to allocate DIO 17\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated
HAL_FreeDIOPort(digitalHandles[7]); // free the third port allocated

View File

@@ -7,28 +7,27 @@
#pragma once
#include <cstdio>
#include <iostream>
#include <thread>
#include "Base.h"
#include "HAL/HAL.h"
#include "llvm/raw_ostream.h"
namespace frc {
class DriverStation;
#define START_ROBOT_CLASS(_ClassName_) \
int main() { \
if (!HAL_Initialize(0)) { \
std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; \
return -1; \
} \
HAL_Report(HALUsageReporting::kResourceType_Language, \
HALUsageReporting::kLanguage_CPlusPlus); \
static _ClassName_ robot; \
std::printf("\n********** Robot program starting **********\n"); \
robot.StartCompetition(); \
#define START_ROBOT_CLASS(_ClassName_) \
int main() { \
if (!HAL_Initialize(0)) { \
llvm::errs() << "FATAL ERROR: HAL could not be initialized\n"; \
return -1; \
} \
HAL_Report(HALUsageReporting::kResourceType_Language, \
HALUsageReporting::kLanguage_CPlusPlus); \
static _ClassName_ robot; \
llvm::outs() << "\n********** Robot program starting **********\n"; \
robot.StartCompetition(); \
}
/**

View File

@@ -10,6 +10,7 @@
#include "DriverStation.h"
#include "HAL/HAL.h"
#include "LiveWindow/LiveWindow.h"
#include "llvm/raw_ostream.h"
#include "networktables/NetworkTable.h"
using namespace frc;
@@ -115,7 +116,7 @@ void IterativeRobot::StartCompetition() {
* ready, causing the robot to be bypassed in a match.
*/
void IterativeRobot::RobotInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -126,7 +127,7 @@ void IterativeRobot::RobotInit() {
* the robot enters disabled mode.
*/
void IterativeRobot::DisabledInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -136,7 +137,7 @@ void IterativeRobot::DisabledInit() {
* called each time the robot enters autonomous mode.
*/
void IterativeRobot::AutonomousInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -146,7 +147,7 @@ void IterativeRobot::AutonomousInit() {
* called each time the robot enters teleop mode.
*/
void IterativeRobot::TeleopInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -156,7 +157,7 @@ void IterativeRobot::TeleopInit() {
* called each time the robot enters test mode.
*/
void IterativeRobot::TestInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -174,7 +175,7 @@ void IterativeRobot::TestInit() {
void IterativeRobot::RobotPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -195,7 +196,7 @@ void IterativeRobot::RobotPeriodic() {
void IterativeRobot::DisabledPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -216,7 +217,7 @@ void IterativeRobot::DisabledPeriodic() {
void IterativeRobot::AutonomousPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -237,7 +238,8 @@ void IterativeRobot::AutonomousPeriodic() {
void IterativeRobot::TeleopPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__
<< "()v method... Overload me!\n";
firstRun = false;
}
}
@@ -257,7 +259,7 @@ void IterativeRobot::TeleopPeriodic() {
void IterativeRobot::TestPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}

View File

@@ -10,6 +10,7 @@
#include "DriverStation.h"
#include "LiveWindow/LiveWindow.h"
#include "Timer.h"
#include "llvm/raw_ostream.h"
#include "networktables/NetworkTable.h"
using namespace frc;
@@ -29,7 +30,7 @@ SampleRobot::SampleRobot() : m_robotMainOverridden(true) {}
* ready, causing the robot to be bypassed in a match.
*/
void SampleRobot::RobotInit() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -39,7 +40,7 @@ void SampleRobot::RobotInit() {
* field is disabled.
*/
void SampleRobot::Disabled() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -50,7 +51,7 @@ void SampleRobot::Disabled() {
* robot enters the autonomous state.
*/
void SampleRobot::Autonomous() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -61,7 +62,7 @@ void SampleRobot::Autonomous() {
* each time the robot enters the teleop state.
*/
void SampleRobot::OperatorControl() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -72,7 +73,7 @@ void SampleRobot::OperatorControl() {
* test mode
*/
void SampleRobot::Test() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**

View File

@@ -27,8 +27,6 @@ Servo::Servo(int channel) : SafePWM(channel) {
// Assign defaults for period multiplier for the servo PWM control signal
SetPeriodMultiplier(kPeriodMultiplier_4X);
// std::printf("Done initializing servo %d\n", channel);
}
Servo::~Servo() {

View File

@@ -8,7 +8,6 @@
#include "Timer.h"
#include <chrono>
#include <iostream>
#include <thread>
#include "DriverStation.h"

View File

@@ -10,7 +10,6 @@
#include <cxxabi.h>
#include <execinfo.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>

View File

@@ -7,7 +7,7 @@
#include "Commands/PrintCommand.h"
#include <iostream>
#include "llvm/raw_ostream.h"
using namespace frc;
@@ -16,4 +16,4 @@ PrintCommand::PrintCommand(const std::string& message)
m_message = message;
}
void PrintCommand::Initialize() { std::cout << m_message << "\n"; }
void PrintCommand::Initialize() { llvm::outs() << m_message << "\n"; }

View File

@@ -8,7 +8,6 @@
#include "Commands/Scheduler.h"
#include <algorithm>
#include <iostream>
#include <set>
#include "Buttons/ButtonScheduler.h"

View File

@@ -7,18 +7,17 @@
#pragma once
#include <cstdio>
#include "Base.h"
#include "DriverStation.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
#include "simulation/simTime.h"
#define START_ROBOT_CLASS(_ClassName_) \
int main() { \
static _ClassName_ robot; \
std::printf("\n********** Robot program starting **********\n"); \
robot.StartCompetition(); \
#define START_ROBOT_CLASS(_ClassName_) \
int main() { \
static _ClassName_ robot; \
llvm::outs() << "\n********** Robot program starting **********\n"; \
robot.StartCompetition(); \
}
namespace frc {

View File

@@ -10,7 +10,6 @@
#define SIMULATION "gazebo"
#include <cstring>
#include <iostream>
#include "AnalogGyro.h"
#include "AnalogInput.h"

View File

@@ -12,6 +12,7 @@
#include <gazebo/gazebo_client.hh>
#include <gazebo/transport/transport.hh>
#include "llvm/raw_ostream.h"
#include "simulation/gz_msgs/msgs.h"
namespace frc {
@@ -56,8 +57,7 @@ class MainNode {
main->Init("frc");
gazebo::transport::run();
} else {
std::cout << "An error has occured setting up gazebo_client!"
<< std::endl;
llvm::outs() << "An error has occured setting up gazebo_client!\n";
}
}
};

View File

@@ -13,6 +13,7 @@
#include "Timer.h"
#include "Utility.h"
#include "WPIErrors.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
using namespace frc;
@@ -331,7 +332,7 @@ double DriverStation::GetMatchTime() const {
* The error is also printed to the program console.
*/
void DriverStation::ReportError(llvm::StringRef error) {
std::cout << error << std::endl;
llvm::outs() << error << "\n";
}
/**
@@ -339,7 +340,7 @@ void DriverStation::ReportError(llvm::StringRef error) {
* The warning is also printed to the program console.
*/
void DriverStation::ReportWarning(llvm::StringRef error) {
std::cout << error << std::endl;
llvm::outs() << error << "\n";
}
/**
@@ -350,9 +351,10 @@ void DriverStation::ReportError(bool is_error, int code, llvm::StringRef error,
llvm::StringRef location,
llvm::StringRef stack) {
if (!location.empty())
std::cout << (is_error ? "Error" : "Warning") << " at " << location << ": ";
std::cout << error << std::endl;
if (!stack.empty()) std::cout << stack << std::endl;
llvm::outs() << (is_error ? "Error" : "Warning") << " at " << location
<< ": ";
llvm::outs() << error << "\n";
if (!stack.empty()) llvm::outs() << stack << "\n";
}
/**

View File

@@ -9,6 +9,7 @@
#include "DriverStation.h"
#include "LiveWindow/LiveWindow.h"
#include "llvm/raw_ostream.h"
#include "networktables/NetworkTable.h"
// not sure what this is used for yet.
@@ -109,7 +110,7 @@ void IterativeRobot::StartCompetition() {
* exactly 1 time.
*/
void IterativeRobot::RobotInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -119,7 +120,7 @@ void IterativeRobot::RobotInit() {
* called each time the robot enters disabled mode.
*/
void IterativeRobot::DisabledInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -129,7 +130,7 @@ void IterativeRobot::DisabledInit() {
* called each time the robot enters autonomous mode.
*/
void IterativeRobot::AutonomousInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -139,7 +140,7 @@ void IterativeRobot::AutonomousInit() {
* called each time the robot enters teleop mode.
*/
void IterativeRobot::TeleopInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -149,7 +150,7 @@ void IterativeRobot::TeleopInit() {
* called each time the robot enters test mode.
*/
void IterativeRobot::TestInit() {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -161,7 +162,7 @@ void IterativeRobot::TestInit() {
void IterativeRobot::RobotPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -175,7 +176,7 @@ void IterativeRobot::RobotPeriodic() {
void IterativeRobot::DisabledPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -189,7 +190,7 @@ void IterativeRobot::DisabledPeriodic() {
void IterativeRobot::AutonomousPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -203,7 +204,7 @@ void IterativeRobot::AutonomousPeriodic() {
void IterativeRobot::TeleopPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}
@@ -217,7 +218,7 @@ void IterativeRobot::TeleopPeriodic() {
void IterativeRobot::TestPeriodic() {
static bool firstRun = true;
if (firstRun) {
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
firstRun = false;
}
}

View File

@@ -7,10 +7,9 @@
#include "SampleRobot.h"
#include <cstdio>
#include "LiveWindow/LiveWindow.h"
#include "Timer.h"
#include "llvm/raw_ostream.h"
#include "networktables/NetworkTable.h"
#if defined(_UNIX)
@@ -31,7 +30,7 @@ SampleRobot::SampleRobot() : m_robotMainOverridden(true) {}
* which will be called each time the robot enters the disabled state.
*/
void SampleRobot::RobotInit() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -41,7 +40,7 @@ void SampleRobot::RobotInit() {
* field is disabled.
*/
void SampleRobot::Disabled() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -52,7 +51,7 @@ void SampleRobot::Disabled() {
* robot enters the autonomous state.
*/
void SampleRobot::Autonomous() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -63,7 +62,7 @@ void SampleRobot::Autonomous() {
* each time the robot enters the teleop state.
*/
void SampleRobot::OperatorControl() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**
@@ -74,7 +73,7 @@ void SampleRobot::OperatorControl() {
* test mode.
*/
void SampleRobot::Test() {
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
llvm::outs() << "Default " << __FUNCTION__ << "() method... Overload me!\n";
}
/**

View File

@@ -12,9 +12,7 @@
#include <execinfo.h>
#endif
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "Timer.h"
#include "llvm/SmallString.h"
@@ -45,10 +43,10 @@ void wpi_suspendOnAssertEnabled(bool enabled) {
static void wpi_handleTracing() {
// if (stackTraceEnabled)
// {
// std::printf("\n-----------<Stack Trace>----------------\n");
// llvm::outs() << "\n-----------<Stack Trace>----------------\n";
// printCurrentStackTrace();
// }
std::printf("\n");
llvm::outs() << "\n";
}
/**
@@ -77,7 +75,7 @@ bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText,
}
// Print to console and send to remote dashboard
std::cout << "\n\n>>>>" << errorStream.str();
llvm::outs() << "\n\n>>>>" << errorStream.str();
wpi_handleTracing();
}
@@ -111,7 +109,7 @@ void wpi_assertEqual_common_impl(int valueA, int valueB,
}
// Print to console and send to remote dashboard
std::cout << "\n\n>>>>" << error.str();
llvm::outs() << "\n\n>>>>" << error.str();
wpi_handleTracing();
}

View File

@@ -7,13 +7,14 @@
#include "simulation/SimContinuousOutput.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
using namespace frc;
SimContinuousOutput::SimContinuousOutput(std::string topic) {
pub = MainNode::Advertise<gazebo::msgs::Float64>("~/simulator/" + topic);
std::cout << "Initialized ~/simulator/" + topic << std::endl;
llvm::outs() << "Initialized ~/simulator/" + topic << "\n";
}
void SimContinuousOutput::Set(double speed) {

View File

@@ -7,6 +7,7 @@
#include "simulation/SimDigitalInput.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
using namespace frc;
@@ -14,7 +15,7 @@ using namespace frc;
SimDigitalInput::SimDigitalInput(std::string topic) {
sub = MainNode::Subscribe("~/simulator/" + topic, &SimDigitalInput::callback,
this);
std::cout << "Initialized ~/simulator/" + topic << std::endl;
llvm::outs() << "Initialized ~/simulator/" + topic << "\n";
}
bool SimDigitalInput::Get() { return value; }

View File

@@ -7,6 +7,7 @@
#include "simulation/SimEncoder.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
using namespace frc;
@@ -22,11 +23,10 @@ SimEncoder::SimEncoder(std::string topic) {
if (commandPub->WaitForConnection(
gazebo::common::Time(5.0))) { // Wait up to five seconds.
std::cout << "Initialized ~/simulator/" + topic << std::endl;
llvm::outs() << "Initialized ~/simulator/" + topic << "\n";
} else {
std::cerr << "Failed to initialize ~/simulator/" + topic +
": does the encoder exist?"
<< std::endl;
llvm::errs() << "Failed to initialize ~/simulator/" + topic +
": does the encoder exist?\n";
}
}

View File

@@ -7,6 +7,7 @@
#include "simulation/SimFloatInput.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
using namespace frc;
@@ -14,7 +15,7 @@ using namespace frc;
SimFloatInput::SimFloatInput(std::string topic) {
sub = MainNode::Subscribe("~/simulator/" + topic, &SimFloatInput::callback,
this);
std::cout << "Initialized ~/simulator/" + topic << std::endl;
llvm::outs() << "Initialized ~/simulator/" + topic << "\n";
}
double SimFloatInput::Get() { return value; }

View File

@@ -7,6 +7,7 @@
#include "simulation/SimGyro.h"
#include "llvm/raw_ostream.h"
#include "simulation/MainNode.h"
using namespace frc;
@@ -22,11 +23,10 @@ SimGyro::SimGyro(std::string topic) {
if (commandPub->WaitForConnection(
gazebo::common::Time(5.0))) { // Wait up to five seconds.
std::cout << "Initialized ~/simulator/" + topic << std::endl;
llvm::outs() << "Initialized ~/simulator/" + topic << "\n";
} else {
std::cerr << "Failed to initialize ~/simulator/" + topic +
": does the gyro exist?"
<< std::endl;
llvm::errs() << "Failed to initialize ~/simulator/" + topic +
": does the gyro exist?\n";
}
}

View File

@@ -10,6 +10,7 @@
#include "TestBench.h"
#include "Timer.h"
#include "gtest/gtest.h"
#include "llvm/raw_ostream.h"
using namespace frc;
@@ -21,21 +22,21 @@ void notifierHandler(void*) { notifierCounter++; }
* Test if the Wait function works
*/
TEST(NotifierTest, DISABLED_TestTimerNotifications) {
std::cout << "NotifierTest..." << std::endl;
llvm::outs() << "NotifierTest...\n";
notifierCounter = 0;
std::cout << "notifier(notifierHandler, nullptr)..." << std::endl;
llvm::outs() << "notifier(notifierHandler, nullptr)...\n";
Notifier notifier(notifierHandler, nullptr);
std::cout << "Start Periodic..." << std::endl;
llvm::outs() << "Start Periodic...\n";
notifier.StartPeriodic(1.0);
std::cout << "Wait..." << std::endl;
llvm::outs() << "Wait...\n";
Wait(10.5);
std::cout << "...Wait" << std::endl;
llvm::outs() << "...Wait\n";
EXPECT_EQ(10u, notifierCounter) << "Received " << notifierCounter
<< " notifications in 10.5 seconds";
std::cout << "Received " << notifierCounter
<< " notifications in 10.5 seconds";
llvm::outs() << "Received " << notifierCounter
<< " notifications in 10.5 seconds";
std::cout << "...NotifierTest" << std::endl;
llvm::outs() << "...NotifierTest\n";
}

View File

@@ -12,6 +12,7 @@
#include "LiveWindow/LiveWindow.h"
#include "Timer.h"
#include "gtest/gtest.h"
#include "llvm/raw_ostream.h"
using namespace frc;
@@ -26,7 +27,7 @@ class TestEnvironment : public testing::Environment {
m_alreadySetUp = true;
if (!HAL_Initialize(0)) {
std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl;
llvm::errs() << "FATAL ERROR: HAL could not be initialized\n";
std::exit(-1);
}
@@ -37,7 +38,7 @@ class TestEnvironment : public testing::Environment {
HAL_ObserveUserProgramStarting();
LiveWindow::GetInstance()->SetEnabled(false);
std::cout << "Waiting for enable" << std::endl;
llvm::outs() << "Waiting for enable\n";
while (!DriverStation::GetInstance().IsEnabled()) {
Wait(0.1);

View File

@@ -11,6 +11,7 @@
#include <errno.h>
#include <jni.h>
#include <cstdio>
#include <cstring>
#include <string>
@@ -21,6 +22,7 @@
#include "HAL/cpp/Log.h"
#include "edu_wpi_first_wpilibj_hal_HALUtil.h"
#include "llvm/SmallString.h"
#include "llvm/raw_ostream.h"
#include "support/jni_util.h"
using namespace wpi::java;
@@ -56,7 +58,7 @@ static JClass pwmConfigDataResultCls;
namespace frc {
void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange,
void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange,
int32_t requestedValue, int32_t status) {
const char *message = HAL_GetErrorMessage(status);
llvm::SmallString<1024> buf;
@@ -76,7 +78,7 @@ void ThrowHalHandleException(JNIEnv *env, int32_t status) {
halHandleExCls.Throw(env, buf.c_str());
}
constexpr const char wpilibjPrefix[] = "edu.wpi.first.wpilibj";
constexpr const char wpilibjPrefix[] = "edu.wpi.first.wpilibj";
void ReportError(JNIEnv *env, int32_t status, bool do_throw) {
if (status == 0) return;
@@ -96,11 +98,11 @@ void ReportError(JNIEnv *env, int32_t status, bool do_throw) {
}
}
void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange,
void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange,
int32_t requestedValue) {
if (status == 0) return;
if (status == NO_AVAILABLE_RESOURCES ||
status == RESOURCE_IS_ALLOCATED ||
if (status == NO_AVAILABLE_RESOURCES ||
status == RESOURCE_IS_ALLOCATED ||
status == RESOURCE_OUT_OF_RANGE) {
ThrowAllocationException(env, minRange, maxRange, requestedValue, status);
}