[hal] Initialize DIO to true in sim (#6670)

This commit is contained in:
Gold856
2024-05-28 00:18:19 -04:00
committed by GitHub
parent 76685fe7e8
commit 0ad4cd69d0
3 changed files with 9 additions and 8 deletions

View File

@@ -66,6 +66,7 @@ HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
SimDIOData[channel].initialized = true;
SimDIOData[channel].isInput = input;
SimDIOData[channel].simDevice = 0;
SimDIOData[channel].value = true;
port->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;

View File

@@ -69,12 +69,12 @@ TEST(DIOSimTest, Output) {
BooleanCallback valueCallback;
auto cb = sim.RegisterValueCallback(valueCallback.GetCallback(), false);
EXPECT_FALSE(output.Get());
EXPECT_FALSE(sim.GetValue());
EXPECT_TRUE(output.Get());
EXPECT_TRUE(sim.GetValue());
EXPECT_FALSE(valueCallback.WasTriggered());
output.Set(true);
output.Set(false);
EXPECT_TRUE(valueCallback.WasTriggered());
EXPECT_TRUE(valueCallback.GetLastValue());
EXPECT_FALSE(valueCallback.GetLastValue());
}
} // namespace frc::sim

View File

@@ -72,13 +72,13 @@ class DIOSimTest {
BooleanCallback valueCallback = new BooleanCallback();
try (CallbackStore cb = sim.registerValueCallback(valueCallback, false)) {
assertFalse(output.get());
assertFalse(sim.getValue());
assertTrue(output.get());
assertTrue(sim.getValue());
assertFalse(valueCallback.wasTriggered());
output.set(true);
output.set(false);
assertTrue(valueCallback.wasTriggered());
assertTrue(valueCallback.getSetValue());
assertFalse(valueCallback.getSetValue());
}
}
}