Clean up the realtime priorities of all the robots etc
Change-Id: Ie19ea31ec7b19d9660230477e5f77de9edc5eb59
diff --git a/y2014/wpilib/wpilib_interface.cc b/y2014/wpilib/wpilib_interface.cc
index a399601..cc634d9 100644
--- a/y2014/wpilib/wpilib_interface.cc
+++ b/y2014/wpilib/wpilib_interface.cc
@@ -264,7 +264,7 @@
::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
::aos::time::Time::InMS(4));
- ::aos::SetCurrentThreadRealtimePriority(kPriority);
+ ::aos::SetCurrentThreadRealtimePriority(40);
while (run_) {
{
const int iterations = phased_loop.SleepUntilNext();
@@ -410,7 +410,7 @@
multiplier * claw_translate(counter->last_negative_encoder_value());
}
- ::frc971::wpilib::InterruptSynchronizer synchronizer_{kInterruptPriority};
+ ::frc971::wpilib::InterruptSynchronizer synchronizer_{55};
::std::unique_ptr<::frc971::wpilib::EdgeCounter> front_counter_;
::std::unique_ptr<::frc971::wpilib::EdgeCounter> calibration_counter_;
@@ -426,9 +426,6 @@
const bool reversed_;
};
- static const int kPriority = 30;
- static const int kInterruptPriority = 55;
-
void CopyShooterPosedgeCounts(
const ::frc971::wpilib::DMAEdgeCounter *counter,
::frc971::PosedgeOnlyCountedHallEffectStruct *output) {
@@ -507,10 +504,18 @@
void operator()() {
::aos::SetCurrentThreadName("Solenoids");
- ::aos::SetCurrentThreadRealtimePriority(30);
+ ::aos::SetCurrentThreadRealtimePriority(27);
+
+ ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(20),
+ ::aos::time::Time::InMS(1));
while (run_) {
- ::aos::time::PhasedLoopXMS(20, 1000);
+ {
+ const int iterations = phased_loop.SleepUntilNext();
+ if (iterations != 1) {
+ LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
+ }
+ }
{
shooter_.FetchLatest();
@@ -771,7 +776,14 @@
::std::thread solenoid_thread(::std::ref(solenoid_writer));
// Wait forever. Not much else to do...
- PCHECK(select(0, nullptr, nullptr, nullptr, nullptr));
+ while (true) {
+ const int r = select(0, nullptr, nullptr, nullptr, nullptr);
+ if (r != 0) {
+ PLOG(WARNING, "infinite select failed");
+ } else {
+ PLOG(WARNING, "infinite select succeeded??\n");
+ }
+ }
LOG(ERROR, "Exiting WPILibRobot\n");