Fix CAN API timing out incorrectly (#1497)

HAL_GetFPGATime returns 0 if it starts with a non zero status.

Always use monotonic clock for CAN times, rather then trying to sync FPGA.

Change timeout from 50 ms to 100 ms.
This commit is contained in:
Thad House
2018-12-29 13:57:23 -08:00
committed by Peter Johnson
parent 300eeb330d
commit d46ce13ffe
5 changed files with 57 additions and 84 deletions

View File

@@ -7,6 +7,8 @@
#include "frc/PowerDistributionPanel.h" // NOLINT(build/include_order)
#include <hal/Ports.h>
#include "TestBench.h"
#include "frc/Jaguar.h"
#include "frc/Talon.h"
@@ -40,6 +42,20 @@ class PowerDistributionPanelTest : public testing::Test {
}
};
TEST_F(PowerDistributionPanelTest, CheckRepeatedCalls) {
auto numChannels = HAL_GetNumPDPChannels();
// 1 second
for (int i = 0; i < 50; i++) {
for (int j = 0; j < numChannels; j++) {
m_pdp->GetCurrent(j);
ASSERT_TRUE(m_pdp->GetError().GetCode() == 0);
}
m_pdp->GetVoltage();
ASSERT_TRUE(m_pdp->GetError().GetCode() == 0);
}
std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
/**
* Test if the current changes when the motor is driven using a talon
*/