Squashed 'third_party/allwpilib_2019/' changes from e20d96ea4e..b0167e6337
32c62449be Add ArrayRef overloads to new command classes (#2216)
6190fcb237 Run wpiformat (#2218)
012d93b2bd Use an explicit stack instead of recursion when parameterizing splines (#2197)
222669dc2c Fix trapezoidal profile PID controller setpoint bug (#2210)
abe25b795b TrajectoryUtil.toPathweaverJson: Create parent directories (#2214)
354185189c Update ProjectYear to 2020 (#2212)
f14fe434a1 Add (Old) qualifier to old subsystem (#2211)
e874ba9313 Add Color classes for use with AddressableLED (#2127)
96348e835a Fix C++ SendableRegistry::AddChild() (#2207)
d91796f8d2 fix clang-format version number (#2206)
9abce8eb06 Fix subsystem LiveWindow usage (#2202)
8b4508ad53 Use default path for networktables.ini in simulation (#2205)
5b7dd186d2 Add templates for new commands for vscode plugin (#2016)
6ea13ea8f3 ntcore: Add support for local-only operation (#2204)
44bcf7fb4d Java examples: use non-static imports for constants (#2191)
c7a1dfc0bc Add SlewRateLimiter class (#2192)
a12bb447e4 Fail cmake build if python3 generate_numbers.py fails (#2203)
c4bd54ef44 Add JNI binding to suppress driver station error/warning messages (#2200)
f9a11cce5e Remove -no-module-directories flag from javadoc build (#2201)
6008671c30 Report WPILib version as part of usage reporting (#2199)
7b952d599d Add usage reporting for many new things (#2184)
93cdf68694 Add Constants.cpp for MecanumControllerCommand example (#2196)
0c6f24562f Fix bug in ULEB128 decoding (#2195)
bdc1cab013 Add support for configuring SPI Auto Stall Config (#2193)
3259cffc63 Add transform methods to Trajectory (#2187)
67b59f2b31 Minor improvements/fixes to new command framework (#2186)
1ce24a7a2f Add 2020 speed controllers (#2188)
635882a9f7 Add getter for initial pose in Trajectory (#2180)
71a22861eb Use ManagedStatic for CameraServer (#2174)
9cb69c5b46 Add a way to pass in a preconstructed value to ManagedStatic (#2175)
5e08bb28f8 Add docs and lifecycle tasks for faster dev builds (#2182)
ea4d1a39e1 Update characterization values to match real robot (#2183)
31b588d961 Fix ArmFeedforward Javadocs (#2176)
0b80d566ad Use ChipObject HMB function for LED (#2173)
f8294e689b Sim GUI: Add a bit of spacing to the analog inputs (#2170)
b78f115fcf Work around VS2019 16.4.0 bugs (#2171)
b468c51251 Change AddressableLED example to use consistent PWM port (#2168)
023c088290 Add toString() to relevant kinematics classes (#2160)
8a11d13a39 Fix C++ DutyCycleEncoder int constructor (#2166)
daa81c64a7 Minor javadoc fix in SwerveDriveKinematicsConstraint (#2167)
Change-Id: Ied6a4d039f2b95381e1d2124fcc70d52580cc165
git-subtree-dir: third_party/allwpilib_2019
git-subtree-split: b0167e6337135545e7053acb89dd5726accc7dec
diff --git a/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java b/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java
index c473181..c203213 100644
--- a/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java
+++ b/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 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. */
@@ -61,4 +61,6 @@
double timeout);
public static native int spiGetAutoDroppedCount(int port);
+
+ public static native void spiConfigureAutoStall(int port, int csToSclkTicks, int stallTicks, int pow2BytesPerRead);
}
diff --git a/hal/src/main/java/edu/wpi/first/hal/sim/DriverStationSim.java b/hal/src/main/java/edu/wpi/first/hal/sim/DriverStationSim.java
index f87051f..d14af9f 100644
--- a/hal/src/main/java/edu/wpi/first/hal/sim/DriverStationSim.java
+++ b/hal/src/main/java/edu/wpi/first/hal/sim/DriverStationSim.java
@@ -79,6 +79,15 @@
DriverStationDataJNI.notifyNewData();
}
+ /**
+ * Toggles suppression of DriverStation.reportError and reportWarning messages.
+ *
+ * @param shouldSend If false then messages will will be suppressed.
+ */
+ public void setSendError(boolean shouldSend) {
+ DriverStationDataJNI.setSendError(shouldSend);
+ }
+
public void resetData() {
DriverStationDataJNI.resetData();
}
diff --git a/hal/src/main/java/edu/wpi/first/hal/sim/mockdata/DriverStationDataJNI.java b/hal/src/main/java/edu/wpi/first/hal/sim/mockdata/DriverStationDataJNI.java
index 2d41ca7..ec19735 100644
--- a/hal/src/main/java/edu/wpi/first/hal/sim/mockdata/DriverStationDataJNI.java
+++ b/hal/src/main/java/edu/wpi/first/hal/sim/mockdata/DriverStationDataJNI.java
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2018-2019 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. */
@@ -49,5 +49,7 @@
public static native void registerAllCallbacks(NotifyCallback callback, boolean initialNotify);
public static native void notifyNewData();
+ public static native void setSendError(boolean shouldSend);
+
public static native void resetData();
}
diff --git a/hal/src/main/native/athena/AddressableLED.cpp b/hal/src/main/native/athena/AddressableLED.cpp
index 9ecc4c4..64b6457 100644
--- a/hal/src/main/native/athena/AddressableLED.cpp
+++ b/hal/src/main/native/athena/AddressableLED.cpp
@@ -9,6 +9,8 @@
#include <cstring>
+#include <FRC_FPGA_ChipObject/fpgainterfacecapi/NiFpga_HMB.h>
+
#include "ConstantsInternal.h"
#include "DigitalInternal.h"
#include "HALInitializer.h"
@@ -19,14 +21,6 @@
using namespace hal;
-extern "C" {
-NiFpga_Status NiFpga_ClientFunctionCall(NiFpga_Session session, uint32_t group,
- uint32_t functionId,
- const void* inBuffer,
- size_t inBufferSize, void* outBuffer,
- size_t outBufferSize);
-} // extern "C"
-
namespace {
struct AddressableLED {
std::unique_ptr<tLED> led;
@@ -52,43 +46,6 @@
} // namespace init
} // namespace hal
-// Shim for broken ChipObject function
-static const uint32_t clientFeature_hostMemoryBuffer = 0;
-static const uint32_t hostMemoryBufferFunction_open = 2;
-
-// Input arguments for HMB open
-struct AtomicHMBOpenInputs {
- const char* memoryName;
-};
-
-// Output arguments for HMB open
-struct AtomicHMBOpenOutputs {
- size_t size;
- void* virtualAddress;
-};
-
-static NiFpga_Status OpenHostMemoryBuffer(NiFpga_Session session,
- const char* memoryName,
- void** virtualAddress, size_t* size) {
- struct AtomicHMBOpenOutputs outputs;
-
- struct AtomicHMBOpenInputs inputs;
- inputs.memoryName = memoryName;
-
- NiFpga_Status retval = NiFpga_ClientFunctionCall(
- session, clientFeature_hostMemoryBuffer, hostMemoryBufferFunction_open,
- &inputs, sizeof(struct AtomicHMBOpenInputs), &outputs,
- sizeof(struct AtomicHMBOpenOutputs));
- if (NiFpga_IsError(retval)) {
- return retval;
- }
- *virtualAddress = outputs.virtualAddress;
- if (size != NULL) {
- *size = outputs.size;
- }
- return retval;
-}
-
extern "C" {
HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
@@ -146,8 +103,8 @@
uint32_t session = led->led->getSystemInterface()->getHandle();
- *status = OpenHostMemoryBuffer(session, "HMB_0_LED", &led->ledBuffer,
- &led->ledBufferSize);
+ *status = NiFpga_OpenHostMemoryBuffer(session, "HMB_0_LED", &led->ledBuffer,
+ &led->ledBufferSize);
if (*status != 0) {
addressableLEDHandles->Free(handle);
diff --git a/hal/src/main/native/athena/SPI.cpp b/hal/src/main/native/athena/SPI.cpp
index 80cbf09..37c5f0e 100644
--- a/hal/src/main/native/athena/SPI.cpp
+++ b/hal/src/main/native/athena/SPI.cpp
@@ -631,12 +631,21 @@
return spiSystem->readTransferSkippedFullCount(status);
}
-// These 2 functions are so the new stall functionality
-// can be tested. How they're used is not very clear
-// but I want them to be testable so we can add an impl.
-// We will not be including these in the headers
-void* HAL_GetSPIDMAManager() { return spiAutoDMA.get(); }
+void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
+ int32_t stallTicks, int32_t pow2BytesPerRead,
+ int32_t* status) {
+ std::scoped_lock lock(spiAutoMutex);
+ // FPGA only has one auto SPI engine
+ if (port != spiAutoPort) {
+ *status = INCOMPATIBLE_STATE;
+ return;
+ }
-void* HAL_GetSPISystem() { return spiSystem.get(); }
+ tSPI::tStallConfig stallConfig;
+ stallConfig.CsToSclkTicks = static_cast<uint8_t>(csToSclkTicks);
+ stallConfig.StallTicks = static_cast<uint16_t>(stallTicks);
+ stallConfig.Pow2BytesPerRead = static_cast<uint8_t>(pow2BytesPerRead);
+ spiSystem->writeStallConfig(stallConfig, status);
+}
} // extern "C"
diff --git a/hal/src/main/native/cpp/jni/SPIJNI.cpp b/hal/src/main/native/cpp/jni/SPIJNI.cpp
index 27078fd..7962e21 100644
--- a/hal/src/main/native/cpp/jni/SPIJNI.cpp
+++ b/hal/src/main/native/cpp/jni/SPIJNI.cpp
@@ -394,4 +394,20 @@
return retval;
}
+/*
+ * Class: edu_wpi_first_hal_SPIJNI
+ * Method: spiConfigureAutoStall
+ * Signature: (IIII)V
+ */
+JNIEXPORT void JNICALL
+Java_edu_wpi_first_hal_SPIJNI_spiConfigureAutoStall
+ (JNIEnv* env, jclass, jint port, jint csToSclkTicks, jint stallTicks,
+ jint pow2BytesPerRead)
+{
+ int32_t status = 0;
+ HAL_ConfigureSPIAutoStall(static_cast<HAL_SPIPort>(port), csToSclkTicks,
+ stallTicks, pow2BytesPerRead, &status);
+ CheckStatus(env, status);
+}
+
} // extern "C"
diff --git a/hal/src/main/native/include/hal/ChipObject.h b/hal/src/main/native/include/hal/ChipObject.h
index 9b321c2..d891ced 100644
--- a/hal/src/main/native/include/hal/ChipObject.h
+++ b/hal/src/main/native/include/hal/ChipObject.h
@@ -27,6 +27,7 @@
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDutyCycle.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h>
+#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tHMB.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tLED.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h>
diff --git a/hal/src/main/native/include/hal/SPI.h b/hal/src/main/native/include/hal/SPI.h
index 4f1815f..abee379 100644
--- a/hal/src/main/native/include/hal/SPI.h
+++ b/hal/src/main/native/include/hal/SPI.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2016-2019 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. */
@@ -244,6 +244,19 @@
*/
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status);
+/**
+ * Configure the Auto SPI Stall time between reads.
+ *
+ * @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
+ * MXP.
+ * @param csToSclkTicks the number of ticks to wait before asserting the cs pin
+ * @param stallTicks the number of ticks to stall for
+ * @param pow2BytesPerRead the number of bytes to read before stalling
+ */
+void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
+ int32_t stallTicks, int32_t pow2BytesPerRead,
+ int32_t* status);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/hal/src/main/native/include/mockdata/SimCallbackRegistry.h b/hal/src/main/native/include/mockdata/SimCallbackRegistry.h
index 7190dcf..3e1aeb0 100644
--- a/hal/src/main/native/include/mockdata/SimCallbackRegistry.h
+++ b/hal/src/main/native/include/mockdata/SimCallbackRegistry.h
@@ -74,7 +74,11 @@
template <typename... U>
void Invoke(U&&... u) const {
+#ifdef _MSC_VER // work around VS2019 16.4.0 bug
+ std::scoped_lock<wpi::recursive_spinlock> lock(m_mutex);
+#else
std::scoped_lock lock(m_mutex);
+#endif
if (m_callbacks) {
const char* name = GetName();
for (auto&& cb : *m_callbacks)
diff --git a/hal/src/main/native/sim/SPI.cpp b/hal/src/main/native/sim/SPI.cpp
index 8c539d3..1c90a98 100644
--- a/hal/src/main/native/sim/SPI.cpp
+++ b/hal/src/main/native/sim/SPI.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-2019 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. */
@@ -18,6 +18,8 @@
} // namespace init
} // namespace hal
+extern "C" {
+
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
hal::init::CheckInit();
SimSPIData[port].initialized = true;
@@ -63,3 +65,9 @@
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
return 0;
}
+
+void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
+ int32_t stallTicks, int32_t pow2BytesPerRead,
+ int32_t* status) {}
+
+} // extern "C"
diff --git a/hal/src/main/native/sim/jni/DriverStationDataJNI.cpp b/hal/src/main/native/sim/jni/DriverStationDataJNI.cpp
index 621650a..82433b3 100644
--- a/hal/src/main/native/sim/jni/DriverStationDataJNI.cpp
+++ b/hal/src/main/native/sim/jni/DriverStationDataJNI.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2018-2019 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. */
@@ -14,6 +14,7 @@
#include "CallbackStore.h"
#include "edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI.h"
#include "mockdata/DriverStationData.h"
+#include "mockdata/MockHooks.h"
using namespace wpi::java;
@@ -448,6 +449,25 @@
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI
+ * Method: setSendError
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL
+Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setSendError
+ (JNIEnv*, jclass, jboolean shouldSend)
+{
+ if (shouldSend) {
+ HALSIM_SetSendError(nullptr);
+ } else {
+ HALSIM_SetSendError([](HAL_Bool isError, int32_t errorCode,
+ HAL_Bool isLVCode, const char* details,
+ const char* location, const char* callStack,
+ HAL_Bool printMsg) { return 1; });
+ }
+}
+
+/*
+ * Class: edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI
* Method: resetData
* Signature: ()V
*/