[hal] Merge WaitForCachedData into WaitForDSData (#2587)

Remove WaitForCachedData as it's no longer required.

Also properly handle caching / transition detection logic that occurs at the
WPILib level.

This also changes DriverStation::IsNewControlData() to check for WPILib-level
caching instead of wrapping the HAL function.
This commit is contained in:
Peter Johnson
2020-07-13 21:57:54 -07:00
committed by GitHub
parent f0a34ea64e
commit 16ef372b53
6 changed files with 86 additions and 120 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -313,6 +313,9 @@ class DriverStation : public ErrorBase {
*
* This is a good way to delay processing until there is new driver station
* data to act on.
*
* Checks if new control data has arrived since the last waitForData call
* on the current thread. If new data has not arrived, returns immediately.
*/
void WaitForData();
@@ -320,6 +323,9 @@ class DriverStation : public ErrorBase {
* Wait until a new packet comes from the driver station, or wait for a
* timeout.
*
* Checks if new control data has arrived since the last waitForData call
* on the current thread. If new data has not arrived, returns immediately.
*
* If the timeout is less then or equal to 0, wait indefinitely.
*
* Timeout is in milliseconds
@@ -446,7 +452,7 @@ class DriverStation : public ErrorBase {
std::thread m_dsThread;
std::atomic<bool> m_isRunning{false};
wpi::mutex m_waitForDataMutex;
mutable wpi::mutex m_waitForDataMutex;
wpi::condition_variable m_waitForDataCond;
int m_waitForDataCounter;