diff --git a/hal/include/HAL/cpp/Log.h b/hal/include/HAL/cpp/Log.h index 528cda3891..cfda80361f 100644 --- a/hal/include/HAL/cpp/Log.h +++ b/hal/include/HAL/cpp/Log.h @@ -8,8 +8,6 @@ #pragma once #include -#include -#include #include #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() { diff --git a/hal/lib/athena/FRCDriverStation.cpp b/hal/lib/athena/FRCDriverStation.cpp index 8e523fb781..bfc6815403 100644 --- a/hal/lib/athena/FRCDriverStation.cpp +++ b/hal/lib/athena/FRCDriverStation.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -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) { diff --git a/hal/lib/athena/HAL.cpp b/hal/lib/athena/HAL.cpp index 5cb35cb2fc..f27391878b 100644 --- a/hal/lib/athena/HAL.cpp +++ b/hal/lib/athena/HAL.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -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"; } } } diff --git a/hal/lib/athena/SPI.cpp b/hal/lib/athena/SPI.cpp index aa6680480e..655188524b 100644 --- a/hal/lib/athena/SPI.cpp +++ b/hal/lib/athena/SPI.cpp @@ -8,7 +8,6 @@ #include "HAL/SPI.h" #include -#include #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 diff --git a/wpilibc/athena/include/RobotBase.h b/wpilibc/athena/include/RobotBase.h index 26a0c91983..598d96e343 100644 --- a/wpilibc/athena/include/RobotBase.h +++ b/wpilibc/athena/include/RobotBase.h @@ -7,28 +7,27 @@ #pragma once -#include -#include #include #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(); \ } /** diff --git a/wpilibc/athena/src/IterativeRobot.cpp b/wpilibc/athena/src/IterativeRobot.cpp index 3b4e64ffac..c4f216106a 100644 --- a/wpilibc/athena/src/IterativeRobot.cpp +++ b/wpilibc/athena/src/IterativeRobot.cpp @@ -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; } } diff --git a/wpilibc/athena/src/SampleRobot.cpp b/wpilibc/athena/src/SampleRobot.cpp index 014730e865..5ef7ef41a9 100644 --- a/wpilibc/athena/src/SampleRobot.cpp +++ b/wpilibc/athena/src/SampleRobot.cpp @@ -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"; } /** diff --git a/wpilibc/athena/src/Servo.cpp b/wpilibc/athena/src/Servo.cpp index 0a425ba842..79b0bb4add 100644 --- a/wpilibc/athena/src/Servo.cpp +++ b/wpilibc/athena/src/Servo.cpp @@ -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() { diff --git a/wpilibc/athena/src/Timer.cpp b/wpilibc/athena/src/Timer.cpp index d17ff4ad6b..e481d05410 100644 --- a/wpilibc/athena/src/Timer.cpp +++ b/wpilibc/athena/src/Timer.cpp @@ -8,7 +8,6 @@ #include "Timer.h" #include -#include #include #include "DriverStation.h" diff --git a/wpilibc/athena/src/Utility.cpp b/wpilibc/athena/src/Utility.cpp index cbf2c99b6a..70234197be 100644 --- a/wpilibc/athena/src/Utility.cpp +++ b/wpilibc/athena/src/Utility.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/wpilibc/shared/src/Commands/PrintCommand.cpp b/wpilibc/shared/src/Commands/PrintCommand.cpp index afdcad55bb..61efa56dce 100644 --- a/wpilibc/shared/src/Commands/PrintCommand.cpp +++ b/wpilibc/shared/src/Commands/PrintCommand.cpp @@ -7,7 +7,7 @@ #include "Commands/PrintCommand.h" -#include +#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"; } diff --git a/wpilibc/shared/src/Commands/Scheduler.cpp b/wpilibc/shared/src/Commands/Scheduler.cpp index a421af872f..19da1dd1c5 100644 --- a/wpilibc/shared/src/Commands/Scheduler.cpp +++ b/wpilibc/shared/src/Commands/Scheduler.cpp @@ -8,7 +8,6 @@ #include "Commands/Scheduler.h" #include -#include #include #include "Buttons/ButtonScheduler.h" diff --git a/wpilibc/sim/include/RobotBase.h b/wpilibc/sim/include/RobotBase.h index 5deaa14d3c..c03f2cf69e 100644 --- a/wpilibc/sim/include/RobotBase.h +++ b/wpilibc/sim/include/RobotBase.h @@ -7,18 +7,17 @@ #pragma once -#include - #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 { diff --git a/wpilibc/sim/include/WPILib.h b/wpilibc/sim/include/WPILib.h index 17518f5c1a..04ff4a32e1 100644 --- a/wpilibc/sim/include/WPILib.h +++ b/wpilibc/sim/include/WPILib.h @@ -10,7 +10,6 @@ #define SIMULATION "gazebo" #include -#include #include "AnalogGyro.h" #include "AnalogInput.h" diff --git a/wpilibc/sim/include/simulation/MainNode.h b/wpilibc/sim/include/simulation/MainNode.h index 21e914763b..d658e5a5b2 100644 --- a/wpilibc/sim/include/simulation/MainNode.h +++ b/wpilibc/sim/include/simulation/MainNode.h @@ -12,6 +12,7 @@ #include #include +#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"; } } }; diff --git a/wpilibc/sim/src/DriverStation.cpp b/wpilibc/sim/src/DriverStation.cpp index 44b167c3e3..937e2d87e9 100644 --- a/wpilibc/sim/src/DriverStation.cpp +++ b/wpilibc/sim/src/DriverStation.cpp @@ -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"; } /** diff --git a/wpilibc/sim/src/IterativeRobot.cpp b/wpilibc/sim/src/IterativeRobot.cpp index 9a37c0577d..14111a5a09 100644 --- a/wpilibc/sim/src/IterativeRobot.cpp +++ b/wpilibc/sim/src/IterativeRobot.cpp @@ -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; } } diff --git a/wpilibc/sim/src/SampleRobot.cpp b/wpilibc/sim/src/SampleRobot.cpp index 7488d24cf3..7768d9c4b6 100644 --- a/wpilibc/sim/src/SampleRobot.cpp +++ b/wpilibc/sim/src/SampleRobot.cpp @@ -7,10 +7,9 @@ #include "SampleRobot.h" -#include - #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"; } /** diff --git a/wpilibc/sim/src/Utility.cpp b/wpilibc/sim/src/Utility.cpp index 390e658d5d..7b0a6554b4 100644 --- a/wpilibc/sim/src/Utility.cpp +++ b/wpilibc/sim/src/Utility.cpp @@ -12,9 +12,7 @@ #include #endif -#include #include -#include #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---------------------------\n"); + // llvm::outs() << "\n---------------------------\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(); } diff --git a/wpilibc/sim/src/simulation/SimContinuousOutput.cpp b/wpilibc/sim/src/simulation/SimContinuousOutput.cpp index 9a907cfae5..0ae5c67bdd 100644 --- a/wpilibc/sim/src/simulation/SimContinuousOutput.cpp +++ b/wpilibc/sim/src/simulation/SimContinuousOutput.cpp @@ -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("~/simulator/" + topic); - std::cout << "Initialized ~/simulator/" + topic << std::endl; + llvm::outs() << "Initialized ~/simulator/" + topic << "\n"; } void SimContinuousOutput::Set(double speed) { diff --git a/wpilibc/sim/src/simulation/SimDigitalInput.cpp b/wpilibc/sim/src/simulation/SimDigitalInput.cpp index c4dbde6dd5..74c8f362c8 100644 --- a/wpilibc/sim/src/simulation/SimDigitalInput.cpp +++ b/wpilibc/sim/src/simulation/SimDigitalInput.cpp @@ -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; } diff --git a/wpilibc/sim/src/simulation/SimEncoder.cpp b/wpilibc/sim/src/simulation/SimEncoder.cpp index 141a371a31..1ee47e3533 100644 --- a/wpilibc/sim/src/simulation/SimEncoder.cpp +++ b/wpilibc/sim/src/simulation/SimEncoder.cpp @@ -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"; } } diff --git a/wpilibc/sim/src/simulation/SimFloatInput.cpp b/wpilibc/sim/src/simulation/SimFloatInput.cpp index 8bf8ae3a3a..18e991714c 100644 --- a/wpilibc/sim/src/simulation/SimFloatInput.cpp +++ b/wpilibc/sim/src/simulation/SimFloatInput.cpp @@ -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; } diff --git a/wpilibc/sim/src/simulation/SimGyro.cpp b/wpilibc/sim/src/simulation/SimGyro.cpp index 33663bdfd1..5f6e833760 100644 --- a/wpilibc/sim/src/simulation/SimGyro.cpp +++ b/wpilibc/sim/src/simulation/SimGyro.cpp @@ -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"; } } diff --git a/wpilibcIntegrationTests/src/NotifierTest.cpp b/wpilibcIntegrationTests/src/NotifierTest.cpp index 448ebb6ba3..46c7706361 100644 --- a/wpilibcIntegrationTests/src/NotifierTest.cpp +++ b/wpilibcIntegrationTests/src/NotifierTest.cpp @@ -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"; } diff --git a/wpilibcIntegrationTests/src/TestEnvironment.cpp b/wpilibcIntegrationTests/src/TestEnvironment.cpp index a59f0a85ab..6aec945906 100644 --- a/wpilibcIntegrationTests/src/TestEnvironment.cpp +++ b/wpilibcIntegrationTests/src/TestEnvironment.cpp @@ -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); diff --git a/wpilibj/src/athena/cpp/lib/HALUtil.cpp b/wpilibj/src/athena/cpp/lib/HALUtil.cpp index 5ad1e53293..3f89c72bf3 100644 --- a/wpilibj/src/athena/cpp/lib/HALUtil.cpp +++ b/wpilibj/src/athena/cpp/lib/HALUtil.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -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); }