diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0e6bc0884..348e0d9797 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,6 +187,7 @@ if (WITH_GUI)
add_subdirectory(imgui)
add_subdirectory(wpigui)
add_subdirectory(glass)
+ add_subdirectory(outlineviewer)
endif()
if (WITH_CSCORE)
diff --git a/cameraserver/multiCameraServer/src/main/java/edu/wpi/Main.java b/cameraserver/multiCameraServer/src/main/java/edu/wpi/Main.java
index 3366b39979..f488487c55 100644
--- a/cameraserver/multiCameraServer/src/main/java/edu/wpi/Main.java
+++ b/cameraserver/multiCameraServer/src/main/java/edu/wpi/Main.java
@@ -10,8 +10,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import edu.wpi.cscore.VideoSource;
import edu.wpi.first.cameraserver.CameraServer;
+import edu.wpi.first.cscore.VideoSource;
import edu.wpi.first.networktables.NetworkTableInstance;
import java.io.IOException;
import java.nio.file.Files;
diff --git a/cameraserver/multiCameraServer/src/main/native/cpp/main.cpp b/cameraserver/multiCameraServer/src/main/native/cpp/main.cpp
index df408dee2a..e030fd9f22 100644
--- a/cameraserver/multiCameraServer/src/main/native/cpp/main.cpp
+++ b/cameraserver/multiCameraServer/src/main/native/cpp/main.cpp
@@ -158,7 +158,7 @@ bool ReadConfig() {
void StartCamera(const CameraConfig& config) {
wpi::outs() << "Starting camera '" << config.name << "' on " << config.path
<< '\n';
- auto camera = frc::CameraServer::GetInstance()->StartAutomaticCapture(
+ auto camera = frc::CameraServer::GetInstance().StartAutomaticCapture(
config.name, config.path);
camera.SetConfigJson(config.config);
diff --git a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java
index 6867d5f9ec..b994749577 100644
--- a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java
+++ b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java
@@ -4,20 +4,20 @@
package edu.wpi.first.cameraserver;
-import edu.wpi.cscore.AxisCamera;
-import edu.wpi.cscore.CameraServerJNI;
-import edu.wpi.cscore.CvSink;
-import edu.wpi.cscore.CvSource;
-import edu.wpi.cscore.MjpegServer;
-import edu.wpi.cscore.UsbCamera;
-import edu.wpi.cscore.VideoEvent;
-import edu.wpi.cscore.VideoException;
-import edu.wpi.cscore.VideoListener;
-import edu.wpi.cscore.VideoMode;
-import edu.wpi.cscore.VideoMode.PixelFormat;
-import edu.wpi.cscore.VideoProperty;
-import edu.wpi.cscore.VideoSink;
-import edu.wpi.cscore.VideoSource;
+import edu.wpi.first.cscore.AxisCamera;
+import edu.wpi.first.cscore.CameraServerJNI;
+import edu.wpi.first.cscore.CvSink;
+import edu.wpi.first.cscore.CvSource;
+import edu.wpi.first.cscore.MjpegServer;
+import edu.wpi.first.cscore.UsbCamera;
+import edu.wpi.first.cscore.VideoEvent;
+import edu.wpi.first.cscore.VideoException;
+import edu.wpi.first.cscore.VideoListener;
+import edu.wpi.first.cscore.VideoMode;
+import edu.wpi.first.cscore.VideoMode.PixelFormat;
+import edu.wpi.first.cscore.VideoProperty;
+import edu.wpi.first.cscore.VideoSink;
+import edu.wpi.first.cscore.VideoSource;
import edu.wpi.first.networktables.EntryListenerFlags;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
diff --git a/cameraserver/src/main/java/edu/wpi/first/vision/VisionRunner.java b/cameraserver/src/main/java/edu/wpi/first/vision/VisionRunner.java
index 2a1275791c..ab7072f6c9 100644
--- a/cameraserver/src/main/java/edu/wpi/first/vision/VisionRunner.java
+++ b/cameraserver/src/main/java/edu/wpi/first/vision/VisionRunner.java
@@ -4,9 +4,9 @@
package edu.wpi.first.vision;
-import edu.wpi.cscore.CvSink;
-import edu.wpi.cscore.VideoSource;
import edu.wpi.first.cameraserver.CameraServerSharedStore;
+import edu.wpi.first.cscore.CvSink;
+import edu.wpi.first.cscore.VideoSource;
import org.opencv.core.Mat;
/**
diff --git a/cameraserver/src/main/java/edu/wpi/first/vision/VisionThread.java b/cameraserver/src/main/java/edu/wpi/first/vision/VisionThread.java
index 5ce896dbf9..6f1a1e35b5 100644
--- a/cameraserver/src/main/java/edu/wpi/first/vision/VisionThread.java
+++ b/cameraserver/src/main/java/edu/wpi/first/vision/VisionThread.java
@@ -4,7 +4,7 @@
package edu.wpi.first.vision;
-import edu.wpi.cscore.VideoSource;
+import edu.wpi.first.cscore.VideoSource;
/**
* A vision thread is a special thread that runs a vision pipeline. It is a daemon thread; it
diff --git a/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java b/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java
index 758ea2889d..b7bab9c35c 100644
--- a/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java
+++ b/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java
@@ -13,7 +13,7 @@
* implements VisionRunner.Listener<MyFindTotePipeline> {
*
* // A USB camera connected to the roboRIO.
- * private {@link edu.wpi.cscore.VideoSource VideoSource} usbCamera;
+ * private {@link edu.wpi.first.cscore.VideoSource VideoSource} usbCamera;
*
* // A vision pipeline. This could be handwritten or generated by GRIP.
* // This has to implement {@link edu.wpi.first.vision.VisionPipeline}.
diff --git a/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp b/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp
index fa18a8e14b..b258d3bbf9 100644
--- a/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp
+++ b/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp
@@ -45,7 +45,7 @@ struct CameraServer::Impl {
std::vector m_addresses;
};
-CameraServer* CameraServer::GetInstance() {
+CameraServer& CameraServer::GetInstance() {
struct Creator {
static void* call() { return new CameraServer{}; }
};
@@ -53,7 +53,7 @@ CameraServer* CameraServer::GetInstance() {
static void call(void* ptr) { delete static_cast(ptr); }
};
static wpi::ManagedStatic instance;
- return &(*instance);
+ return *instance;
}
static wpi::StringRef MakeSourceValue(CS_Source source,
diff --git a/cameraserver/src/main/native/include/cameraserver/CameraServer.h b/cameraserver/src/main/native/include/cameraserver/CameraServer.h
index ce620ed1b8..2cf73e8fa4 100644
--- a/cameraserver/src/main/native/include/cameraserver/CameraServer.h
+++ b/cameraserver/src/main/native/include/cameraserver/CameraServer.h
@@ -32,7 +32,7 @@ class CameraServer {
/**
* Get the CameraServer instance.
*/
- static CameraServer* GetInstance();
+ static CameraServer& GetInstance();
/**
* Start automatically capturing images to send to the dashboard.
diff --git a/cscore/src/dev/java/edu/wpi/cscore/DevMain.java b/cscore/src/dev/java/edu/wpi/first/cscore/DevMain.java
similarity index 94%
rename from cscore/src/dev/java/edu/wpi/cscore/DevMain.java
rename to cscore/src/dev/java/edu/wpi/first/cscore/DevMain.java
index 69198cb247..5ccbed722b 100644
--- a/cscore/src/dev/java/edu/wpi/cscore/DevMain.java
+++ b/cscore/src/dev/java/edu/wpi/first/cscore/DevMain.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import edu.wpi.first.wpiutil.RuntimeDetector;
diff --git a/cscore/src/main/java/edu/wpi/cscore/AxisCamera.java b/cscore/src/main/java/edu/wpi/first/cscore/AxisCamera.java
similarity index 97%
rename from cscore/src/main/java/edu/wpi/cscore/AxisCamera.java
rename to cscore/src/main/java/edu/wpi/first/cscore/AxisCamera.java
index c219517ee5..296bd6bd14 100644
--- a/cscore/src/main/java/edu/wpi/cscore/AxisCamera.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/AxisCamera.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** A source that represents an Axis IP camera. */
public class AxisCamera extends HttpCamera {
diff --git a/cscore/src/main/java/edu/wpi/cscore/CameraServerCvJNI.java b/cscore/src/main/java/edu/wpi/first/cscore/CameraServerCvJNI.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/CameraServerCvJNI.java
rename to cscore/src/main/java/edu/wpi/first/cscore/CameraServerCvJNI.java
index 34fcfc22c5..6d382c87db 100644
--- a/cscore/src/main/java/edu/wpi/cscore/CameraServerCvJNI.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/CameraServerCvJNI.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import edu.wpi.first.wpiutil.RuntimeLoader;
import java.io.IOException;
diff --git a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java b/cscore/src/main/java/edu/wpi/first/cscore/CameraServerJNI.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java
rename to cscore/src/main/java/edu/wpi/first/cscore/CameraServerJNI.java
index 2672a90ecd..b7a9216e82 100644
--- a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/CameraServerJNI.java
@@ -2,9 +2,9 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
-import edu.wpi.cscore.raw.RawFrame;
+import edu.wpi.first.cscore.raw.RawFrame;
import edu.wpi.first.wpiutil.RuntimeLoader;
import java.io.IOException;
import java.nio.ByteBuffer;
diff --git a/cscore/src/main/java/edu/wpi/cscore/CvSink.java b/cscore/src/main/java/edu/wpi/first/cscore/CvSink.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/CvSink.java
rename to cscore/src/main/java/edu/wpi/first/cscore/CvSink.java
index 5e3489ca12..28f0dd13a8 100644
--- a/cscore/src/main/java/edu/wpi/cscore/CvSink.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/CvSink.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import org.opencv.core.Mat;
diff --git a/cscore/src/main/java/edu/wpi/cscore/CvSource.java b/cscore/src/main/java/edu/wpi/first/cscore/CvSource.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/CvSource.java
rename to cscore/src/main/java/edu/wpi/first/cscore/CvSource.java
index 09f551b7c6..3934a09c0b 100644
--- a/cscore/src/main/java/edu/wpi/cscore/CvSource.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/CvSource.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import org.opencv.core.Mat;
diff --git a/cscore/src/main/java/edu/wpi/cscore/HttpCamera.java b/cscore/src/main/java/edu/wpi/first/cscore/HttpCamera.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/HttpCamera.java
rename to cscore/src/main/java/edu/wpi/first/cscore/HttpCamera.java
index 1caeb338ac..9758f90436 100644
--- a/cscore/src/main/java/edu/wpi/cscore/HttpCamera.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/HttpCamera.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** A source that represents a MJPEG-over-HTTP (IP) camera. */
public class HttpCamera extends VideoCamera {
diff --git a/cscore/src/main/java/edu/wpi/cscore/ImageSink.java b/cscore/src/main/java/edu/wpi/first/cscore/ImageSink.java
similarity index 97%
rename from cscore/src/main/java/edu/wpi/cscore/ImageSink.java
rename to cscore/src/main/java/edu/wpi/first/cscore/ImageSink.java
index 8907ee1106..55318da1cb 100644
--- a/cscore/src/main/java/edu/wpi/cscore/ImageSink.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/ImageSink.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
public abstract class ImageSink extends VideoSink {
protected ImageSink(int handle) {
diff --git a/cscore/src/main/java/edu/wpi/cscore/ImageSource.java b/cscore/src/main/java/edu/wpi/first/cscore/ImageSource.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/ImageSource.java
rename to cscore/src/main/java/edu/wpi/first/cscore/ImageSource.java
index 93f994c250..431e75cfa4 100644
--- a/cscore/src/main/java/edu/wpi/cscore/ImageSource.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/ImageSource.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
public abstract class ImageSource extends VideoSource {
protected ImageSource(int handle) {
diff --git a/cscore/src/main/java/edu/wpi/cscore/MjpegServer.java b/cscore/src/main/java/edu/wpi/first/cscore/MjpegServer.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/MjpegServer.java
rename to cscore/src/main/java/edu/wpi/first/cscore/MjpegServer.java
index 29619d27d3..a1ffb6331d 100644
--- a/cscore/src/main/java/edu/wpi/cscore/MjpegServer.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/MjpegServer.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** A sink that acts as a MJPEG-over-HTTP network server. */
public class MjpegServer extends VideoSink {
diff --git a/cscore/src/main/java/edu/wpi/cscore/UsbCamera.java b/cscore/src/main/java/edu/wpi/first/cscore/UsbCamera.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/UsbCamera.java
rename to cscore/src/main/java/edu/wpi/first/cscore/UsbCamera.java
index 144a4aadb5..2b5cf5a41a 100644
--- a/cscore/src/main/java/edu/wpi/cscore/UsbCamera.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/UsbCamera.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** A source that represents a USB camera. */
public class UsbCamera extends VideoCamera {
diff --git a/cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java b/cscore/src/main/java/edu/wpi/first/cscore/UsbCameraInfo.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java
rename to cscore/src/main/java/edu/wpi/first/cscore/UsbCameraInfo.java
index 4899c77828..df856e8d2d 100644
--- a/cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/UsbCameraInfo.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** USB camera information. */
public class UsbCameraInfo {
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoCamera.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoCamera.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/VideoCamera.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoCamera.java
index 2a93112a9c..ca3b09e642 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoCamera.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoCamera.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** A source that represents a video camera. */
public class VideoCamera extends VideoSource {
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoEvent.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoEvent.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/VideoEvent.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoEvent.java
index c2731fdc78..ca38109b47 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoEvent.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoEvent.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** Video event. */
public class VideoEvent {
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoException.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoException.java
similarity index 94%
rename from cscore/src/main/java/edu/wpi/cscore/VideoException.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoException.java
index 1142c0f8d7..1c445c6f77 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoException.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoException.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** An exception raised by the camera server. */
public class VideoException extends RuntimeException {
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoListener.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoListener.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/VideoListener.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoListener.java
index cfaeb9da2a..0d77461432 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoListener.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoListener.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import java.util.HashMap;
import java.util.Map;
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoMode.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoMode.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/VideoMode.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoMode.java
index b7191eeb40..af7fb8f1cb 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoMode.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoMode.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** Video mode. */
public class VideoMode {
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoProperty.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoProperty.java
similarity index 98%
rename from cscore/src/main/java/edu/wpi/cscore/VideoProperty.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoProperty.java
index 53a24ad7fa..8179ba3c3d 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoProperty.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoProperty.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/** A source or sink property. */
public class VideoProperty {
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoSink.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoSink.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/VideoSink.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoSink.java
index 098f9cb4bf..ea65d0e54a 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoSink.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoSink.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/**
* A source for video that provides a sequence of frames. Each frame may consist of multiple images
diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoSource.java b/cscore/src/main/java/edu/wpi/first/cscore/VideoSource.java
similarity index 99%
rename from cscore/src/main/java/edu/wpi/cscore/VideoSource.java
rename to cscore/src/main/java/edu/wpi/first/cscore/VideoSource.java
index fc115c7924..047503a1e3 100644
--- a/cscore/src/main/java/edu/wpi/cscore/VideoSource.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/VideoSource.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
/**
* A source for video that provides a sequence of frames. Each frame may consist of multiple images
diff --git a/cscore/src/main/java/edu/wpi/cscore/raw/RawFrame.java b/cscore/src/main/java/edu/wpi/first/cscore/raw/RawFrame.java
similarity index 97%
rename from cscore/src/main/java/edu/wpi/cscore/raw/RawFrame.java
rename to cscore/src/main/java/edu/wpi/first/cscore/raw/RawFrame.java
index 18da73dc3a..1919d6b2dd 100644
--- a/cscore/src/main/java/edu/wpi/cscore/raw/RawFrame.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/raw/RawFrame.java
@@ -2,9 +2,9 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore.raw;
+package edu.wpi.first.cscore.raw;
-import edu.wpi.cscore.CameraServerJNI;
+import edu.wpi.first.cscore.CameraServerJNI;
import java.nio.ByteBuffer;
/**
diff --git a/cscore/src/main/java/edu/wpi/cscore/raw/RawSink.java b/cscore/src/main/java/edu/wpi/first/cscore/raw/RawSink.java
similarity index 94%
rename from cscore/src/main/java/edu/wpi/cscore/raw/RawSink.java
rename to cscore/src/main/java/edu/wpi/first/cscore/raw/RawSink.java
index e9854136b7..64afae2b64 100644
--- a/cscore/src/main/java/edu/wpi/cscore/raw/RawSink.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/raw/RawSink.java
@@ -2,10 +2,10 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore.raw;
+package edu.wpi.first.cscore.raw;
-import edu.wpi.cscore.CameraServerJNI;
-import edu.wpi.cscore.ImageSink;
+import edu.wpi.first.cscore.CameraServerJNI;
+import edu.wpi.first.cscore.ImageSink;
/**
* A sink for user code to accept video frames as raw bytes.
diff --git a/cscore/src/main/java/edu/wpi/cscore/raw/RawSource.java b/cscore/src/main/java/edu/wpi/first/cscore/raw/RawSource.java
similarity index 93%
rename from cscore/src/main/java/edu/wpi/cscore/raw/RawSource.java
rename to cscore/src/main/java/edu/wpi/first/cscore/raw/RawSource.java
index 89cb257670..f1be05065b 100644
--- a/cscore/src/main/java/edu/wpi/cscore/raw/RawSource.java
+++ b/cscore/src/main/java/edu/wpi/first/cscore/raw/RawSource.java
@@ -2,11 +2,11 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore.raw;
+package edu.wpi.first.cscore.raw;
-import edu.wpi.cscore.CameraServerJNI;
-import edu.wpi.cscore.ImageSource;
-import edu.wpi.cscore.VideoMode;
+import edu.wpi.first.cscore.CameraServerJNI;
+import edu.wpi.first.cscore.ImageSource;
+import edu.wpi.first.cscore.VideoMode;
/**
* A source for user code to provide video frames as raw bytes.
diff --git a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp
index 62ab2b29da..a603fbf820 100644
--- a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp
+++ b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp
@@ -12,7 +12,7 @@
#include "cscore_cpp.h"
#include "cscore_cv.h"
#include "cscore_raw.h"
-#include "edu_wpi_cscore_CameraServerJNI.h"
+#include "edu_wpi_first_cscore_CameraServerJNI.h"
namespace cv {
class Mat;
@@ -39,13 +39,13 @@ static JException exceptionEx;
static JNIEnv* listenerEnv = nullptr;
static const JClassInit classes[] = {
- {"edu/wpi/cscore/UsbCameraInfo", &usbCameraInfoCls},
- {"edu/wpi/cscore/VideoMode", &videoModeCls},
- {"edu/wpi/cscore/VideoEvent", &videoEventCls},
- {"edu/wpi/cscore/raw/RawFrame", &rawFrameCls}};
+ {"edu/wpi/first/cscore/UsbCameraInfo", &usbCameraInfoCls},
+ {"edu/wpi/first/cscore/VideoMode", &videoModeCls},
+ {"edu/wpi/first/cscore/VideoEvent", &videoEventCls},
+ {"edu/wpi/first/cscore/raw/RawFrame", &rawFrameCls}};
static const JExceptionInit exceptions[] = {
- {"edu/wpi/cscore/VideoException", &videoEx},
+ {"edu/wpi/first/cscore/VideoException", &videoEx},
{"java/lang/InterruptedException", &interruptedEx},
{"java/lang/NullPointerException", &nullPointerEx},
{"java/lang/UnsupportedOperationException", &unsupportedEx},
@@ -308,12 +308,12 @@ static jobjectArray MakeJObject(JNIEnv* env, wpi::ArrayRef arr) {
extern "C" {
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getPropertyKind
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getPropertyKind
+Java_edu_wpi_first_cscore_CameraServerJNI_getPropertyKind
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -323,12 +323,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getPropertyKind
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getPropertyName
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getPropertyName
+Java_edu_wpi_first_cscore_CameraServerJNI_getPropertyName
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -341,12 +341,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getPropertyName
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getProperty
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_getProperty
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -356,12 +356,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setProperty
* Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_setProperty
(JNIEnv* env, jclass, jint property, jint value)
{
CS_Status status = 0;
@@ -370,12 +370,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getPropertyMin
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getPropertyMin
+Java_edu_wpi_first_cscore_CameraServerJNI_getPropertyMin
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -385,12 +385,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getPropertyMin
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getPropertyMax
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getPropertyMax
+Java_edu_wpi_first_cscore_CameraServerJNI_getPropertyMax
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -400,12 +400,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getPropertyMax
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getPropertyStep
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getPropertyStep
+Java_edu_wpi_first_cscore_CameraServerJNI_getPropertyStep
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -415,12 +415,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getPropertyStep
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getPropertyDefault
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getPropertyDefault
+Java_edu_wpi_first_cscore_CameraServerJNI_getPropertyDefault
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -430,12 +430,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getPropertyDefault
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getStringProperty
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getStringProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_getStringProperty
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -448,12 +448,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getStringProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setStringProperty
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setStringProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_setStringProperty
(JNIEnv* env, jclass, jint property, jstring value)
{
if (!value) {
@@ -466,12 +466,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setStringProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getEnumPropertyChoices
* Signature: (I)[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getEnumPropertyChoices
+Java_edu_wpi_first_cscore_CameraServerJNI_getEnumPropertyChoices
(JNIEnv* env, jclass, jint property)
{
CS_Status status = 0;
@@ -483,12 +483,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getEnumPropertyChoices
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createUsbCameraDev
* Signature: (Ljava/lang/String;I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraDev
+Java_edu_wpi_first_cscore_CameraServerJNI_createUsbCameraDev
(JNIEnv* env, jclass, jstring name, jint dev)
{
if (!name) {
@@ -502,12 +502,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraDev
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createUsbCameraPath
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraPath
+Java_edu_wpi_first_cscore_CameraServerJNI_createUsbCameraPath
(JNIEnv* env, jclass, jstring name, jstring path)
{
if (!name) {
@@ -526,12 +526,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraPath
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createHttpCamera
* Signature: (Ljava/lang/String;Ljava/lang/String;I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createHttpCamera
+Java_edu_wpi_first_cscore_CameraServerJNI_createHttpCamera
(JNIEnv* env, jclass, jstring name, jstring url, jint kind)
{
if (!name) {
@@ -551,12 +551,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createHttpCamera
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createHttpCameraMulti
* Signature: (Ljava/lang/String;[Ljava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti
+Java_edu_wpi_first_cscore_CameraServerJNI_createHttpCameraMulti
(JNIEnv* env, jclass, jstring name, jobjectArray urls, jint kind)
{
if (!name) {
@@ -588,12 +588,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti
}
/*
- * Class: edu_wpi_cscore_CameraServerCvJNI
+ * Class: edu_wpi_first_cscore_CameraServerCvJNI
* Method: createCvSource
* Signature: (Ljava/lang/String;IIII)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerCvJNI_createCvSource
+Java_edu_wpi_first_cscore_CameraServerCvJNI_createCvSource
(JNIEnv* env, jclass, jstring name, jint pixelFormat, jint width, jint height,
jint fps)
{
@@ -613,12 +613,12 @@ Java_edu_wpi_cscore_CameraServerCvJNI_createCvSource
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createRawSource
* Signature: (Ljava/lang/String;IIII)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createRawSource
+Java_edu_wpi_first_cscore_CameraServerJNI_createRawSource
(JNIEnv* env, jclass, jstring name, jint pixelFormat, jint width, jint height,
jint fps)
{
@@ -638,12 +638,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createRawSource
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceKind
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceKind
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceKind
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -653,12 +653,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceKind
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceName
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceName
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceName
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -671,12 +671,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceName
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceDescription
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceDescription
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceDescription
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -689,12 +689,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceDescription
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceLastFrameTime
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceLastFrameTime
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceLastFrameTime
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -704,12 +704,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceLastFrameTime
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceConnectionStrategy
* Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceConnectionStrategy
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceConnectionStrategy
(JNIEnv* env, jclass, jint source, jint strategy)
{
CS_Status status = 0;
@@ -719,12 +719,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceConnectionStrategy
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: isSourceConnected
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_isSourceConnected
+Java_edu_wpi_first_cscore_CameraServerJNI_isSourceConnected
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -734,12 +734,12 @@ Java_edu_wpi_cscore_CameraServerJNI_isSourceConnected
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: isSourceEnabled
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_isSourceEnabled
+Java_edu_wpi_first_cscore_CameraServerJNI_isSourceEnabled
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -749,12 +749,12 @@ Java_edu_wpi_cscore_CameraServerJNI_isSourceEnabled
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceProperty
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceProperty
(JNIEnv* env, jclass, jint source, jstring name)
{
if (!name) {
@@ -769,12 +769,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateSourceProperties
* Signature: (I)[I
*/
JNIEXPORT jintArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceProperties
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateSourceProperties
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -787,12 +787,12 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceProperties
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceVideoMode
* Signature: (I)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceVideoMode
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceVideoMode
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -804,12 +804,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceVideoMode
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceVideoMode
* Signature: (IIIII)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceVideoMode
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceVideoMode
(JNIEnv* env, jclass, jint source, jint pixelFormat, jint width, jint height,
jint fps)
{
@@ -824,12 +824,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceVideoMode
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourcePixelFormat
* Signature: (II)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourcePixelFormat
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourcePixelFormat
(JNIEnv* env, jclass, jint source, jint pixelFormat)
{
CS_Status status = 0;
@@ -840,12 +840,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourcePixelFormat
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceResolution
* Signature: (III)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceResolution
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceResolution
(JNIEnv* env, jclass, jint source, jint width, jint height)
{
CS_Status status = 0;
@@ -855,12 +855,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceResolution
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceFPS
* Signature: (II)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceFPS
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceFPS
(JNIEnv* env, jclass, jint source, jint fps)
{
CS_Status status = 0;
@@ -870,12 +870,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceFPS
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceConfigJson
* Signature: (ILjava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceConfigJson
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceConfigJson
(JNIEnv* env, jclass, jint source, jstring config)
{
CS_Status status = 0;
@@ -885,12 +885,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceConfigJson
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSourceConfigJson
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSourceConfigJson
+Java_edu_wpi_first_cscore_CameraServerJNI_getSourceConfigJson
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -900,12 +900,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSourceConfigJson
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateSourceVideoModes
* Signature: (I)[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceVideoModes
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateSourceVideoModes
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -925,12 +925,12 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceVideoModes
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateSourceSinks
* Signature: (I)[I
*/
JNIEXPORT jintArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceSinks
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateSourceSinks
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -943,12 +943,12 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceSinks
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: copySource
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_copySource
+Java_edu_wpi_first_cscore_CameraServerJNI_copySource
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -958,12 +958,12 @@ Java_edu_wpi_cscore_CameraServerJNI_copySource
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: releaseSource
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_releaseSource
+Java_edu_wpi_first_cscore_CameraServerJNI_releaseSource
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -972,12 +972,12 @@ Java_edu_wpi_cscore_CameraServerJNI_releaseSource
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraBrightness
* Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraBrightness
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraBrightness
(JNIEnv* env, jclass, jint source, jint brightness)
{
CS_Status status = 0;
@@ -986,12 +986,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraBrightness
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getCameraBrightness
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getCameraBrightness
+Java_edu_wpi_first_cscore_CameraServerJNI_getCameraBrightness
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1001,12 +1001,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getCameraBrightness
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraWhiteBalanceAuto
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceAuto
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraWhiteBalanceAuto
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1015,12 +1015,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceAuto
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraWhiteBalanceHoldCurrent
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceHoldCurrent
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraWhiteBalanceHoldCurrent
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1029,12 +1029,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceHoldCurrent
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraWhiteBalanceManual
* Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceManual
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraWhiteBalanceManual
(JNIEnv* env, jclass, jint source, jint value)
{
CS_Status status = 0;
@@ -1043,12 +1043,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceManual
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraExposureAuto
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureAuto
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraExposureAuto
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1057,12 +1057,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureAuto
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraExposureHoldCurrent
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureHoldCurrent
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraExposureHoldCurrent
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1071,12 +1071,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureHoldCurrent
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setCameraExposureManual
* Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureManual
+Java_edu_wpi_first_cscore_CameraServerJNI_setCameraExposureManual
(JNIEnv* env, jclass, jint source, jint value)
{
CS_Status status = 0;
@@ -1085,12 +1085,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureManual
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setUsbCameraPath
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setUsbCameraPath
+Java_edu_wpi_first_cscore_CameraServerJNI_setUsbCameraPath
(JNIEnv* env, jclass, jint source, jstring path)
{
CS_Status status = 0;
@@ -1099,12 +1099,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setUsbCameraPath
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getUsbCameraPath
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraPath
+Java_edu_wpi_first_cscore_CameraServerJNI_getUsbCameraPath
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1116,12 +1116,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraPath
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getUsbCameraInfo
* Signature: (I)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraInfo
+Java_edu_wpi_first_cscore_CameraServerJNI_getUsbCameraInfo
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1133,12 +1133,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraInfo
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getHttpCameraKind
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraKind
+Java_edu_wpi_first_cscore_CameraServerJNI_getHttpCameraKind
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1150,12 +1150,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraKind
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setHttpCameraUrls
* Signature: (I[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls
+Java_edu_wpi_first_cscore_CameraServerJNI_setHttpCameraUrls
(JNIEnv* env, jclass, jint source, jobjectArray urls)
{
if (!urls) {
@@ -1180,12 +1180,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getHttpCameraUrls
* Signature: (I)[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraUrls
+Java_edu_wpi_first_cscore_CameraServerJNI_getHttpCameraUrls
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1197,12 +1197,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraUrls
}
/*
- * Class: edu_wpi_cscore_CameraServerCvJNI
+ * Class: edu_wpi_first_cscore_CameraServerCvJNI
* Method: putSourceFrame
* Signature: (IJ)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerCvJNI_putSourceFrame
+Java_edu_wpi_first_cscore_CameraServerCvJNI_putSourceFrame
(JNIEnv* env, jclass, jint source, jlong imageNativeObj)
{
try {
@@ -1220,12 +1220,12 @@ Java_edu_wpi_cscore_CameraServerCvJNI_putSourceFrame
// int width, int height, int pixelFormat, int totalData
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: putRawSourceFrameBB
* Signature: (ILjava/lang/Object;IIII)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_putRawSourceFrameBB
+Java_edu_wpi_first_cscore_CameraServerJNI_putRawSourceFrameBB
(JNIEnv* env, jclass, jint source, jobject byteBuffer, jint width,
jint height, jint pixelFormat, jint totalData)
{
@@ -1242,12 +1242,12 @@ Java_edu_wpi_cscore_CameraServerJNI_putRawSourceFrameBB
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: putRawSourceFrame
* Signature: (IJIIII)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_putRawSourceFrame
+Java_edu_wpi_first_cscore_CameraServerJNI_putRawSourceFrame
(JNIEnv* env, jclass, jint source, jlong ptr, jint width, jint height,
jint pixelFormat, jint totalData)
{
@@ -1263,12 +1263,12 @@ Java_edu_wpi_cscore_CameraServerJNI_putRawSourceFrame
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: notifySourceError
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_notifySourceError
+Java_edu_wpi_first_cscore_CameraServerJNI_notifySourceError
(JNIEnv* env, jclass, jint source, jstring msg)
{
if (!msg) {
@@ -1281,12 +1281,12 @@ Java_edu_wpi_cscore_CameraServerJNI_notifySourceError
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceConnected
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceConnected
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceConnected
(JNIEnv* env, jclass, jint source, jboolean connected)
{
CS_Status status = 0;
@@ -1295,12 +1295,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceConnected
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceDescription
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceDescription
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceDescription
(JNIEnv* env, jclass, jint source, jstring description)
{
if (!description) {
@@ -1313,12 +1313,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceDescription
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createSourceProperty
* Signature: (ILjava/lang/String;IIIIII)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createSourceProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_createSourceProperty
(JNIEnv* env, jclass, jint source, jstring name, jint kind, jint minimum,
jint maximum, jint step, jint defaultValue, jint value)
{
@@ -1331,12 +1331,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createSourceProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSourceEnumPropertyChoices
* Signature: (II[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumPropertyChoices
+Java_edu_wpi_first_cscore_CameraServerJNI_setSourceEnumPropertyChoices
(JNIEnv* env, jclass, jint source, jint property, jobjectArray choices)
{
if (!choices) {
@@ -1361,12 +1361,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumPropertyChoices
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createMjpegServer
* Signature: (Ljava/lang/String;Ljava/lang/String;I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createMjpegServer
+Java_edu_wpi_first_cscore_CameraServerJNI_createMjpegServer
(JNIEnv* env, jclass, jstring name, jstring listenAddress, jint port)
{
if (!name) {
@@ -1386,12 +1386,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createMjpegServer
}
/*
- * Class: edu_wpi_cscore_CameraServerCvJNI
+ * Class: edu_wpi_first_cscore_CameraServerCvJNI
* Method: createCvSink
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerCvJNI_createCvSink
+Java_edu_wpi_first_cscore_CameraServerCvJNI_createCvSink
(JNIEnv* env, jclass, jstring name)
{
if (!name) {
@@ -1405,12 +1405,12 @@ Java_edu_wpi_cscore_CameraServerCvJNI_createCvSink
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createRawSink
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createRawSink
+Java_edu_wpi_first_cscore_CameraServerJNI_createRawSink
(JNIEnv* env, jclass, jstring name)
{
if (!name) {
@@ -1424,12 +1424,12 @@ Java_edu_wpi_cscore_CameraServerJNI_createRawSink
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkKind
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkKind
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkKind
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1439,12 +1439,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkKind
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkName
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkName
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkName
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1457,12 +1457,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkName
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkDescription
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkDescription
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1475,12 +1475,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkProperty
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkProperty
(JNIEnv* env, jclass, jint sink, jstring name)
{
if (!name) {
@@ -1494,12 +1494,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateSinkProperties
* Signature: (I)[I
*/
JNIEXPORT jintArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateSinkProperties
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateSinkProperties
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1512,12 +1512,12 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateSinkProperties
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSinkConfigJson
* Signature: (ILjava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSinkConfigJson
+Java_edu_wpi_first_cscore_CameraServerJNI_setSinkConfigJson
(JNIEnv* env, jclass, jint source, jstring config)
{
CS_Status status = 0;
@@ -1527,12 +1527,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSinkConfigJson
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkConfigJson
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkConfigJson
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkConfigJson
(JNIEnv* env, jclass, jint source)
{
CS_Status status = 0;
@@ -1542,12 +1542,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkConfigJson
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSinkSource
* Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSinkSource
+Java_edu_wpi_first_cscore_CameraServerJNI_setSinkSource
(JNIEnv* env, jclass, jint sink, jint source)
{
CS_Status status = 0;
@@ -1556,12 +1556,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSinkSource
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkSourceProperty
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkSourceProperty
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkSourceProperty
(JNIEnv* env, jclass, jint sink, jstring name)
{
if (!name) {
@@ -1576,12 +1576,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkSourceProperty
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkSource
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkSource
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkSource
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1591,12 +1591,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkSource
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: copySink
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_copySink
+Java_edu_wpi_first_cscore_CameraServerJNI_copySink
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1606,12 +1606,12 @@ Java_edu_wpi_cscore_CameraServerJNI_copySink
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: releaseSink
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_releaseSink
+Java_edu_wpi_first_cscore_CameraServerJNI_releaseSink
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1620,12 +1620,12 @@ Java_edu_wpi_cscore_CameraServerJNI_releaseSink
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getMjpegServerListenAddress
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerListenAddress
+Java_edu_wpi_first_cscore_CameraServerJNI_getMjpegServerListenAddress
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1637,12 +1637,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerListenAddress
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getMjpegServerPort
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerPort
+Java_edu_wpi_first_cscore_CameraServerJNI_getMjpegServerPort
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1652,12 +1652,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerPort
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSinkDescription
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSinkDescription
+Java_edu_wpi_first_cscore_CameraServerJNI_setSinkDescription
(JNIEnv* env, jclass, jint sink, jstring description)
{
if (!description) {
@@ -1670,12 +1670,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSinkDescription
}
/*
- * Class: edu_wpi_cscore_CameraServerCvJNI
+ * Class: edu_wpi_first_cscore_CameraServerCvJNI
* Method: grabSinkFrame
* Signature: (IJ)J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrame
+Java_edu_wpi_first_cscore_CameraServerCvJNI_grabSinkFrame
(JNIEnv* env, jclass, jint sink, jlong imageNativeObj)
{
try {
@@ -1694,12 +1694,12 @@ Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrame
}
/*
- * Class: edu_wpi_cscore_CameraServerCvJNI
+ * Class: edu_wpi_first_cscore_CameraServerCvJNI
* Method: grabSinkFrameTimeout
* Signature: (IJD)J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrameTimeout
+Java_edu_wpi_first_cscore_CameraServerCvJNI_grabSinkFrameTimeout
(JNIEnv* env, jclass, jint sink, jlong imageNativeObj, jdouble timeout)
{
try {
@@ -1735,12 +1735,12 @@ static void SetRawFrameData(JNIEnv* env, jobject rawFrameObj,
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: grabRawSinkFrameImpl
* Signature: (ILjava/lang/Object;JLjava/lang/Object;III)J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_grabRawSinkFrameImpl
+Java_edu_wpi_first_cscore_CameraServerJNI_grabRawSinkFrameImpl
(JNIEnv* env, jclass, jint sink, jobject rawFrameObj, jlong rawFramePtr,
jobject byteBuffer, jint width, jint height, jint pixelFormat)
{
@@ -1760,12 +1760,12 @@ Java_edu_wpi_cscore_CameraServerJNI_grabRawSinkFrameImpl
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: grabRawSinkFrameTimeoutImpl
* Signature: (ILjava/lang/Object;JLjava/lang/Object;IIID)J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_grabRawSinkFrameTimeoutImpl
+Java_edu_wpi_first_cscore_CameraServerJNI_grabRawSinkFrameTimeoutImpl
(JNIEnv* env, jclass, jint sink, jobject rawFrameObj, jlong rawFramePtr,
jobject byteBuffer, jint width, jint height, jint pixelFormat,
jdouble timeout)
@@ -1787,12 +1787,12 @@ Java_edu_wpi_cscore_CameraServerJNI_grabRawSinkFrameTimeoutImpl
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getSinkError
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getSinkError
+Java_edu_wpi_first_cscore_CameraServerJNI_getSinkError
(JNIEnv* env, jclass, jint sink)
{
CS_Status status = 0;
@@ -1805,12 +1805,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getSinkError
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setSinkEnabled
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setSinkEnabled
+Java_edu_wpi_first_cscore_CameraServerJNI_setSinkEnabled
(JNIEnv* env, jclass, jint sink, jboolean enabled)
{
CS_Status status = 0;
@@ -1819,12 +1819,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setSinkEnabled
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: addListener
* Signature: (Ljava/lang/Object;IZ)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_addListener
+Java_edu_wpi_first_cscore_CameraServerJNI_addListener
(JNIEnv* envouter, jclass, jobject listener, jint eventMask,
jboolean immediateNotify)
{
@@ -1883,12 +1883,12 @@ Java_edu_wpi_cscore_CameraServerJNI_addListener
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: removeListener
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_removeListener
+Java_edu_wpi_first_cscore_CameraServerJNI_removeListener
(JNIEnv* env, jclass, jint handle)
{
CS_Status status = 0;
@@ -1897,36 +1897,36 @@ Java_edu_wpi_cscore_CameraServerJNI_removeListener
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: createListenerPoller
* Signature: ()I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_createListenerPoller
+Java_edu_wpi_first_cscore_CameraServerJNI_createListenerPoller
(JNIEnv*, jclass)
{
return cs::CreateListenerPoller();
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: destroyListenerPoller
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_destroyListenerPoller
+Java_edu_wpi_first_cscore_CameraServerJNI_destroyListenerPoller
(JNIEnv*, jclass, jint poller)
{
cs::DestroyListenerPoller(poller);
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: addPolledListener
* Signature: (IIZ)I
*/
JNIEXPORT jint JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_addPolledListener
+Java_edu_wpi_first_cscore_CameraServerJNI_addPolledListener
(JNIEnv* env, jclass, jint poller, jint eventMask, jboolean immediateNotify)
{
CS_Status status = 0;
@@ -1936,12 +1936,12 @@ Java_edu_wpi_cscore_CameraServerJNI_addPolledListener
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: pollListener
* Signature: (I)[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_pollListener
+Java_edu_wpi_first_cscore_CameraServerJNI_pollListener
(JNIEnv* env, jclass, jint poller)
{
auto events = cs::PollListener(poller);
@@ -1953,12 +1953,12 @@ Java_edu_wpi_cscore_CameraServerJNI_pollListener
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: pollListenerTimeout
* Signature: (ID)[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_pollListenerTimeout
+Java_edu_wpi_first_cscore_CameraServerJNI_pollListenerTimeout
(JNIEnv* env, jclass, jint poller, jdouble timeout)
{
bool timed_out = false;
@@ -1971,48 +1971,48 @@ Java_edu_wpi_cscore_CameraServerJNI_pollListenerTimeout
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: cancelPollListener
* Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_cancelPollListener
+Java_edu_wpi_first_cscore_CameraServerJNI_cancelPollListener
(JNIEnv*, jclass, jint poller)
{
cs::CancelPollListener(poller);
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setTelemetryPeriod
* Signature: (D)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setTelemetryPeriod
+Java_edu_wpi_first_cscore_CameraServerJNI_setTelemetryPeriod
(JNIEnv* env, jclass, jdouble seconds)
{
cs::SetTelemetryPeriod(seconds);
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getTelemetryElapsedTime
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getTelemetryElapsedTime
+Java_edu_wpi_first_cscore_CameraServerJNI_getTelemetryElapsedTime
(JNIEnv* env, jclass)
{
return cs::GetTelemetryElapsedTime();
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getTelemetryValue
* Signature: (II)J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getTelemetryValue
+Java_edu_wpi_first_cscore_CameraServerJNI_getTelemetryValue
(JNIEnv* env, jclass, jint handle, jint kind)
{
CS_Status status = 0;
@@ -2023,12 +2023,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getTelemetryValue
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getTelemetryAverageValue
* Signature: (II)D
*/
JNIEXPORT jdouble JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getTelemetryAverageValue
+Java_edu_wpi_first_cscore_CameraServerJNI_getTelemetryAverageValue
(JNIEnv* env, jclass, jint handle, jint kind)
{
CS_Status status = 0;
@@ -2039,12 +2039,12 @@ Java_edu_wpi_cscore_CameraServerJNI_getTelemetryAverageValue
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateUsbCameras
* Signature: ()[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateUsbCameras
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateUsbCameras
(JNIEnv* env, jclass)
{
CS_Status status = 0;
@@ -2065,12 +2065,12 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateUsbCameras
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateSources
* Signature: ()[I
*/
JNIEXPORT jintArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateSources
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateSources
(JNIEnv* env, jclass)
{
CS_Status status = 0;
@@ -2083,12 +2083,12 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateSources
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: enumerateSinks
* Signature: ()[I
*/
JNIEXPORT jintArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks
+Java_edu_wpi_first_cscore_CameraServerJNI_enumerateSinks
(JNIEnv* env, jclass)
{
CS_Status status = 0;
@@ -2101,24 +2101,24 @@ Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getHostname
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getHostname
+Java_edu_wpi_first_cscore_CameraServerJNI_getHostname
(JNIEnv* env, jclass)
{
return MakeJString(env, cs::GetHostname());
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: getNetworkInterfaces
* Signature: ()[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_getNetworkInterfaces
+Java_edu_wpi_first_cscore_CameraServerJNI_getNetworkInterfaces
(JNIEnv* env, jclass)
{
return MakeJStringArray(env, cs::GetNetworkInterfaces());
@@ -2158,12 +2158,12 @@ typedef JSingletonCallbackManager LoggerJNI;
extern "C" {
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: setLogger
* Signature: (Ljava/lang/Object;I)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_setLogger
+Java_edu_wpi_first_cscore_CameraServerJNI_setLogger
(JNIEnv* env, jclass, jobject func, jint minLevel)
{
if (!func) {
@@ -2196,12 +2196,12 @@ Java_edu_wpi_cscore_CameraServerJNI_setLogger
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: allocateRawFrame
* Signature: ()J
*/
JNIEXPORT jlong JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_allocateRawFrame
+Java_edu_wpi_first_cscore_CameraServerJNI_allocateRawFrame
(JNIEnv*, jclass)
{
cs::RawFrame* rawFrame = new cs::RawFrame{};
@@ -2210,12 +2210,12 @@ Java_edu_wpi_cscore_CameraServerJNI_allocateRawFrame
}
/*
- * Class: edu_wpi_cscore_CameraServerJNI
+ * Class: edu_wpi_first_cscore_CameraServerJNI
* Method: freeRawFrame
* Signature: (J)V
*/
JNIEXPORT void JNICALL
-Java_edu_wpi_cscore_CameraServerJNI_freeRawFrame
+Java_edu_wpi_first_cscore_CameraServerJNI_freeRawFrame
(JNIEnv*, jclass, jlong rawFrame)
{
cs::RawFrame* ptr =
diff --git a/cscore/src/main/native/windows/UsbCameraImpl.cpp b/cscore/src/main/native/windows/UsbCameraImpl.cpp
index 91944a34bd..10ce8d982a 100644
--- a/cscore/src/main/native/windows/UsbCameraImpl.cpp
+++ b/cscore/src/main/native/windows/UsbCameraImpl.cpp
@@ -293,32 +293,45 @@ void UsbCameraImpl::ProcessFrame(IMFSample* videoSample,
return;
}
- bool lock2d = false;
BYTE* ptr = NULL;
LONG pitch = 0;
- DWORD maxsize = 0, cursize = 0;
+ DWORD length = 0;
- // "For 2-D buffers, the Lock2D method is more efficient than the Lock
- // method" see IMFMediaBuffer::Lock method documentation:
- // https://msdn.microsoft.com/en-us/library/windows/desktop/bb970366(v=vs.85).aspx
- ComPtr buffer2d;
- DWORD memLength2d = 0;
- if (true) {
- buffer2d = buf.As();
- if (buffer2d) {
- buffer2d->GetContiguousLength(&memLength2d);
- if (SUCCEEDED(buffer2d->Lock2D(&ptr, &pitch))) {
- lock2d = true;
+ // First try to access using Lock2DSize, then try Lock2D, then fallback
+ // https://docs.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfmediabuffer-lock
+
+ ComPtr buffer2d = buf.As();
+ if (buffer2d) {
+ BYTE* scanline0 = nullptr;
+ HRESULT result;
+ ComPtr buffer2d2 = buf.As();
+ if (buffer2d2) {
+ BYTE* datastart;
+ result = buffer2d2->Lock2DSize(MF2DBuffer_LockFlags_Read, &scanline0,
+ &pitch, &datastart, &length);
+ } else {
+ result = buffer2d->Lock2D(&scanline0, &pitch);
+ }
+ if (SUCCEEDED(result)) {
+ BOOL isContiguous;
+ if (pitch > 0 && SUCCEEDED(buffer2d->IsContiguousFormat(&isContiguous)) &&
+ isContiguous &&
+ (length || SUCCEEDED(buffer2d->GetContiguousLength(&length)))) {
+ // Use the buffer pointer.
+ ptr = scanline0;
+ } else {
+ // Release the buffer and fall back to Lock().
+ buffer2d->Unlock2D();
}
}
}
if (ptr == NULL) {
- if (!SUCCEEDED(buf->Lock(&ptr, &maxsize, &cursize))) {
+ buffer2d = nullptr;
+ DWORD maxsize = 0;
+ if (!SUCCEEDED(buf->Lock(&ptr, &maxsize, &length))) {
return;
}
}
- if (!ptr)
- return;
cv::Mat tmpMat;
std::unique_ptr dest;
@@ -328,7 +341,7 @@ void UsbCameraImpl::ProcessFrame(IMFSample* videoSample,
case cs::VideoMode::PixelFormat::kMJPEG: {
// Special case
PutFrame(VideoMode::kMJPEG, mode.width, mode.height,
- wpi::StringRef(reinterpret_cast(ptr), cursize),
+ wpi::StringRef(reinterpret_cast(ptr), length),
wpi::Now());
doFinalSet = false;
break;
@@ -360,10 +373,11 @@ void UsbCameraImpl::ProcessFrame(IMFSample* videoSample,
PutFrame(std::move(dest), wpi::Now());
}
- if (lock2d)
+ if (buffer2d) {
buffer2d->Unlock2D();
- else
+ } else {
buf->Unlock();
+ }
}
LRESULT UsbCameraImpl::PumpMain(HWND hwnd, UINT uiMsg, WPARAM wParam,
diff --git a/cscore/src/test/java/edu/wpi/cscore/JNITest.java b/cscore/src/test/java/edu/wpi/first/cscore/JNITest.java
similarity index 92%
rename from cscore/src/test/java/edu/wpi/cscore/JNITest.java
rename to cscore/src/test/java/edu/wpi/first/cscore/JNITest.java
index 11f93f881f..40e2584a98 100644
--- a/cscore/src/test/java/edu/wpi/cscore/JNITest.java
+++ b/cscore/src/test/java/edu/wpi/first/cscore/JNITest.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import org.junit.jupiter.api.Test;
diff --git a/cscore/src/test/java/edu/wpi/cscore/UsbCameraTest.java b/cscore/src/test/java/edu/wpi/first/cscore/UsbCameraTest.java
similarity index 98%
rename from cscore/src/test/java/edu/wpi/cscore/UsbCameraTest.java
rename to cscore/src/test/java/edu/wpi/first/cscore/UsbCameraTest.java
index 13a68d00db..8a790fa788 100644
--- a/cscore/src/test/java/edu/wpi/cscore/UsbCameraTest.java
+++ b/cscore/src/test/java/edu/wpi/first/cscore/UsbCameraTest.java
@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
-package edu.wpi.cscore;
+package edu.wpi.first.cscore;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
diff --git a/glass/src/app/native/mac/glass.icns b/glass/src/app/native/mac/glass.icns
index 1204734761..74b6850595 100644
Binary files a/glass/src/app/native/mac/glass.icns and b/glass/src/app/native/mac/glass.icns differ
diff --git a/glass/src/libnt/native/cpp/NetworkTables.cpp b/glass/src/libnt/native/cpp/NetworkTables.cpp
index 7a1c6b7ed1..cea8be538f 100644
--- a/glass/src/libnt/native/cpp/NetworkTables.cpp
+++ b/glass/src/libnt/native/cpp/NetworkTables.cpp
@@ -741,30 +741,20 @@ void glass::DisplayNetworkTables(NetworkTablesModel* model,
ImGui::Columns();
}
-void NetworkTablesView::Display() {
- auto& storage = GetStorage();
- auto pTreeView =
- storage.GetBoolRef("tree", m_defaultFlags & NetworkTablesFlags_TreeView);
- auto pShowConnections = storage.GetBoolRef(
- "connections", m_defaultFlags & NetworkTablesFlags_ShowConnections);
- auto pShowFlags = storage.GetBoolRef(
- "flags", m_defaultFlags & NetworkTablesFlags_ShowFlags);
- auto pShowTimestamp = storage.GetBoolRef(
- "timestamp", m_defaultFlags & NetworkTablesFlags_ShowTimestamp);
- auto pCreateNoncanonicalKeys = storage.GetBoolRef(
- "createNonCanonical",
- m_defaultFlags & NetworkTablesFlags_CreateNoncanonicalKeys);
-
- if (ImGui::BeginPopupContextItem()) {
- ImGui::MenuItem("Tree View", "", pTreeView);
- ImGui::MenuItem("Show Connections", "", pShowConnections);
- ImGui::MenuItem("Show Flags", "", pShowFlags);
- ImGui::MenuItem("Show Timestamp", "", pShowTimestamp);
- ImGui::Separator();
- ImGui::MenuItem("Allow creation of non-canonical keys", "",
- pCreateNoncanonicalKeys);
-
- ImGui::EndPopup();
+void NetworkTablesFlagsSettings::Update() {
+ if (!m_pTreeView) {
+ auto& storage = GetStorage();
+ m_pTreeView = storage.GetBoolRef(
+ "tree", m_defaultFlags & NetworkTablesFlags_TreeView);
+ m_pShowConnections = storage.GetBoolRef(
+ "connections", m_defaultFlags & NetworkTablesFlags_ShowConnections);
+ m_pShowFlags = storage.GetBoolRef(
+ "flags", m_defaultFlags & NetworkTablesFlags_ShowFlags);
+ m_pShowTimestamp = storage.GetBoolRef(
+ "timestamp", m_defaultFlags & NetworkTablesFlags_ShowTimestamp);
+ m_pCreateNoncanonicalKeys = storage.GetBoolRef(
+ "createNonCanonical",
+ m_defaultFlags & NetworkTablesFlags_CreateNoncanonicalKeys);
}
m_flags &=
@@ -772,11 +762,32 @@ void NetworkTablesView::Display() {
NetworkTablesFlags_ShowFlags | NetworkTablesFlags_ShowTimestamp |
NetworkTablesFlags_CreateNoncanonicalKeys);
m_flags |=
- (*pTreeView ? NetworkTablesFlags_TreeView : 0) |
- (*pShowConnections ? NetworkTablesFlags_ShowConnections : 0) |
- (*pShowFlags ? NetworkTablesFlags_ShowFlags : 0) |
- (*pShowTimestamp ? NetworkTablesFlags_ShowTimestamp : 0) |
- (*pCreateNoncanonicalKeys ? NetworkTablesFlags_CreateNoncanonicalKeys
- : 0);
- DisplayNetworkTables(m_model, m_flags);
+ (*m_pTreeView ? NetworkTablesFlags_TreeView : 0) |
+ (*m_pShowConnections ? NetworkTablesFlags_ShowConnections : 0) |
+ (*m_pShowFlags ? NetworkTablesFlags_ShowFlags : 0) |
+ (*m_pShowTimestamp ? NetworkTablesFlags_ShowTimestamp : 0) |
+ (*m_pCreateNoncanonicalKeys ? NetworkTablesFlags_CreateNoncanonicalKeys
+ : 0);
+}
+
+void NetworkTablesFlagsSettings::DisplayMenu() {
+ if (!m_pTreeView) {
+ return;
+ }
+ ImGui::MenuItem("Tree View", "", m_pTreeView);
+ ImGui::MenuItem("Show Connections", "", m_pShowConnections);
+ ImGui::MenuItem("Show Flags", "", m_pShowFlags);
+ ImGui::MenuItem("Show Timestamp", "", m_pShowTimestamp);
+ ImGui::Separator();
+ ImGui::MenuItem("Allow creation of non-canonical keys", "",
+ m_pCreateNoncanonicalKeys);
+}
+
+void NetworkTablesView::Display() {
+ m_flags.Update();
+ if (ImGui::BeginPopupContextItem()) {
+ m_flags.DisplayMenu();
+ ImGui::EndPopup();
+ }
+ DisplayNetworkTables(m_model, m_flags.GetFlags());
}
diff --git a/glass/src/libnt/native/include/glass/networktables/NetworkTables.h b/glass/src/libnt/native/include/glass/networktables/NetworkTables.h
index f515764f42..e7dbbece83 100644
--- a/glass/src/libnt/native/include/glass/networktables/NetworkTables.h
+++ b/glass/src/libnt/native/include/glass/networktables/NetworkTables.h
@@ -104,19 +104,39 @@ void DisplayNetworkTables(
NetworkTablesModel* model,
NetworkTablesFlags flags = NetworkTablesFlags_Default);
+class NetworkTablesFlagsSettings {
+ public:
+ explicit NetworkTablesFlagsSettings(
+ NetworkTablesFlags defaultFlags = NetworkTablesFlags_Default)
+ : m_defaultFlags{defaultFlags}, m_flags{defaultFlags} {}
+
+ void Update();
+ void DisplayMenu();
+
+ NetworkTablesFlags GetFlags() const { return m_flags; }
+
+ private:
+ bool* m_pTreeView = nullptr;
+ bool* m_pShowConnections = nullptr;
+ bool* m_pShowFlags = nullptr;
+ bool* m_pShowTimestamp = nullptr;
+ bool* m_pCreateNoncanonicalKeys = nullptr;
+ NetworkTablesFlags m_defaultFlags; // NOLINT
+ NetworkTablesFlags m_flags; // NOLINT
+};
+
class NetworkTablesView : public View {
public:
explicit NetworkTablesView(
NetworkTablesModel* model,
NetworkTablesFlags defaultFlags = NetworkTablesFlags_Default)
- : m_model{model}, m_defaultFlags{defaultFlags}, m_flags{defaultFlags} {}
+ : m_model{model}, m_flags{defaultFlags} {}
void Display() override;
private:
NetworkTablesModel* m_model;
- NetworkTablesFlags m_defaultFlags;
- NetworkTablesFlags m_flags;
+ NetworkTablesFlagsSettings m_flags;
};
} // namespace glass
diff --git a/hal/src/main/java/edu/wpi/first/hal/HAL.java b/hal/src/main/java/edu/wpi/first/hal/HAL.java
index fb51ac02a4..6fd6910aab 100644
--- a/hal/src/main/java/edu/wpi/first/hal/HAL.java
+++ b/hal/src/main/java/edu/wpi/first/hal/HAL.java
@@ -28,7 +28,36 @@ public final class HAL extends JNIWrapper {
private static native void simPeriodicBeforeNative();
- public static final List s_simPeriodicBefore = new ArrayList<>();
+ private static final List s_simPeriodicBefore = new ArrayList<>();
+
+ public static class SimPeriodicBeforeCallback implements AutoCloseable {
+ private SimPeriodicBeforeCallback(Runnable r) {
+ m_run = r;
+ }
+
+ @Override
+ public void close() {
+ synchronized (s_simPeriodicBefore) {
+ s_simPeriodicBefore.remove(m_run);
+ }
+ }
+
+ private final Runnable m_run;
+ }
+
+ /**
+ * Registers a callback to be run by IterativeRobotBase prior to the user's simulationPeriodic
+ * code.
+ *
+ * @param r runnable
+ * @return Callback object (must be retained for callback to stay active).
+ */
+ public static SimPeriodicBeforeCallback registerSimPeriodicBeforeCallback(Runnable r) {
+ synchronized (s_simPeriodicBefore) {
+ s_simPeriodicBefore.add(r);
+ }
+ return new SimPeriodicBeforeCallback(r);
+ }
/**
* Runs SimPeriodicBefore callbacks. IterativeRobotBase calls this prior to the user's
@@ -45,7 +74,35 @@ public final class HAL extends JNIWrapper {
private static native void simPeriodicAfterNative();
- public static final List s_simPeriodicAfter = new ArrayList<>();
+ private static final List s_simPeriodicAfter = new ArrayList<>();
+
+ public static class SimPeriodicAfterCallback implements AutoCloseable {
+ private SimPeriodicAfterCallback(Runnable r) {
+ m_run = r;
+ }
+
+ @Override
+ public void close() {
+ synchronized (s_simPeriodicAfter) {
+ s_simPeriodicAfter.remove(m_run);
+ }
+ }
+
+ private final Runnable m_run;
+ }
+
+ /**
+ * Registers a callback to be run by IterativeRobotBase after the user's simulationPeriodic code.
+ *
+ * @param r runnable
+ * @return Callback object (must be retained for callback to stay active).
+ */
+ public static SimPeriodicAfterCallback registerSimPeriodicAfterCallback(Runnable r) {
+ synchronized (s_simPeriodicAfter) {
+ s_simPeriodicAfter.add(r);
+ }
+ return new SimPeriodicAfterCallback(r);
+ }
/**
* Runs SimPeriodicAfter callbacks. IterativeRobotBase calls this after the user's
diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/SimDeviceDataJNI.java b/hal/src/main/java/edu/wpi/first/hal/simulation/SimDeviceDataJNI.java
index 36d3388000..33c1bac477 100644
--- a/hal/src/main/java/edu/wpi/first/hal/simulation/SimDeviceDataJNI.java
+++ b/hal/src/main/java/edu/wpi/first/hal/simulation/SimDeviceDataJNI.java
@@ -47,17 +47,11 @@ public class SimDeviceDataJNI extends JNIWrapper {
public static native int registerSimValueCreatedCallback(
int device, SimValueCallback callback, boolean initialNotify);
- public static native int registerSimValueCreatedCallback2(
- int device, SimValueCallback2 callback, boolean initialNotify);
-
public static native void cancelSimValueCreatedCallback(int uid);
public static native int registerSimValueChangedCallback(
int handle, SimValueCallback callback, boolean initialNotify);
- public static native int registerSimValueChangedCallback2(
- int handle, SimValueCallback2 callback, boolean initialNotify);
-
public static native void cancelSimValueChangedCallback(int uid);
/**
@@ -69,7 +63,7 @@ public class SimDeviceDataJNI extends JNIWrapper {
* @param initialNotify ignored (present for consistency)
*/
public static native int registerSimValueResetCallback(
- int handle, SimValueCallback2 callback, boolean initialNotify);
+ int handle, SimValueCallback callback, boolean initialNotify);
public static native void cancelSimValueResetCallback(int uid);
diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback.java b/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback.java
index c586210459..4f9da942cc 100644
--- a/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback.java
+++ b/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback.java
@@ -8,10 +8,10 @@ import edu.wpi.first.hal.HALValue;
@FunctionalInterface
public interface SimValueCallback {
- void callback(String name, int handle, boolean readonly, HALValue value);
+ void callback(String name, int handle, int direction, HALValue value);
default void callbackNative(
- String name, int handle, boolean readonly, int type, long value1, double value2) {
- callback(name, handle, readonly, HALValue.fromNative(type, value1, value2));
+ String name, int handle, int direction, int type, long value1, double value2) {
+ callback(name, handle, direction, HALValue.fromNative(type, value1, value2));
}
}
diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback2.java b/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback2.java
deleted file mode 100644
index f575c7f42c..0000000000
--- a/hal/src/main/java/edu/wpi/first/hal/simulation/SimValueCallback2.java
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) FIRST and other WPILib contributors.
-// Open Source Software; you can modify and/or share it under the terms of
-// the WPILib BSD license file in the root directory of this project.
-
-package edu.wpi.first.hal.simulation;
-
-import edu.wpi.first.hal.HALValue;
-
-@FunctionalInterface
-public interface SimValueCallback2 {
- void callback(String name, int handle, int direction, HALValue value);
-
- default void callbackNative(
- String name, int handle, int direction, int type, long value1, double value2) {
- callback(name, handle, direction, HALValue.fromNative(type, value1, value2));
- }
-}
diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/SimulatorJNI.java b/hal/src/main/java/edu/wpi/first/hal/simulation/SimulatorJNI.java
index f3c61d7634..3dfeb068a9 100644
--- a/hal/src/main/java/edu/wpi/first/hal/simulation/SimulatorJNI.java
+++ b/hal/src/main/java/edu/wpi/first/hal/simulation/SimulatorJNI.java
@@ -4,7 +4,6 @@
package edu.wpi.first.hal.simulation;
-import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.JNIWrapper;
public class SimulatorJNI extends JNIWrapper {
@@ -29,48 +28,4 @@ public class SimulatorJNI extends JNIWrapper {
public static native void stepTimingAsync(long delta);
public static native void resetHandles();
-
- public static class SimPeriodicBeforeCallback implements AutoCloseable {
- private SimPeriodicBeforeCallback(Runnable r) {
- m_run = r;
- }
-
- @Override
- public void close() {
- synchronized (HAL.s_simPeriodicBefore) {
- HAL.s_simPeriodicBefore.remove(m_run);
- }
- }
-
- private Runnable m_run;
- }
-
- public static SimPeriodicBeforeCallback registerSimPeriodicBeforeCallback(Runnable r) {
- synchronized (HAL.s_simPeriodicBefore) {
- HAL.s_simPeriodicBefore.add(r);
- }
- return new SimPeriodicBeforeCallback(r);
- }
-
- public static class SimPeriodicAfterCallback implements AutoCloseable {
- private SimPeriodicAfterCallback(Runnable r) {
- m_run = r;
- }
-
- @Override
- public void close() {
- synchronized (HAL.s_simPeriodicAfter) {
- HAL.s_simPeriodicAfter.remove(m_run);
- }
- }
-
- private Runnable m_run;
- }
-
- public static SimPeriodicAfterCallback registerSimPeriodicAfterCallback(Runnable r) {
- synchronized (HAL.s_simPeriodicAfter) {
- HAL.s_simPeriodicAfter.add(r);
- }
- return new SimPeriodicAfterCallback(r);
- }
}
diff --git a/hal/src/main/native/athena/AddressableLED.cpp b/hal/src/main/native/athena/AddressableLED.cpp
index 39db71c039..864c08ce07 100644
--- a/hal/src/main/native/athena/AddressableLED.cpp
+++ b/hal/src/main/native/athena/AddressableLED.cpp
@@ -11,6 +11,7 @@
#include "ConstantsInternal.h"
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AddressableLEDTypes.h"
#include "hal/ChipObject.h"
@@ -142,8 +143,11 @@ void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
return;
}
- if (length > HAL_kAddressableLEDMaxLength) {
+ if (length > HAL_kAddressableLEDMaxLength || length < 0) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "LED length must be less than or equal to " +
+ wpi::Twine(HAL_kAddressableLEDMaxLength) +
+ ". " + wpi::Twine(length) + " was requested");
return;
}
@@ -173,8 +177,11 @@ void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
return;
}
- if (length > led->stringLength) {
+ if (length > led->stringLength || length < 0) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Data length must be less than or equal to " +
+ wpi::Twine(led->stringLength) + ". " +
+ wpi::Twine(length) + " was requested");
return;
}
diff --git a/hal/src/main/native/athena/AnalogGyro.cpp b/hal/src/main/native/athena/AnalogGyro.cpp
index b8f4add6e2..83bc42f0be 100644
--- a/hal/src/main/native/athena/AnalogGyro.cpp
+++ b/hal/src/main/native/athena/AnalogGyro.cpp
@@ -4,12 +4,14 @@
#include "hal/AnalogGyro.h"
+#include
#include
#include
#include "AnalogInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/AnalogInput.h"
#include "hal/handles/IndexedHandleResource.h"
@@ -21,6 +23,7 @@ struct AnalogGyro {
double voltsPerDegreePerSecond;
double offset;
int32_t center;
+ std::string previousAllocation;
};
} // namespace
@@ -55,36 +58,43 @@ static void Wait(double seconds) {
extern "C" {
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle analogHandle,
+ const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
+ // Handle will be type checked by HAL_IsAccumulatorChannel
+ int16_t channel = getHandleIndex(analogHandle);
if (!HAL_IsAccumulatorChannel(analogHandle, status)) {
if (*status == 0) {
*status = HAL_INVALID_ACCUMULATOR_CHANNEL;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Gyro",
+ 0, kNumAccumulators, channel);
}
return HAL_kInvalidHandle;
}
- // handle known to be correct, so no need to type check
- int16_t channel = getHandleIndex(analogHandle);
-
- auto handle = analogGyroHandles->Allocate(channel, status);
+ HAL_GyroHandle handle;
+ auto gyro = analogGyroHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (gyro) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Analog Gyro", channel,
+ gyro->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Gyro",
+ 0, kNumAccumulators, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
// Initialize port structure
- auto gyro = analogGyroHandles->Get(handle);
- if (gyro == nullptr) { // would only error on thread issue
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
gyro->handle = analogHandle;
gyro->voltsPerDegreePerSecond = 0;
gyro->offset = 0;
gyro->center = 0;
+ gyro->previousAllocation = allocationLocation ? allocationLocation : "";
+
return handle;
}
diff --git a/hal/src/main/native/athena/AnalogInput.cpp b/hal/src/main/native/athena/AnalogInput.cpp
index 4fd77a654d..6b3add10e9 100644
--- a/hal/src/main/native/athena/AnalogInput.cpp
+++ b/hal/src/main/native/athena/AnalogInput.cpp
@@ -9,6 +9,7 @@
#include "AnalogInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/handles/HandlesInternal.h"
@@ -21,8 +22,9 @@ using namespace hal;
extern "C" {
-HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle portHandle,
- int32_t* status) {
+HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
+ HAL_PortHandle portHandle, const char* allocationLocation,
+ int32_t* status) {
hal::init::CheckInit();
initializeAnalog(status);
@@ -31,23 +33,28 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle portHandle,
}
int16_t channel = getPortHandleChannel(portHandle);
- if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ if (channel == InvalidHandleIndex || channel >= kNumAnalogInputs) {
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
+ 0, kNumAnalogInputs, channel);
return HAL_kInvalidHandle;
}
- HAL_AnalogInputHandle handle = analogInputHandles->Allocate(channel, status);
+ HAL_AnalogInputHandle handle;
+ auto analog_port = analogInputHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (analog_port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Analog Input", channel,
+ analog_port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
+ 0, kNumAnalogInputs, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
// Initialize port structure
- auto analog_port = analogInputHandles->Get(handle);
- if (analog_port == nullptr) { // would only error on thread issue
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
analog_port->channel = static_cast(channel);
if (HAL_IsAccumulatorChannel(handle, status)) {
analog_port->accumulator.reset(tAccumulator::create(channel, status));
@@ -59,6 +66,8 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle portHandle,
analogInputSystem->writeScanList(channel, channel, status);
HAL_SetAnalogAverageBits(handle, kDefaultAverageBits, status);
HAL_SetAnalogOversampleBits(handle, kDefaultOversampleBits, status);
+ analog_port->previousAllocation =
+ allocationLocation ? allocationLocation : "";
return handle;
}
diff --git a/hal/src/main/native/athena/AnalogInternal.h b/hal/src/main/native/athena/AnalogInternal.h
index d3403648f0..431c6242b7 100644
--- a/hal/src/main/native/athena/AnalogInternal.h
+++ b/hal/src/main/native/athena/AnalogInternal.h
@@ -7,6 +7,7 @@
#include
#include
+#include
#include
@@ -31,6 +32,7 @@ extern bool analogSampleRateSet;
struct AnalogPort {
uint8_t channel;
std::unique_ptr accumulator;
+ std::string previousAllocation;
};
extern IndexedHandleResource
+
#include "AnalogInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/Errors.h"
#include "hal/handles/HandlesInternal.h"
@@ -17,6 +20,7 @@ namespace {
struct AnalogOutput {
uint8_t channel;
+ std::string previousAllocation;
};
} // namespace
@@ -36,8 +40,9 @@ void InitializeAnalogOutput() {
extern "C" {
-HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(HAL_PortHandle portHandle,
- int32_t* status) {
+HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
+ HAL_PortHandle portHandle, const char* allocationLocation,
+ int32_t* status) {
hal::init::CheckInit();
initializeAnalog(status);
@@ -46,25 +51,31 @@ HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(HAL_PortHandle portHandle,
}
int16_t channel = getPortHandleChannel(portHandle);
- if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ if (channel == InvalidHandleIndex || channel >= kNumAnalogOutputs) {
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Output",
+ 0, kNumAnalogOutputs, channel);
return HAL_kInvalidHandle;
}
- HAL_AnalogOutputHandle handle =
- analogOutputHandles->Allocate(channel, status);
+ HAL_AnalogOutputHandle handle;
+ auto port = analogOutputHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Analog Output", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status,
+ "Invalid Index for Analog Output", 0,
+ kNumAnalogOutputs, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = analogOutputHandles->Get(handle);
- if (port == nullptr) { // would only error on thread issue
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
port->channel = static_cast(channel);
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
+
return handle;
}
diff --git a/hal/src/main/native/athena/AnalogTrigger.cpp b/hal/src/main/native/athena/AnalogTrigger.cpp
index 7d438572e8..d9e2b9251c 100644
--- a/hal/src/main/native/athena/AnalogTrigger.cpp
+++ b/hal/src/main/native/athena/AnalogTrigger.cpp
@@ -7,6 +7,7 @@
#include "AnalogInternal.h"
#include "DutyCycleInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogInput.h"
#include "hal/DutyCycle.h"
@@ -138,6 +139,11 @@ void HAL_SetAnalogTriggerLimitsDutyCycle(
if (lower < 0.0 || upper > 1.0) {
*status = PARAMETER_OUT_OF_RANGE;
+ auto lowerStr = std::to_string(lower);
+ auto upperStr = std::to_string(upper);
+ hal::SetLastError(
+ status, "Lower must be >= 0 and upper must be <=1. Requested lower " +
+ lowerStr + " Requested upper " + upperStr);
return;
}
diff --git a/hal/src/main/native/athena/Counter.cpp b/hal/src/main/native/athena/Counter.cpp
index 2605279ed3..d6a278ce74 100644
--- a/hal/src/main/native/athena/Counter.cpp
+++ b/hal/src/main/native/athena/Counter.cpp
@@ -7,6 +7,7 @@
#include "ConstantsInternal.h"
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/HAL.h"
#include "hal/handles/LimitedHandleResource.h"
@@ -146,6 +147,9 @@ void HAL_SetCounterDownSource(HAL_CounterHandle counterHandle,
// TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "Counter only
// supports DownSource in TwoPulse and ExternalDirection modes.");
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status,
+ "Counter only supports DownSource in TwoPulse and "
+ "ExternalDirection mode.");
return;
}
@@ -260,6 +264,11 @@ void HAL_SetCounterSamplesToAverage(HAL_CounterHandle counterHandle,
}
if (samplesToAverage < 1 || samplesToAverage > 127) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(
+ status,
+ "Samples to average must be between 1 and 127 inclusive. Requested " +
+ wpi::Twine(samplesToAverage));
+ return;
}
counter->counter->writeTimerConfig_AverageSize(samplesToAverage, status);
}
diff --git a/hal/src/main/native/athena/DIO.cpp b/hal/src/main/native/athena/DIO.cpp
index 23c5ab331b..75909a0702 100644
--- a/hal/src/main/native/athena/DIO.cpp
+++ b/hal/src/main/native/athena/DIO.cpp
@@ -11,6 +11,7 @@
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/cpp/fpga_clock.h"
#include "hal/handles/HandlesInternal.h"
@@ -38,7 +39,9 @@ void InitializeDIO() {
extern "C" {
HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
- HAL_Bool input, int32_t* status) {
+ HAL_Bool input,
+ const char* allocationLocation,
+ int32_t* status) {
hal::init::CheckInit();
initializeDigital(status);
@@ -48,23 +51,28 @@ HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex || channel >= kNumDigitalChannels) {
- *status = PARAMETER_OUT_OF_RANGE;
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
+ kNumDigitalChannels, channel);
return HAL_kInvalidHandle;
}
- auto handle =
- digitalChannelHandles->Allocate(channel, HAL_HandleEnum::DIO, status);
+ HAL_DigitalHandle handle;
+
+ auto port = digitalChannelHandles->Allocate(channel, HAL_HandleEnum::DIO,
+ &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
+ kNumDigitalChannels, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = digitalChannelHandles->Get(handle, HAL_HandleEnum::DIO);
- if (port == nullptr) { // would only occur on thread issue.
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
port->channel = static_cast(channel);
std::scoped_lock lock(digitalDIOMutex);
@@ -114,6 +122,7 @@ HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
}
digitalSystem->writeOutputEnable(outputEnable, status);
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;
}
@@ -191,8 +200,8 @@ void HAL_SetDigitalPWMRate(double rate, int32_t* status) {
if (*status != 0) {
return;
}
- uint16_t pwmPeriodPower = static_cast(
- std::log(1.0 / (16 * 1.0E-6 * rate)) / std::log(2.0) + 0.5);
+ uint16_t pwmPeriodPower =
+ std::lround(std::log(1.0 / (16 * 1.0E-6 * rate)) / std::log(2.0));
digitalSystem->writePWMPeriodPower(pwmPeriodPower, status);
}
diff --git a/hal/src/main/native/athena/DMA.cpp b/hal/src/main/native/athena/DMA.cpp
index 31ca1c27bc..40eaca6f4b 100644
--- a/hal/src/main/native/athena/DMA.cpp
+++ b/hal/src/main/native/athena/DMA.cpp
@@ -13,6 +13,7 @@
#include "AnalogInternal.h"
#include "DigitalInternal.h"
#include "EncoderInternal.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/AnalogGyro.h"
@@ -528,6 +529,9 @@ void HAL_SetDMAExternalTrigger(HAL_DMAHandle handle,
if (!success) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status,
+ "Digital Source unabled to be mapped properly. Likely "
+ "invalid handle passed.");
return;
}
diff --git a/hal/src/main/native/athena/DigitalInternal.cpp b/hal/src/main/native/athena/DigitalInternal.cpp
index d47cedfb45..c75c66b3ba 100644
--- a/hal/src/main/native/athena/DigitalInternal.cpp
+++ b/hal/src/main/native/athena/DigitalInternal.cpp
@@ -5,6 +5,7 @@
#include "DigitalInternal.h"
#include
+#include
#include
#include
@@ -108,10 +109,10 @@ void initializeDigital(int32_t* status) {
double loopTime = pwmSystem->readLoopTiming(status) /
(kSystemClockTicksPerMicrosecond * 1e3);
- pwmSystem->writeConfig_Period(
- static_cast(kDefaultPwmPeriod / loopTime + 0.5), status);
- uint16_t minHigh = static_cast(
- (kDefaultPwmCenter - kDefaultPwmStepsDown * loopTime) / loopTime + 0.5);
+ pwmSystem->writeConfig_Period(std::lround(kDefaultPwmPeriod / loopTime),
+ status);
+ uint16_t minHigh = std::lround(
+ (kDefaultPwmCenter - kDefaultPwmStepsDown * loopTime) / loopTime);
pwmSystem->writeConfig_MinHigh(minHigh, status);
// Ensure that PWM output values are set to OFF
for (uint8_t pwmIndex = 0; pwmIndex < kNumPWMChannels; pwmIndex++) {
diff --git a/hal/src/main/native/athena/DigitalInternal.h b/hal/src/main/native/athena/DigitalInternal.h
index 79656ad5e2..6b1e9097b8 100644
--- a/hal/src/main/native/athena/DigitalInternal.h
+++ b/hal/src/main/native/athena/DigitalInternal.h
@@ -7,6 +7,7 @@
#include
#include
+#include
#include
@@ -70,6 +71,7 @@ struct DigitalPort {
int32_t centerPwm = 0;
int32_t deadbandMinPwm = 0;
int32_t minPwm = 0;
+ std::string previousAllocation;
};
extern DigitalHandleResource(encodingType)) +
+ " invalid.");
return;
}
}
@@ -181,6 +185,10 @@ void Encoder::SetReverseDirection(bool reverseDirection, int32_t* status) {
void Encoder::SetSamplesToAverage(int32_t samplesToAverage, int32_t* status) {
if (samplesToAverage < 1 || samplesToAverage > 127) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(
+ status,
+ "Samples to average must be between 1 and 127 inclusive. Requested " +
+ wpi::Twine(samplesToAverage));
return;
}
if (m_counter) {
diff --git a/hal/src/main/native/athena/FPGAEncoder.cpp b/hal/src/main/native/athena/FPGAEncoder.cpp
index 8709139924..3bfe9d9a41 100644
--- a/hal/src/main/native/athena/FPGAEncoder.cpp
+++ b/hal/src/main/native/athena/FPGAEncoder.cpp
@@ -8,6 +8,7 @@
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/handles/LimitedHandleResource.h"
@@ -193,6 +194,11 @@ void HAL_SetFPGAEncoderSamplesToAverage(HAL_FPGAEncoderHandle fpgaEncoderHandle,
}
if (samplesToAverage < 1 || samplesToAverage > 127) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(
+ status,
+ "Samples to average must be between 1 and 127 inclusive. Requested " +
+ wpi::Twine(samplesToAverage));
+ return;
}
encoder->encoder->writeTimerConfig_AverageSize(samplesToAverage, status);
}
diff --git a/hal/src/main/native/athena/HAL.cpp b/hal/src/main/native/athena/HAL.cpp
index fcee49897f..eefe34c9a2 100644
--- a/hal/src/main/native/athena/HAL.cpp
+++ b/hal/src/main/native/athena/HAL.cpp
@@ -233,6 +233,8 @@ const char* HAL_GetErrorMessage(int32_t code) {
return HAL_CAN_BUFFER_OVERRUN_MESSAGE;
case HAL_LED_CHANNEL_ERROR:
return HAL_LED_CHANNEL_ERROR_MESSAGE;
+ case HAL_USE_LAST_ERROR:
+ return HAL_USE_LAST_ERROR_MESSAGE;
default:
return "Unknown error status";
}
diff --git a/hal/src/main/native/athena/HALInternal.h b/hal/src/main/native/athena/HALInternal.h
index b9f284ff6a..b1a2d1dfd5 100644
--- a/hal/src/main/native/athena/HALInternal.h
+++ b/hal/src/main/native/athena/HALInternal.h
@@ -6,7 +6,15 @@
#include
+#include
+
namespace hal {
void ReleaseFPGAInterrupt(int32_t interruptNumber);
-
+void SetLastError(int32_t* status, const wpi::Twine& value);
+void SetLastErrorIndexOutOfRange(int32_t* status, const wpi::Twine& message,
+ int32_t minimum, int32_t maximum,
+ int32_t channel);
+void SetLastErrorPreviouslyAllocated(int32_t* status, const wpi::Twine& message,
+ int32_t channel,
+ const wpi::Twine& previousAllocation);
} // namespace hal
diff --git a/hal/src/main/native/athena/I2C.cpp b/hal/src/main/native/athena/I2C.cpp
index 17d6e9fbb3..9af13ed46f 100644
--- a/hal/src/main/native/athena/I2C.cpp
+++ b/hal/src/main/native/athena/I2C.cpp
@@ -67,11 +67,11 @@ void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
return;
}
if ((i2CMXPDigitalHandle1 = HAL_InitializeDIOPort(
- HAL_GetPort(24), false, status)) == HAL_kInvalidHandle) {
+ HAL_GetPort(24), false, nullptr, status)) == HAL_kInvalidHandle) {
return;
}
if ((i2CMXPDigitalHandle2 = HAL_InitializeDIOPort(
- HAL_GetPort(25), false, status)) == HAL_kInvalidHandle) {
+ HAL_GetPort(25), false, nullptr, status)) == HAL_kInvalidHandle) {
HAL_FreeDIOPort(i2CMXPDigitalHandle1); // free the first port allocated
return;
}
diff --git a/hal/src/main/native/athena/PDP.cpp b/hal/src/main/native/athena/PDP.cpp
index 7db4dd2db5..0cdf30f831 100644
--- a/hal/src/main/native/athena/PDP.cpp
+++ b/hal/src/main/native/athena/PDP.cpp
@@ -7,6 +7,7 @@
#include
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/CANAPI.h"
#include "hal/Errors.h"
@@ -117,6 +118,7 @@ HAL_PDPHandle HAL_InitializePDP(int32_t module, int32_t* status) {
hal::init::CheckInit();
if (!HAL_CheckPDPModule(module)) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid pdp module " + wpi::Twine(module));
return HAL_kInvalidHandle;
}
@@ -192,6 +194,7 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
int32_t* status) {
if (!HAL_CheckPDPChannel(channel)) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid pdp channel " + wpi::Twine(channel));
return 0;
}
diff --git a/hal/src/main/native/athena/PWM.cpp b/hal/src/main/native/athena/PWM.cpp
index 873d447ee4..bf9773a6a2 100644
--- a/hal/src/main/native/athena/PWM.cpp
+++ b/hal/src/main/native/athena/PWM.cpp
@@ -12,6 +12,7 @@
#include "ConstantsInternal.h"
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/cpp/fpga_clock.h"
#include "hal/handles/HandlesInternal.h"
@@ -65,6 +66,7 @@ void InitializePWM() {}
extern "C" {
HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
+ const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
initializeDigital(status);
@@ -75,7 +77,9 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex || channel >= kNumPWMChannels) {
- *status = PARAMETER_OUT_OF_RANGE;
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
+ kNumPWMChannels, channel);
return HAL_kInvalidHandle;
}
@@ -87,19 +91,22 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
channel = remapMXPPWMChannel(channel) + 10; // remap MXP to proper channel
}
- auto handle =
- digitalChannelHandles->Allocate(channel, HAL_HandleEnum::PWM, status);
+ HAL_DigitalHandle handle;
+
+ auto port = digitalChannelHandles->Allocate(channel, HAL_HandleEnum::PWM,
+ &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
+ kNumPWMChannels, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = digitalChannelHandles->Get(handle, HAL_HandleEnum::PWM);
- if (port == nullptr) { // would only occur on thread issue.
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
port->channel = origChannel;
if (port->channel > tPWM::kNumHdrRegisters - 1) {
@@ -113,6 +120,8 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
// Defaults to allow an always valid config.
HAL_SetPWMConfig(handle, 2.0, 1.501, 1.5, 1.499, 1.0, status);
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
+
return handle;
}
void HAL_FreePWMPort(HAL_DigitalHandle pwmPortHandle, int32_t* status) {
@@ -277,13 +286,13 @@ void HAL_SetPWMSpeed(HAL_DigitalHandle pwmPortHandle, double speed,
if (speed == 0.0) {
rawValue = GetCenterPwm(dPort);
} else if (speed > 0.0) {
- rawValue = static_cast(
- speed * static_cast(GetPositiveScaleFactor(dPort)) +
- static_cast(GetMinPositivePwm(dPort)) + 0.5);
+ rawValue =
+ std::lround(speed * static_cast(GetPositiveScaleFactor(dPort)) +
+ static_cast(GetMinPositivePwm(dPort)));
} else {
- rawValue = static_cast(
- speed * static_cast(GetNegativeScaleFactor(dPort)) +
- static_cast(GetMaxNegativePwm(dPort)) + 0.5);
+ rawValue =
+ std::lround(speed * static_cast(GetNegativeScaleFactor(dPort)) +
+ static_cast(GetMaxNegativePwm(dPort)));
}
if (!((rawValue >= GetMinNegativePwm(dPort)) &&
diff --git a/hal/src/main/native/athena/Relay.cpp b/hal/src/main/native/athena/Relay.cpp
index 368ce1b730..a01dd9d52b 100644
--- a/hal/src/main/native/athena/Relay.cpp
+++ b/hal/src/main/native/athena/Relay.cpp
@@ -4,8 +4,11 @@
#include "hal/Relay.h"
+#include
+
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/handles/IndexedHandleResource.h"
@@ -16,6 +19,7 @@ namespace {
struct Relay {
uint8_t channel;
bool fwd;
+ std::string previousAllocation;
};
} // namespace
@@ -38,6 +42,7 @@ void InitializeRelay() {
extern "C" {
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
+ const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
initializeDigital(status);
@@ -47,8 +52,10 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
}
int16_t channel = getPortHandleChannel(portHandle);
- if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ if (channel == InvalidHandleIndex || channel >= kNumRelayChannels) {
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Relay", 0,
+ kNumRelayChannels, channel);
return HAL_kInvalidHandle;
}
@@ -56,18 +63,20 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
channel += kNumRelayHeaders; // add 4 to reverse channels
}
- auto handle = relayHandles->Allocate(channel, status);
+ HAL_RelayHandle handle;
+ auto port = relayHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Relay", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Relay", 0,
+ kNumRelayChannels, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = relayHandles->Get(handle);
- if (port == nullptr) { // would only occur on thread issue.
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
if (!fwd) {
// Subtract number of headers to put channel in range
channel -= kNumRelayHeaders;
@@ -78,6 +87,7 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
}
port->channel = static_cast(channel);
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;
}
diff --git a/hal/src/main/native/athena/SPI.cpp b/hal/src/main/native/athena/SPI.cpp
index a237f668ea..090c53378e 100644
--- a/hal/src/main/native/athena/SPI.cpp
+++ b/hal/src/main/native/athena/SPI.cpp
@@ -18,6 +18,7 @@
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "hal/DIO.h"
#include "hal/HAL.h"
#include "hal/handles/HandlesInternal.h"
@@ -75,14 +76,14 @@ static void CommonSPIPortInit(int32_t* status) {
}
// MISO
if ((digitalHandles[3] = HAL_InitializeDIOPort(createPortHandleForSPI(29),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 29 (MISO)\n");
return;
}
// MOSI
if ((digitalHandles[4] = HAL_InitializeDIOPort(createPortHandleForSPI(30),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 30 (MOSI)\n");
HAL_FreeDIOPort(digitalHandles[3]); // free the first port allocated
@@ -103,6 +104,9 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
hal::init::CheckInit();
if (port < 0 || port >= kSpiMaxHandles) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Serial port must be between 0 and " +
+ wpi::Twine(kSpiMaxHandles) + ". Requested " +
+ wpi::Twine(static_cast(port)));
return;
}
@@ -133,7 +137,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
}
// CS1, Allocate
if ((digitalHandles[0] = HAL_InitializeDIOPort(createPortHandleForSPI(26),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 26 (CS1)\n");
CommonSPIPortFree();
@@ -156,7 +160,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
}
// CS2, Allocate
if ((digitalHandles[1] = HAL_InitializeDIOPort(createPortHandleForSPI(27),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 27 (CS2)\n");
CommonSPIPortFree();
@@ -179,7 +183,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
}
// CS3, Allocate
if ((digitalHandles[2] = HAL_InitializeDIOPort(createPortHandleForSPI(28),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
std::printf("Failed to allocate DIO 28 (CS3)\n");
CommonSPIPortFree();
@@ -201,20 +205,20 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
return;
}
if ((digitalHandles[5] = HAL_InitializeDIOPort(createPortHandleForSPI(14),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
wpi::outs() << "Failed to allocate DIO 14\n";
return;
}
if ((digitalHandles[6] = HAL_InitializeDIOPort(createPortHandleForSPI(15),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
wpi::outs() << "Failed to allocate DIO 15\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
return;
}
if ((digitalHandles[7] = HAL_InitializeDIOPort(createPortHandleForSPI(16),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
wpi::outs() << "Failed to allocate DIO 16\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
@@ -222,7 +226,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
return;
}
if ((digitalHandles[8] = HAL_InitializeDIOPort(createPortHandleForSPI(17),
- false, status)) ==
+ false, nullptr, status)) ==
HAL_kInvalidHandle) {
wpi::outs() << "Failed to allocate DIO 17\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
@@ -246,6 +250,8 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
break;
default:
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(
+ status, "Invalid SPI port " + wpi::Twine(static_cast(port)));
break;
}
}
@@ -374,6 +380,9 @@ void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status) {
if (port < 0 || port >= kSpiMaxHandles) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Serial port must be between 0 and " +
+ wpi::Twine(kSpiMaxHandles) + ". Requested " +
+ wpi::Twine(static_cast(port)));
return;
}
@@ -389,6 +398,9 @@ void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status) {
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status) {
if (port < 0 || port >= kSpiMaxHandles) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Serial port must be between 0 and " +
+ wpi::Twine(kSpiMaxHandles) + ". Requested " +
+ wpi::Twine(static_cast(port)));
return;
}
@@ -453,6 +465,9 @@ void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle) {
void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status) {
if (port < 0 || port >= kSpiMaxHandles) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Serial port must be between 0 and " +
+ wpi::Twine(kSpiMaxHandles) + ". Requested " +
+ wpi::Twine(static_cast(port)));
return;
}
@@ -484,6 +499,9 @@ void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status) {
void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t* status) {
if (port < 0 || port >= kSpiMaxHandles) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Serial port must be between 0 and " +
+ wpi::Twine(kSpiMaxHandles) + ". Requested " +
+ wpi::Twine(static_cast(port)));
return;
}
@@ -586,11 +604,17 @@ void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
int32_t* status) {
if (dataSize < 0 || dataSize > 32) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(
+ status, "Data size must be between 0 and 32 inclusive. Requested " +
+ wpi::Twine(dataSize));
return;
}
if (zeroSize < 0 || zeroSize > 127) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(
+ status, "Zero size must be between 0 and 127 inclusive. Requested " +
+ wpi::Twine(zeroSize));
return;
}
diff --git a/hal/src/main/native/athena/SerialPort.cpp b/hal/src/main/native/athena/SerialPort.cpp
index 27f17397ed..dfacbecc7c 100644
--- a/hal/src/main/native/athena/SerialPort.cpp
+++ b/hal/src/main/native/athena/SerialPort.cpp
@@ -19,6 +19,7 @@
#include
#include
+#include "HALInternal.h"
#include "hal/cpp/SerialHelper.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/IndexedHandleResource.h"
@@ -70,19 +71,14 @@ HAL_SerialPortHandle HAL_InitializeSerialPort(HAL_SerialPort port,
HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
const char* portName,
int32_t* status) {
- auto handle = serialPortHandles->Allocate(static_cast(port), status);
+ HAL_SerialPortHandle handle;
+ auto serialPort =
+ serialPortHandles->Allocate(static_cast(port), &handle, status);
if (*status != 0) {
return HAL_kInvalidHandle;
}
- auto serialPort = serialPortHandles->Get(handle);
-
- if (serialPort == nullptr) {
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
serialPort->portId = open(portName, O_RDWR | O_NOCTTY);
if (serialPort->portId < 0) {
*status = errno;
@@ -188,6 +184,7 @@ void HAL_SetSerialBaudRate(HAL_SerialPortHandle handle, int32_t baud,
BAUDCASE(4000000)
default:
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid BaudRate: " + wpi::Twine(baud));
return;
}
int err = cfsetospeed(&port->tty, static_cast(port->baudRate));
@@ -230,6 +227,7 @@ void HAL_SetSerialDataBits(HAL_SerialPortHandle handle, int32_t bits,
break;
default:
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid data bits: " + wpi::Twine(bits));
return;
}
@@ -277,6 +275,7 @@ void HAL_SetSerialParity(HAL_SerialPortHandle handle, int32_t parity,
break;
default:
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid parity bits: " + wpi::Twine(parity));
return;
}
@@ -304,6 +303,7 @@ void HAL_SetSerialStopBits(HAL_SerialPortHandle handle, int32_t stopBits,
break;
default:
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid stop bits: " + wpi::Twine(stopBits));
return;
}
@@ -339,6 +339,7 @@ void HAL_SetSerialFlowControl(HAL_SerialPortHandle handle, int32_t flow,
break;
default:
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid fc bits: " + wpi::Twine(flow));
return;
}
diff --git a/hal/src/main/native/athena/Solenoid.cpp b/hal/src/main/native/athena/Solenoid.cpp
index 669b87674f..b12d8bf1a7 100644
--- a/hal/src/main/native/athena/Solenoid.cpp
+++ b/hal/src/main/native/athena/Solenoid.cpp
@@ -60,16 +60,12 @@ HAL_SolenoidHandle HAL_InitializeSolenoidPort(HAL_PortHandle portHandle,
return HAL_kInvalidHandle;
}
- auto handle = solenoidHandles->Allocate(
- module * kNumSolenoidChannels + channel, status);
+ HAL_SolenoidHandle handle;
+ auto solenoidPort = solenoidHandles->Allocate(
+ module * kNumSolenoidChannels + channel, &handle, status);
if (*status != 0) {
return HAL_kInvalidHandle;
}
- auto solenoidPort = solenoidHandles->Get(handle);
- if (solenoidPort == nullptr) { // would only occur on thread issues
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
solenoidPort->module = static_cast(module);
solenoidPort->channel = static_cast(channel);
diff --git a/hal/src/main/native/cpp/ErrorHandling.cpp b/hal/src/main/native/cpp/ErrorHandling.cpp
new file mode 100644
index 0000000000..fa54e4676e
--- /dev/null
+++ b/hal/src/main/native/cpp/ErrorHandling.cpp
@@ -0,0 +1,61 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#include
+#include
+
+#include "hal/Errors.h"
+#include "hal/HALBase.h"
+
+namespace {
+struct LastErrorStorage {
+ int32_t status;
+ wpi::SmallString<512> message;
+};
+} // namespace
+
+static LastErrorStorage& GetThreadLastError() {
+ thread_local LastErrorStorage lastError;
+ return lastError;
+}
+
+namespace hal {
+void SetLastError(int32_t* status, const wpi::Twine& value) {
+ LastErrorStorage& lastError = GetThreadLastError();
+ lastError.message.clear();
+ value.toVector(lastError.message);
+ lastError.status = *status;
+ *status = HAL_USE_LAST_ERROR;
+}
+
+void SetLastErrorIndexOutOfRange(int32_t* status, const wpi::Twine& message,
+ int32_t minimum, int32_t maximum,
+ int32_t requested) {
+ SetLastError(status, message + "\n Status: " + wpi::Twine(*status) +
+ "\n Minimum: " + wpi::Twine(minimum) +
+ " Maximum: " + wpi::Twine(maximum) +
+ " Reequested: " + wpi::Twine(requested));
+}
+
+void SetLastErrorPreviouslyAllocated(int32_t* status, const wpi::Twine& message,
+ int32_t channel,
+ const wpi::Twine& previousAllocation) {
+ hal::SetLastError(
+ status,
+ message + " " + wpi::Twine(channel) +
+ " previously allocated.\nLocation of the previous allocation:\n" +
+ previousAllocation + "\nLocation of the current allocation:");
+}
+} // namespace hal
+
+extern "C" {
+const char* HAL_GetLastError(int32_t* status) {
+ if (*status == HAL_USE_LAST_ERROR) {
+ LastErrorStorage& lastError = GetThreadLastError();
+ *status = lastError.status;
+ return lastError.message.c_str();
+ }
+ return HAL_GetErrorMessage(*status);
+}
+} // extern "C"
diff --git a/hal/src/main/native/cpp/jni/AnalogGyroJNI.cpp b/hal/src/main/native/cpp/jni/AnalogGyroJNI.cpp
index 8a6b131837..154301f8e7 100644
--- a/hal/src/main/native/cpp/jni/AnalogGyroJNI.cpp
+++ b/hal/src/main/native/cpp/jni/AnalogGyroJNI.cpp
@@ -6,6 +6,8 @@
#include
+#include
+
#include "HALUtil.h"
#include "edu_wpi_first_hal_AnalogGyroJNI.h"
#include "hal/AnalogGyro.h"
@@ -24,8 +26,9 @@ Java_edu_wpi_first_hal_AnalogGyroJNI_initializeAnalogGyro
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
- HAL_GyroHandle handle =
- HAL_InitializeAnalogGyro((HAL_AnalogInputHandle)id, &status);
+ auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
+ HAL_GyroHandle handle = HAL_InitializeAnalogGyro((HAL_AnalogInputHandle)id,
+ stack.c_str(), &status);
// Analog input does range checking, so we don't need to do so.
CheckStatusForceThrow(env, status);
return (jint)handle;
diff --git a/hal/src/main/native/cpp/jni/AnalogJNI.cpp b/hal/src/main/native/cpp/jni/AnalogJNI.cpp
index 04ec3a405e..5f0abce6be 100644
--- a/hal/src/main/native/cpp/jni/AnalogJNI.cpp
+++ b/hal/src/main/native/cpp/jni/AnalogJNI.cpp
@@ -6,6 +6,8 @@
#include
+#include
+
#include "HALUtil.h"
#include "edu_wpi_first_hal_AnalogJNI.h"
#include "hal/AnalogAccumulator.h"
@@ -29,9 +31,10 @@ Java_edu_wpi_first_hal_AnalogJNI_initializeAnalogInputPort
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
- auto analog = HAL_InitializeAnalogInputPort((HAL_PortHandle)id, &status);
- CheckStatusRange(env, status, 0, HAL_GetNumAnalogInputs(),
- hal::getPortHandleChannel((HAL_PortHandle)id));
+ auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
+ auto analog =
+ HAL_InitializeAnalogInputPort((HAL_PortHandle)id, stack.c_str(), &status);
+ CheckStatusForceThrow(env, status);
return (jint)analog;
}
@@ -57,10 +60,10 @@ Java_edu_wpi_first_hal_AnalogJNI_initializeAnalogOutputPort
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
- HAL_AnalogOutputHandle analog =
- HAL_InitializeAnalogOutputPort((HAL_PortHandle)id, &status);
- CheckStatusRange(env, status, 0, HAL_GetNumAnalogOutputs(),
- hal::getPortHandleChannel((HAL_PortHandle)id));
+ auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
+ HAL_AnalogOutputHandle analog = HAL_InitializeAnalogOutputPort(
+ (HAL_PortHandle)id, stack.c_str(), &status);
+ CheckStatusForceThrow(env, status);
return (jlong)analog;
}
diff --git a/hal/src/main/native/cpp/jni/CounterJNI.cpp b/hal/src/main/native/cpp/jni/CounterJNI.cpp
index 07718a6cd5..0565d5b847 100644
--- a/hal/src/main/native/cpp/jni/CounterJNI.cpp
+++ b/hal/src/main/native/cpp/jni/CounterJNI.cpp
@@ -119,12 +119,6 @@ Java_edu_wpi_first_hal_CounterJNI_setCounterDownSource
HAL_SetCounterDownSource((HAL_CounterHandle)id,
(HAL_Handle)digitalSourceHandle,
(HAL_AnalogTriggerType)analogTriggerType, &status);
- if (status == PARAMETER_OUT_OF_RANGE) {
- ThrowIllegalArgumentException(env,
- "Counter only supports DownSource in "
- "TwoPulse and ExternalDirection modes.");
- return;
- }
CheckStatus(env, status);
}
@@ -240,10 +234,6 @@ Java_edu_wpi_first_hal_CounterJNI_setCounterSamplesToAverage
{
int32_t status = 0;
HAL_SetCounterSamplesToAverage((HAL_CounterHandle)id, value, &status);
- if (status == PARAMETER_OUT_OF_RANGE) {
- ThrowBoundaryException(env, value, 1, 127);
- return;
- }
CheckStatus(env, status);
}
diff --git a/hal/src/main/native/cpp/jni/DIOJNI.cpp b/hal/src/main/native/cpp/jni/DIOJNI.cpp
index 5dc59c8bda..236754169e 100644
--- a/hal/src/main/native/cpp/jni/DIOJNI.cpp
+++ b/hal/src/main/native/cpp/jni/DIOJNI.cpp
@@ -6,6 +6,8 @@
#include
+#include
+
#include "HALUtil.h"
#include "edu_wpi_first_hal_DIOJNI.h"
#include "hal/DIO.h"
@@ -27,10 +29,10 @@ Java_edu_wpi_first_hal_DIOJNI_initializeDIOPort
(JNIEnv* env, jclass, jint id, jboolean input)
{
int32_t status = 0;
- auto dio = HAL_InitializeDIOPort((HAL_PortHandle)id,
- static_cast(input), &status);
- CheckStatusRange(env, status, 0, HAL_GetNumDigitalChannels(),
- hal::getPortHandleChannel((HAL_PortHandle)id));
+ auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
+ auto dio = HAL_InitializeDIOPort(
+ (HAL_PortHandle)id, static_cast(input), stack.c_str(), &status);
+ CheckStatusForceThrow(env, status);
return (jint)dio;
}
diff --git a/hal/src/main/native/cpp/jni/EncoderJNI.cpp b/hal/src/main/native/cpp/jni/EncoderJNI.cpp
index 80673ab49e..f93e064ac4 100644
--- a/hal/src/main/native/cpp/jni/EncoderJNI.cpp
+++ b/hal/src/main/native/cpp/jni/EncoderJNI.cpp
@@ -267,10 +267,6 @@ Java_edu_wpi_first_hal_EncoderJNI_setEncoderSamplesToAverage
{
int32_t status = 0;
HAL_SetEncoderSamplesToAverage((HAL_EncoderHandle)id, value, &status);
- if (status == PARAMETER_OUT_OF_RANGE) {
- ThrowBoundaryException(env, value, 1, 127);
- return;
- }
CheckStatus(env, status);
}
diff --git a/hal/src/main/native/cpp/jni/HALUtil.cpp b/hal/src/main/native/cpp/jni/HALUtil.cpp
index fc37e9dd56..9894942f12 100644
--- a/hal/src/main/native/cpp/jni/HALUtil.cpp
+++ b/hal/src/main/native/cpp/jni/HALUtil.cpp
@@ -83,20 +83,18 @@ void ThrowUncleanStatusException(JNIEnv* env, wpi::StringRef msg,
env->Throw(static_cast(exception));
}
-void ThrowAllocationException(JNIEnv* env, int32_t minRange, int32_t maxRange,
- int32_t requestedValue, int32_t status) {
- const char* message = HAL_GetErrorMessage(status);
+void ThrowAllocationException(JNIEnv* env, const char* lastError,
+ int32_t status) {
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
- oss << " Code: " << status << ". " << message
- << ", Minimum Value: " << minRange << ", Maximum Value: " << maxRange
- << ", Requested Value: " << requestedValue;
- env->ThrowNew(allocationExCls, buf.c_str());
+
+ oss << "Code: " << status << '\n' << lastError;
+
allocationExCls.Throw(env, buf.c_str());
}
void ThrowHalHandleException(JNIEnv* env, int32_t status) {
- const char* message = HAL_GetErrorMessage(status);
+ const char* message = HAL_GetLastError(&status);
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
oss << " Code: " << status << ". " << message;
@@ -107,10 +105,11 @@ void ReportError(JNIEnv* env, int32_t status, bool doThrow) {
if (status == 0) {
return;
}
+ const char* message = HAL_GetLastError(&status);
if (status == HAL_HANDLE_ERROR) {
ThrowHalHandleException(env, status);
+ return;
}
- const char* message = HAL_GetErrorMessage(status);
if (doThrow && status < 0) {
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
@@ -119,7 +118,11 @@ void ReportError(JNIEnv* env, int32_t status, bool doThrow) {
} else {
std::string func;
auto stack = GetJavaStackTrace(env, &func, "edu.wpi.first");
- HAL_SendError(1, status, 0, message, func.c_str(), stack.c_str(), 1);
+ // Make a copy of message for safety, calling back into the HAL might
+ // invalidate the string.
+ wpi::SmallString<256> lastMessage{wpi::StringRef{message}};
+ HAL_SendError(1, status, 0, lastMessage.c_str(), func.c_str(),
+ stack.c_str(), 1);
}
}
@@ -128,17 +131,19 @@ void ThrowError(JNIEnv* env, int32_t status, int32_t minRange, int32_t maxRange,
if (status == 0) {
return;
}
+ const char* lastError = HAL_GetLastError(&status);
if (status == NO_AVAILABLE_RESOURCES || status == RESOURCE_IS_ALLOCATED ||
status == RESOURCE_OUT_OF_RANGE) {
- ThrowAllocationException(env, minRange, maxRange, requestedValue, status);
+ ThrowAllocationException(env, lastError, status);
+ return;
}
if (status == HAL_HANDLE_ERROR) {
ThrowHalHandleException(env, status);
+ return;
}
- const char* message = HAL_GetErrorMessage(status);
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
- oss << " Code: " << status << ". " << message;
+ oss << " Code: " << status << ". " << lastError;
ThrowUncleanStatusException(env, buf.c_str(), status);
}
diff --git a/hal/src/main/native/cpp/jni/PWMJNI.cpp b/hal/src/main/native/cpp/jni/PWMJNI.cpp
index 5099dba7d9..e83f11bcdf 100644
--- a/hal/src/main/native/cpp/jni/PWMJNI.cpp
+++ b/hal/src/main/native/cpp/jni/PWMJNI.cpp
@@ -6,6 +6,8 @@
#include
+#include
+
#include "HALUtil.h"
#include "edu_wpi_first_hal_PWMJNI.h"
#include "hal/DIO.h"
@@ -27,9 +29,9 @@ Java_edu_wpi_first_hal_PWMJNI_initializePWMPort
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
- auto pwm = HAL_InitializePWMPort((HAL_PortHandle)id, &status);
- CheckStatusRange(env, status, 0, HAL_GetNumPWMChannels(),
- hal::getPortHandleChannel((HAL_PortHandle)id));
+ auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
+ auto pwm = HAL_InitializePWMPort((HAL_PortHandle)id, stack.c_str(), &status);
+ CheckStatusForceThrow(env, status);
return (jint)pwm;
}
diff --git a/hal/src/main/native/cpp/jni/RelayJNI.cpp b/hal/src/main/native/cpp/jni/RelayJNI.cpp
index 0bb7fa45e8..9e31a9da10 100644
--- a/hal/src/main/native/cpp/jni/RelayJNI.cpp
+++ b/hal/src/main/native/cpp/jni/RelayJNI.cpp
@@ -6,6 +6,8 @@
#include
+#include
+
#include "HALUtil.h"
#include "edu_wpi_first_hal_RelayJNI.h"
#include "hal/Ports.h"
@@ -26,10 +28,10 @@ Java_edu_wpi_first_hal_RelayJNI_initializeRelayPort
(JNIEnv* env, jclass, jint id, jboolean fwd)
{
int32_t status = 0;
+ auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
HAL_RelayHandle handle = HAL_InitializeRelayPort(
- (HAL_PortHandle)id, static_cast(fwd), &status);
- CheckStatusRange(env, status, 0, HAL_GetNumRelayChannels(),
- hal::getPortHandleChannel((HAL_PortHandle)id));
+ (HAL_PortHandle)id, static_cast(fwd), stack.c_str(), &status);
+ CheckStatusForceThrow(env, status);
return (jint)handle;
}
diff --git a/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp
index 5f02ebcbc1..a07e8af15c 100644
--- a/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp
+++ b/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp
@@ -109,8 +109,6 @@ class DeviceCallbackStore {
class ValueCallbackStore {
public:
- explicit ValueCallbackStore(bool dirCallback) : m_dirCallback{dirCallback} {}
-
void create(JNIEnv* env, jobject obj) { m_call = JGlobal(env, obj); }
void performCallback(const char* name, HAL_SimValueHandle handle,
int32_t direction, const HAL_Value& value);
@@ -121,7 +119,6 @@ class ValueCallbackStore {
private:
wpi::java::JGlobal m_call;
int32_t m_callbackId;
- bool m_dirCallback;
};
} // namespace
@@ -181,17 +178,9 @@ void ValueCallbackStore::performCallback(const char* name,
}
auto [value1, value2] = ToValue12(value);
- if (m_dirCallback) {
- env->CallVoidMethod(m_call, simValueCallbackCallback,
- MakeJString(env, name), static_cast(handle),
- static_cast(direction),
- static_cast(value.type), value1, value2);
- } else {
- env->CallVoidMethod(m_call, simValueCallbackCallback,
- MakeJString(env, name), static_cast(handle),
- static_cast(direction == HAL_SimValueOutput),
- static_cast(value.type), value1, value2);
- }
+ env->CallVoidMethod(m_call, simValueCallbackCallback, MakeJString(env, name),
+ static_cast(handle), static_cast(direction),
+ static_cast(value.type), value1, value2);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
@@ -266,12 +255,11 @@ using FreeValueCallbackFunc = void (*)(int32_t uid);
template
static SIM_JniHandle AllocateValueCallback(
- JNIEnv* env, THandle h, jobject callback, bool dirCallback,
- jboolean initialNotify,
+ JNIEnv* env, THandle h, jobject callback, jboolean initialNotify,
int32_t (*createCallback)(THandle handle, void* param,
HALSIM_SimValueCallback callback,
HAL_Bool initialNotify)) {
- auto callbackStore = std::make_shared(dirCallback);
+ auto callbackStore = std::make_shared();
auto handle = valueCallbackHandles->Allocate(callbackStore);
@@ -345,7 +333,7 @@ bool InitializeSimDeviceDataJNI(JNIEnv* env) {
}
simValueCallbackCallback = env->GetMethodID(
- simValueCallbackCls, "callbackNative", "(Ljava/lang/String;IZIJD)V");
+ simValueCallbackCls, "callbackNative", "(Ljava/lang/String;IIIJD)V");
if (!simValueCallbackCallback) {
return false;
}
@@ -530,21 +518,7 @@ Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueCreatedCallba
(JNIEnv* env, jclass, jint device, jobject callback, jboolean initialNotify)
{
return AllocateValueCallback(env, static_cast(device),
- callback, false, initialNotify,
- &HALSIM_RegisterSimValueCreatedCallback);
-}
-
-/*
- * Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
- * Method: registerSimValueCreatedCallback2
- * Signature: (ILjava/lang/Object;Z)I
- */
-JNIEXPORT jint JNICALL
-Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueCreatedCallback2
- (JNIEnv* env, jclass, jint device, jobject callback, jboolean initialNotify)
-{
- return AllocateValueCallback(env, static_cast(device),
- callback, true, initialNotify,
+ callback, initialNotify,
&HALSIM_RegisterSimValueCreatedCallback);
}
@@ -570,21 +544,7 @@ Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueChangedCallba
(JNIEnv* env, jclass, jint handle, jobject callback, jboolean initialNotify)
{
return AllocateValueCallback(env, static_cast(handle),
- callback, false, initialNotify,
- &HALSIM_RegisterSimValueChangedCallback);
-}
-
-/*
- * Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
- * Method: registerSimValueChangedCallback2
- * Signature: (ILjava/lang/Object;Z)I
- */
-JNIEXPORT jint JNICALL
-Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueChangedCallback2
- (JNIEnv* env, jclass, jint handle, jobject callback, jboolean initialNotify)
-{
- return AllocateValueCallback(env, static_cast(handle),
- callback, true, initialNotify,
+ callback, initialNotify,
&HALSIM_RegisterSimValueChangedCallback);
}
@@ -610,7 +570,7 @@ Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueResetCallback
(JNIEnv* env, jclass, jint handle, jobject callback, jboolean initialNotify)
{
return AllocateValueCallback(env, static_cast(handle),
- callback, true, initialNotify,
+ callback, initialNotify,
&HALSIM_RegisterSimValueResetCallback);
}
diff --git a/hal/src/main/native/include/hal/AnalogGyro.h b/hal/src/main/native/include/hal/AnalogGyro.h
index 79e0f7d16e..16171b1384 100644
--- a/hal/src/main/native/include/hal/AnalogGyro.h
+++ b/hal/src/main/native/include/hal/AnalogGyro.h
@@ -22,9 +22,12 @@ extern "C" {
* Initializes an analog gyro.
*
* @param handle handle to the analog port
+ * @param allocationLocation the location where the allocation is occuring
+ * (can be null)
* @return the initialized gyro handle
*/
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle handle,
+ const char* allocationLocation,
int32_t* status);
/**
diff --git a/hal/src/main/native/include/hal/AnalogInput.h b/hal/src/main/native/include/hal/AnalogInput.h
index bcfc633000..8275ea26d1 100644
--- a/hal/src/main/native/include/hal/AnalogInput.h
+++ b/hal/src/main/native/include/hal/AnalogInput.h
@@ -22,10 +22,12 @@ extern "C" {
* Initializes the analog input port using the given port object.
*
* @param portHandle Handle to the port to initialize.
+ * @param allocationLocation the location where the allocation is occuring
+ * (can be null)
* @return the created analog input handle
*/
-HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle portHandle,
- int32_t* status);
+HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
+ HAL_PortHandle portHandle, const char* allocationLocation, int32_t* status);
/**
* Frees an analog input port.
diff --git a/hal/src/main/native/include/hal/AnalogOutput.h b/hal/src/main/native/include/hal/AnalogOutput.h
index b104315b39..ef013af95e 100644
--- a/hal/src/main/native/include/hal/AnalogOutput.h
+++ b/hal/src/main/native/include/hal/AnalogOutput.h
@@ -22,10 +22,12 @@ extern "C" {
* Initializes the analog output port using the given port object.
*
* @param handle handle to the port
+ * @param allocationLocation the location where the allocation is occuring
+ * (can be null)
* @return the created analog output handle
*/
-HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(HAL_PortHandle portHandle,
- int32_t* status);
+HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
+ HAL_PortHandle portHandle, const char* allocationLocation, int32_t* status);
/**
* Frees an analog output port.
diff --git a/hal/src/main/native/include/hal/DIO.h b/hal/src/main/native/include/hal/DIO.h
index cdfdd354bd..306321478e 100644
--- a/hal/src/main/native/include/hal/DIO.h
+++ b/hal/src/main/native/include/hal/DIO.h
@@ -21,12 +21,16 @@ extern "C" {
/**
* Creates a new instance of a digital port.
*
- * @param portHandle the port handle to create from
- * @param input true for input, false for output
- * @return the created digital handle
+ * @param portHandle the port handle to create from
+ * @param input true for input, false for output
+ * @param allocationLocation the location where the allocation is occuring
+ * (can be null)
+ * @return the created digital handle
*/
HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
- HAL_Bool input, int32_t* status);
+ HAL_Bool input,
+ const char* allocationLocation,
+ int32_t* status);
/**
* Checks if a DIO channel is valid.
diff --git a/hal/src/main/native/include/hal/Errors.h b/hal/src/main/native/include/hal/Errors.h
index b2e4b081b0..6444ea6c9e 100644
--- a/hal/src/main/native/include/hal/Errors.h
+++ b/hal/src/main/native/include/hal/Errors.h
@@ -41,6 +41,8 @@
#define ERR_FRCSystem_NoDSConnection_MESSAGE \
"FRCSystem: No driver station connected"
+#define HAL_SUCCESS 0
+
#define SAMPLE_RATE_TOO_HIGH 1001
#define SAMPLE_RATE_TOO_HIGH_MESSAGE \
"HAL: Analog module sample rate is too high"
@@ -125,6 +127,10 @@
#define HAL_SIM_NOT_SUPPORTED -1155
#define HAL_SIM_NOT_SUPPORTED_MESSAGE "HAL: Method not supported in sim"
+#define HAL_USE_LAST_ERROR -1156
+#define HAL_USE_LAST_ERROR_MESSAGE \
+ "HAL: Use HAL_GetLastError(status) to get last error"
+
#define HAL_CAN_BUFFER_OVERRUN -35007
#define HAL_CAN_BUFFER_OVERRUN_MESSAGE \
"HAL: CAN Output Buffer Full. Ensure a device is attached"
diff --git a/hal/src/main/native/include/hal/HALBase.h b/hal/src/main/native/include/hal/HALBase.h
index dbbf15d803..ce2a420711 100644
--- a/hal/src/main/native/include/hal/HALBase.h
+++ b/hal/src/main/native/include/hal/HALBase.h
@@ -22,6 +22,19 @@ HAL_ENUM(HAL_RuntimeType) { HAL_Athena, HAL_Mock };
extern "C" {
#endif
+/**
+ * Gets the last error set on this thread, or the message for the status code.
+ *
+ * If passed HAL_USE_LAST_ERROR, the last error set on the thread will be
+ * returned.
+ *
+ * @param code the status code, set to the error status code if input is
+ * HAL_USE_LAST_ERROR
+ * @return the error message for the code. This does not need to be freed,
+ * but can be overwritten by another hal call on the same thread.
+ */
+const char* HAL_GetLastError(int32_t* status);
+
/**
* Gets the error message for a specific status code.
*
diff --git a/hal/src/main/native/include/hal/PWM.h b/hal/src/main/native/include/hal/PWM.h
index e0fa945c44..04bfc4f73e 100644
--- a/hal/src/main/native/include/hal/PWM.h
+++ b/hal/src/main/native/include/hal/PWM.h
@@ -22,9 +22,12 @@ extern "C" {
* Initializes a PWM port.
*
* @param portHandle the port to initialize
+ * @param allocationLocation the location where the allocation is occuring
+ * (can be null)
* @return the created pwm handle
*/
HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
+ const char* allocationLocation,
int32_t* status);
/**
diff --git a/hal/src/main/native/include/hal/Relay.h b/hal/src/main/native/include/hal/Relay.h
index 5fa714ac9f..d59da0a669 100644
--- a/hal/src/main/native/include/hal/Relay.h
+++ b/hal/src/main/native/include/hal/Relay.h
@@ -26,9 +26,12 @@ extern "C" {
*
* @param portHandle the port handle to initialize
* @param fwd true for the forward port, false for the reverse port
+ * @param allocationLocation the location where the allocation is occuring
+ * (can be null)
* @return the created relay handle
*/
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
+ const char* allocationLocation,
int32_t* status);
/**
diff --git a/hal/src/main/native/include/hal/handles/DigitalHandleResource.h b/hal/src/main/native/include/hal/handles/DigitalHandleResource.h
index 85a14a7d62..5154a43aad 100644
--- a/hal/src/main/native/include/hal/handles/DigitalHandleResource.h
+++ b/hal/src/main/native/include/hal/handles/DigitalHandleResource.h
@@ -22,7 +22,7 @@ namespace hal {
* allows a limited number of handles that are allocated by index.
* The enum value is separate, as 2 enum values are allowed per handle
* Because they are allocated by index, each individual index holds its own
- * mutex, which reduces contention heavily.]
+ * mutex, which reduces contention heavily.
*
* @tparam THandle The Handle Type (Must be typedefed from HAL_Handle)
* @tparam TStruct The struct type held by this resource
@@ -38,7 +38,8 @@ class DigitalHandleResource : public HandleBase {
DigitalHandleResource(const DigitalHandleResource&) = delete;
DigitalHandleResource& operator=(const DigitalHandleResource&) = delete;
- THandle Allocate(int16_t index, HAL_HandleEnum enumValue, int32_t* status);
+ std::shared_ptr Allocate(int16_t index, HAL_HandleEnum enumValue,
+ THandle* handle, int32_t* status);
int16_t GetIndex(THandle handle, HAL_HandleEnum enumValue) {
return getHandleTypedIndex(handle, enumValue, m_version);
}
@@ -52,21 +53,27 @@ class DigitalHandleResource : public HandleBase {
};
template
-THandle DigitalHandleResource::Allocate(
- int16_t index, HAL_HandleEnum enumValue, int32_t* status) {
+std::shared_ptr
+DigitalHandleResource::Allocate(
+ int16_t index, HAL_HandleEnum enumValue, THandle* handle, int32_t* status) {
// don't acquire the lock if we can fail early.
if (index < 0 || index >= size) {
+ *handle = HAL_kInvalidHandle;
*status = RESOURCE_OUT_OF_RANGE;
- return HAL_kInvalidHandle;
+ return nullptr;
}
std::scoped_lock lock(m_handleMutexes[index]);
// check for allocation, otherwise allocate and return a valid handle
if (m_structures[index] != nullptr) {
+ *handle = HAL_kInvalidHandle;
*status = RESOURCE_IS_ALLOCATED;
- return HAL_kInvalidHandle;
+ return m_structures[index];
}
m_structures[index] = std::make_shared();
- return static_cast(hal::createHandle(index, enumValue, m_version));
+ *handle =
+ static_cast(hal::createHandle(index, enumValue, m_version));
+ *status = HAL_SUCCESS;
+ return m_structures[index];
}
template
diff --git a/hal/src/main/native/include/hal/handles/IndexedHandleResource.h b/hal/src/main/native/include/hal/handles/IndexedHandleResource.h
index 2f158e1913..2e921eebcf 100644
--- a/hal/src/main/native/include/hal/handles/IndexedHandleResource.h
+++ b/hal/src/main/native/include/hal/handles/IndexedHandleResource.h
@@ -39,7 +39,8 @@ class IndexedHandleResource : public HandleBase {
IndexedHandleResource(const IndexedHandleResource&) = delete;
IndexedHandleResource& operator=(const IndexedHandleResource&) = delete;
- THandle Allocate(int16_t index, int32_t* status);
+ std::shared_ptr Allocate(int16_t index, THandle* handle,
+ int32_t* status);
int16_t GetIndex(THandle handle) {
return getHandleTypedIndex(handle, enumValue, m_version);
}
@@ -54,21 +55,27 @@ class IndexedHandleResource : public HandleBase {
template
-THandle IndexedHandleResource::Allocate(
- int16_t index, int32_t* status) {
+std::shared_ptr
+IndexedHandleResource::Allocate(
+ int16_t index, THandle* handle, int32_t* status) {
// don't acquire the lock if we can fail early.
if (index < 0 || index >= size) {
*status = RESOURCE_OUT_OF_RANGE;
- return HAL_kInvalidHandle;
+ *handle = HAL_kInvalidHandle;
+ return nullptr;
}
std::scoped_lock lock(m_handleMutexes[index]);
// check for allocation, otherwise allocate and return a valid handle
if (m_structures[index] != nullptr) {
*status = RESOURCE_IS_ALLOCATED;
- return HAL_kInvalidHandle;
+ *handle = HAL_kInvalidHandle;
+ return m_structures[index];
}
m_structures[index] = std::make_shared();
- return static_cast(hal::createHandle(index, enumValue, m_version));
+ *handle =
+ static_cast(hal::createHandle(index, enumValue, m_version));
+ *status = HAL_SUCCESS;
+ return m_structures[index];
}
template HAL_kAddressableLEDMaxLength) {
+ if (length > HAL_kAddressableLEDMaxLength || length < 0) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "LED length must be less than or equal to " +
+ wpi::Twine(HAL_kAddressableLEDMaxLength) +
+ ". " + wpi::Twine(length) + " was requested");
return;
}
SimAddressableLEDData[led->index].length = length;
@@ -127,6 +131,10 @@ void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
}
if (length > SimAddressableLEDData[led->index].length) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status,
+ "Data length must be less than or equal to " +
+ wpi::Twine(SimAddressableLEDData[led->index].length) +
+ ". " + wpi::Twine(length) + " was requested");
return;
}
SimAddressableLEDData[led->index].SetData(data, length);
diff --git a/hal/src/main/native/sim/AnalogGyro.cpp b/hal/src/main/native/sim/AnalogGyro.cpp
index 3324333e9b..3efca200e7 100644
--- a/hal/src/main/native/sim/AnalogGyro.cpp
+++ b/hal/src/main/native/sim/AnalogGyro.cpp
@@ -4,7 +4,10 @@
#include "hal/AnalogGyro.h"
+#include
+
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/Errors.h"
@@ -15,6 +18,7 @@ namespace {
struct AnalogGyro {
HAL_AnalogInputHandle handle;
uint8_t index;
+ std::string previousAllocation;
};
} // namespace
@@ -34,36 +38,41 @@ void InitializeAnalogGyro() {
extern "C" {
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle analogHandle,
+ const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
+ // Handle will be type checked by HAL_IsAccumulatorChannel
+ int16_t channel = getHandleIndex(analogHandle);
if (!HAL_IsAccumulatorChannel(analogHandle, status)) {
if (*status == 0) {
*status = HAL_INVALID_ACCUMULATOR_CHANNEL;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Gyro",
+ 0, kNumAccumulators, channel);
}
return HAL_kInvalidHandle;
}
- // handle known to be correct, so no need to type check
- int16_t channel = getHandleIndex(analogHandle);
-
- auto handle = analogGyroHandles->Allocate(channel, status);
+ HAL_GyroHandle handle;
+ auto gyro = analogGyroHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (gyro) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Analog Gyro", channel,
+ gyro->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Gyro",
+ 0, kNumAccumulators, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- // Initialize port structure
- auto gyro = analogGyroHandles->Get(handle);
- if (gyro == nullptr) { // would only error on thread issue
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
gyro->handle = analogHandle;
gyro->index = channel;
SimAnalogGyroData[channel].initialized = true;
+ gyro->previousAllocation = allocationLocation ? allocationLocation : "";
+
return handle;
}
diff --git a/hal/src/main/native/sim/AnalogInput.cpp b/hal/src/main/native/sim/AnalogInput.cpp
index 3a9f572f05..4697dc2493 100644
--- a/hal/src/main/native/sim/AnalogInput.cpp
+++ b/hal/src/main/native/sim/AnalogInput.cpp
@@ -6,6 +6,7 @@
#include "AnalogInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/handles/HandlesInternal.h"
@@ -18,28 +19,32 @@ void InitializeAnalogInput() {}
} // namespace hal::init
extern "C" {
-HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle portHandle,
- int32_t* status) {
+HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
+ HAL_PortHandle portHandle, const char* allocationLocation,
+ int32_t* status) {
hal::init::CheckInit();
int16_t channel = getPortHandleChannel(portHandle);
- if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ if (channel == InvalidHandleIndex || channel >= kNumAnalogInputs) {
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
+ 0, kNumAnalogInputs, channel);
return HAL_kInvalidHandle;
}
- HAL_AnalogInputHandle handle = analogInputHandles->Allocate(channel, status);
+ HAL_AnalogInputHandle handle;
+ auto analog_port = analogInputHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (analog_port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Analog Input", channel,
+ analog_port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
+ 0, kNumAnalogInputs, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- // Initialize port structure
- auto analog_port = analogInputHandles->Get(handle);
- if (analog_port == nullptr) { // would only error on thread issue
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
analog_port->channel = static_cast(channel);
if (HAL_IsAccumulatorChannel(handle, status)) {
analog_port->isAccumulator = true;
@@ -51,6 +56,9 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle portHandle,
SimAnalogInData[channel].accumulatorInitialized = false;
SimAnalogInData[channel].simDevice = 0;
+ analog_port->previousAllocation =
+ allocationLocation ? allocationLocation : "";
+
return handle;
}
void HAL_FreeAnalogInputPort(HAL_AnalogInputHandle analogPortHandle) {
diff --git a/hal/src/main/native/sim/AnalogInternal.h b/hal/src/main/native/sim/AnalogInternal.h
index 835fddd8f1..89cb3593c3 100644
--- a/hal/src/main/native/sim/AnalogInternal.h
+++ b/hal/src/main/native/sim/AnalogInternal.h
@@ -6,6 +6,8 @@
#include
+#include
+
#include "PortsInternal.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/IndexedHandleResource.h"
@@ -20,6 +22,7 @@ static constexpr uint32_t kAccumulatorChannels[] = {0, 1};
struct AnalogPort {
uint8_t channel;
bool isAccumulator;
+ std::string previousAllocation;
};
extern IndexedHandleResource
+
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/Errors.h"
#include "hal/handles/HandlesInternal.h"
@@ -16,6 +19,7 @@ using namespace hal;
namespace {
struct AnalogOutput {
uint8_t channel;
+ std::string previousAllocation;
};
} // namespace
@@ -33,32 +37,39 @@ void InitializeAnalogOutput() {
} // namespace hal::init
extern "C" {
-HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(HAL_PortHandle portHandle,
- int32_t* status) {
+HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
+ HAL_PortHandle portHandle, const char* allocationLocation,
+ int32_t* status) {
hal::init::CheckInit();
int16_t channel = getPortHandleChannel(portHandle);
- if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ if (channel == InvalidHandleIndex || channel >= kNumAnalogOutputs) {
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Output",
+ 0, kNumAnalogOutputs, channel);
return HAL_kInvalidHandle;
}
- HAL_AnalogOutputHandle handle =
- analogOutputHandles->Allocate(channel, status);
+ HAL_AnalogOutputHandle handle;
+ auto port = analogOutputHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Analog Output", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status,
+ "Invalid Index for Analog Output", 0,
+ kNumAnalogOutputs, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = analogOutputHandles->Get(handle);
- if (port == nullptr) { // would only error on thread issue
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
port->channel = static_cast(channel);
// Initialize sim analog input
SimAnalogOutData[channel].initialized = true;
+
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;
}
diff --git a/hal/src/main/native/sim/DIO.cpp b/hal/src/main/native/sim/DIO.cpp
index 4cb3d38810..0b85cd83dc 100644
--- a/hal/src/main/native/sim/DIO.cpp
+++ b/hal/src/main/native/sim/DIO.cpp
@@ -6,6 +6,7 @@
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/LimitedHandleResource.h"
@@ -31,36 +32,41 @@ void InitializeDIO() {
extern "C" {
HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
- HAL_Bool input, int32_t* status) {
+ HAL_Bool input,
+ const char* allocationLocation,
+ int32_t* status) {
hal::init::CheckInit();
- if (*status != 0) {
- return HAL_kInvalidHandle;
- }
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
+ kNumDigitalChannels, channel);
return HAL_kInvalidHandle;
}
- auto handle =
- digitalChannelHandles->Allocate(channel, HAL_HandleEnum::DIO, status);
+ HAL_DigitalHandle handle;
+
+ auto port = digitalChannelHandles->Allocate(channel, HAL_HandleEnum::DIO,
+ &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
+ kNumDigitalChannels, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = digitalChannelHandles->Get(handle, HAL_HandleEnum::DIO);
- if (port == nullptr) { // would only occur on thread issue.
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
port->channel = static_cast(channel);
SimDIOData[channel].initialized = true;
SimDIOData[channel].isInput = input;
SimDIOData[channel].simDevice = 0;
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;
}
diff --git a/hal/src/main/native/sim/DigitalInternal.h b/hal/src/main/native/sim/DigitalInternal.h
index 080eb6fbe8..cd1ac5fcb5 100644
--- a/hal/src/main/native/sim/DigitalInternal.h
+++ b/hal/src/main/native/sim/DigitalInternal.h
@@ -6,6 +6,8 @@
#include
+#include
+
#include "PortsInternal.h"
#include "hal/AnalogTrigger.h"
#include "hal/handles/DigitalHandleResource.h"
@@ -56,6 +58,7 @@ struct DigitalPort {
int32_t centerPwm = 0;
int32_t deadbandMinPwm = 0;
int32_t minPwm = 0;
+ std::string previousAllocation;
};
extern DigitalHandleResourcedistancePerPulse = distancePerPulse;
diff --git a/hal/src/main/native/sim/HAL.cpp b/hal/src/main/native/sim/HAL.cpp
index 97ad1b9bba..09409bc1fb 100644
--- a/hal/src/main/native/sim/HAL.cpp
+++ b/hal/src/main/native/sim/HAL.cpp
@@ -250,6 +250,8 @@ const char* HAL_GetErrorMessage(int32_t code) {
return HAL_CAN_BUFFER_OVERRUN_MESSAGE;
case HAL_LED_CHANNEL_ERROR:
return HAL_LED_CHANNEL_ERROR_MESSAGE;
+ case HAL_USE_LAST_ERROR:
+ return HAL_USE_LAST_ERROR_MESSAGE;
default:
return "Unknown error status";
}
diff --git a/hal/src/main/native/sim/HALInternal.h b/hal/src/main/native/sim/HALInternal.h
new file mode 100644
index 0000000000..28dcdc293a
--- /dev/null
+++ b/hal/src/main/native/sim/HALInternal.h
@@ -0,0 +1,19 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#pragma once
+
+#include
+
+#include
+
+namespace hal {
+void SetLastError(int32_t* status, const wpi::Twine& value);
+void SetLastErrorIndexOutOfRange(int32_t* status, const wpi::Twine& message,
+ int32_t minimum, int32_t maximum,
+ int32_t channel);
+void SetLastErrorPreviouslyAllocated(int32_t* status, const wpi::Twine& message,
+ int32_t channel,
+ const wpi::Twine& previousAllocation);
+} // namespace hal
diff --git a/hal/src/main/native/sim/PDP.cpp b/hal/src/main/native/sim/PDP.cpp
index 36fb50e45d..aa08ca0dfa 100644
--- a/hal/src/main/native/sim/PDP.cpp
+++ b/hal/src/main/native/sim/PDP.cpp
@@ -6,6 +6,7 @@
#include "CANAPIInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/CANAPI.h"
#include "hal/Errors.h"
@@ -27,6 +28,7 @@ extern "C" {
HAL_PDPHandle HAL_InitializePDP(int32_t module, int32_t* status) {
if (!HAL_CheckPDPModule(module)) {
*status = PARAMETER_OUT_OF_RANGE;
+ hal::SetLastError(status, "Invalid pdp module " + wpi::Twine(module));
return HAL_kInvalidHandle;
}
hal::init::CheckInit();
diff --git a/hal/src/main/native/sim/PWM.cpp b/hal/src/main/native/sim/PWM.cpp
index 06105e9981..698769fede 100644
--- a/hal/src/main/native/sim/PWM.cpp
+++ b/hal/src/main/native/sim/PWM.cpp
@@ -7,6 +7,7 @@
#include "ConstantsInternal.h"
#include "DigitalInternal.h"
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/handles/HandlesInternal.h"
#include "mockdata/PWMDataInternal.h"
@@ -20,15 +21,15 @@ void InitializePWM() {}
extern "C" {
HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
+ const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
- if (*status != 0) {
- return HAL_kInvalidHandle;
- }
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
+ kNumPWMChannels, channel);
return HAL_kInvalidHandle;
}
@@ -40,19 +41,22 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
channel = remapMXPPWMChannel(channel) + 10; // remap MXP to proper channel
}
- auto handle =
- digitalChannelHandles->Allocate(channel, HAL_HandleEnum::PWM, status);
+ HAL_DigitalHandle handle;
+
+ auto port = digitalChannelHandles->Allocate(channel, HAL_HandleEnum::PWM,
+ &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
+ kNumPWMChannels, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = digitalChannelHandles->Get(handle, HAL_HandleEnum::PWM);
- if (port == nullptr) { // would only occur on thread issue.
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
port->channel = origChannel;
SimPWMData[origChannel].initialized = true;
@@ -60,6 +64,8 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
// Defaults to allow an always valid config.
HAL_SetPWMConfig(handle, 2.0, 1.501, 1.5, 1.499, 1.0, status);
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
+
return handle;
}
void HAL_FreePWMPort(HAL_DigitalHandle pwmPortHandle, int32_t* status) {
diff --git a/hal/src/main/native/sim/Relay.cpp b/hal/src/main/native/sim/Relay.cpp
index 7ba0438d50..4dfcdaf2a4 100644
--- a/hal/src/main/native/sim/Relay.cpp
+++ b/hal/src/main/native/sim/Relay.cpp
@@ -4,7 +4,10 @@
#include "hal/Relay.h"
+#include
+
#include "HALInitializer.h"
+#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/handles/IndexedHandleResource.h"
#include "mockdata/RelayDataInternal.h"
@@ -15,6 +18,7 @@ namespace {
struct Relay {
uint8_t channel;
bool fwd;
+ std::string previousAllocation;
};
} // namespace
@@ -32,6 +36,7 @@ void InitializeRelay() {
extern "C" {
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
+ const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
if (*status != 0) {
@@ -39,8 +44,10 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
}
int16_t channel = getPortHandleChannel(portHandle);
- if (channel == InvalidHandleIndex) {
- *status = PARAMETER_OUT_OF_RANGE;
+ if (channel == InvalidHandleIndex || channel >= kNumRelayChannels) {
+ *status = RESOURCE_OUT_OF_RANGE;
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Relay", 0,
+ kNumRelayChannels, channel);
return HAL_kInvalidHandle;
}
@@ -48,18 +55,20 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
channel += kNumRelayHeaders; // add 4 to reverse channels
}
- auto handle = relayHandles->Allocate(channel, status);
+ HAL_RelayHandle handle;
+ auto port = relayHandles->Allocate(channel, &handle, status);
if (*status != 0) {
+ if (port) {
+ hal::SetLastErrorPreviouslyAllocated(status, "Relay", channel,
+ port->previousAllocation);
+ } else {
+ hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Relay", 0,
+ kNumRelayChannels, channel);
+ }
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
- auto port = relayHandles->Get(handle);
- if (port == nullptr) { // would only occur on thread issue.
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
-
if (!fwd) {
// Subtract number of headers to put channel in range
channel -= kNumRelayHeaders;
@@ -73,6 +82,7 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
}
port->channel = static_cast(channel);
+ port->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;
}
diff --git a/hal/src/main/native/sim/Solenoid.cpp b/hal/src/main/native/sim/Solenoid.cpp
index 81be01a351..e59b393562 100644
--- a/hal/src/main/native/sim/Solenoid.cpp
+++ b/hal/src/main/native/sim/Solenoid.cpp
@@ -55,17 +55,13 @@ HAL_SolenoidHandle HAL_InitializeSolenoidPort(HAL_PortHandle portHandle,
return HAL_kInvalidHandle;
}
- auto handle = solenoidHandles->Allocate(
- module * kNumSolenoidChannels + channel, status);
+ HAL_SolenoidHandle handle;
+ auto solenoidPort = solenoidHandles->Allocate(
+ module * kNumSolenoidChannels + channel, &handle, status);
if (handle == HAL_kInvalidHandle) { // out of resources
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
}
- auto solenoidPort = solenoidHandles->Get(handle);
- if (solenoidPort == nullptr) { // would only occur on thread issues
- *status = HAL_HANDLE_ERROR;
- return HAL_kInvalidHandle;
- }
solenoidPort->module = static_cast(module);
solenoidPort->channel = static_cast(channel);
diff --git a/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp b/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp
index d9fbe01389..c657ebe36d 100644
--- a/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp
+++ b/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp
@@ -36,16 +36,18 @@ TEST(AnalogInSimTests, TestAnalogInInitialization) {
status = 0;
portHandle = 8000;
gTestAnalogInCallbackName = "Unset";
- analogInHandle = HAL_InitializeAnalogInputPort(portHandle, &status);
+ analogInHandle = HAL_InitializeAnalogInputPort(portHandle, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, analogInHandle);
- EXPECT_EQ(PARAMETER_OUT_OF_RANGE, status);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
+ EXPECT_EQ(RESOURCE_OUT_OF_RANGE, status);
EXPECT_STREQ("Unset", gTestAnalogInCallbackName.c_str());
// Successful setup
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestAnalogInCallbackName = "Unset";
- analogInHandle = HAL_InitializeAnalogInputPort(portHandle, &status);
+ analogInHandle = HAL_InitializeAnalogInputPort(portHandle, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != analogInHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestAnalogInCallbackName.c_str());
@@ -54,8 +56,10 @@ TEST(AnalogInSimTests, TestAnalogInInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestAnalogInCallbackName = "Unset";
- analogInHandle = HAL_InitializeAnalogInputPort(portHandle, &status);
+ analogInHandle = HAL_InitializeAnalogInputPort(portHandle, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, analogInHandle);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
EXPECT_EQ(RESOURCE_IS_ALLOCATED, status);
EXPECT_STREQ("Unset", gTestAnalogInCallbackName.c_str());
@@ -69,7 +73,7 @@ TEST(AnalogInSimTests, TestAnalogInInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestAnalogInCallbackName = "Unset";
- analogInHandle = HAL_InitializeAnalogInputPort(portHandle, &status);
+ analogInHandle = HAL_InitializeAnalogInputPort(portHandle, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != analogInHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestAnalogInCallbackName.c_str());
diff --git a/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp b/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp
index 16e1d9d957..1ec14f4f19 100644
--- a/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp
+++ b/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp
@@ -36,16 +36,20 @@ TEST(AnalogOutSimTests, TestAnalogOutInitialization) {
status = 0;
portHandle = 8000;
gTestAnalogOutCallbackName = "Unset";
- analogOutHandle = HAL_InitializeAnalogOutputPort(portHandle, &status);
+ analogOutHandle =
+ HAL_InitializeAnalogOutputPort(portHandle, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, analogOutHandle);
- EXPECT_EQ(PARAMETER_OUT_OF_RANGE, status);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
+ EXPECT_EQ(RESOURCE_OUT_OF_RANGE, status);
EXPECT_STREQ("Unset", gTestAnalogOutCallbackName.c_str());
// Successful setup
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestAnalogOutCallbackName = "Unset";
- analogOutHandle = HAL_InitializeAnalogOutputPort(portHandle, &status);
+ analogOutHandle =
+ HAL_InitializeAnalogOutputPort(portHandle, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != analogOutHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestAnalogOutCallbackName.c_str());
@@ -54,8 +58,11 @@ TEST(AnalogOutSimTests, TestAnalogOutInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestAnalogOutCallbackName = "Unset";
- analogOutHandle = HAL_InitializeAnalogOutputPort(portHandle, &status);
+ analogOutHandle =
+ HAL_InitializeAnalogOutputPort(portHandle, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, analogOutHandle);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
EXPECT_EQ(RESOURCE_IS_ALLOCATED, status);
EXPECT_STREQ("Unset", gTestAnalogOutCallbackName.c_str());
@@ -69,7 +76,8 @@ TEST(AnalogOutSimTests, TestAnalogOutInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestAnalogOutCallbackName = "Unset";
- analogOutHandle = HAL_InitializeAnalogOutputPort(portHandle, &status);
+ analogOutHandle =
+ HAL_InitializeAnalogOutputPort(portHandle, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != analogOutHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestAnalogOutCallbackName.c_str());
diff --git a/hal/src/test/native/cpp/mockdata/DIODataTests.cpp b/hal/src/test/native/cpp/mockdata/DIODataTests.cpp
index d584b45ec0..bc1345b091 100644
--- a/hal/src/test/native/cpp/mockdata/DIODataTests.cpp
+++ b/hal/src/test/native/cpp/mockdata/DIODataTests.cpp
@@ -36,16 +36,18 @@ TEST(DigitalIoSimTests, TestDigitalIoInitialization) {
status = 0;
portHandle = 8000;
gTestDigitalIoCallbackName = "Unset";
- digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, &status);
+ digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, digitalIoHandle);
- EXPECT_EQ(PARAMETER_OUT_OF_RANGE, status);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
+ EXPECT_EQ(RESOURCE_OUT_OF_RANGE, status);
EXPECT_STREQ("Unset", gTestDigitalIoCallbackName.c_str());
// Successful setup
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestDigitalIoCallbackName = "Unset";
- digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, &status);
+ digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != digitalIoHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestDigitalIoCallbackName.c_str());
@@ -54,8 +56,10 @@ TEST(DigitalIoSimTests, TestDigitalIoInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestDigitalIoCallbackName = "Unset";
- digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, &status);
+ digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, digitalIoHandle);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
EXPECT_EQ(RESOURCE_IS_ALLOCATED, status);
EXPECT_STREQ("Unset", gTestDigitalIoCallbackName.c_str());
@@ -69,7 +73,7 @@ TEST(DigitalIoSimTests, TestDigitalIoInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestDigitalIoCallbackName = "Unset";
- digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, &status);
+ digitalIoHandle = HAL_InitializeDIOPort(portHandle, true, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != digitalIoHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestDigitalIoCallbackName.c_str());
diff --git a/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp b/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp
index fb717971ac..c0bb7f0b31 100644
--- a/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp
+++ b/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp
@@ -35,16 +35,18 @@ TEST(PWMSimTests, TestPwmInitialization) {
status = 0;
portHandle = 8000;
gTestPwmCallbackName = "Unset";
- pwmHandle = HAL_InitializePWMPort(portHandle, &status);
+ pwmHandle = HAL_InitializePWMPort(portHandle, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, pwmHandle);
- EXPECT_EQ(PARAMETER_OUT_OF_RANGE, status);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
+ EXPECT_EQ(RESOURCE_OUT_OF_RANGE, status);
EXPECT_STREQ("Unset", gTestPwmCallbackName.c_str());
// Successful setup
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestPwmCallbackName = "Unset";
- pwmHandle = HAL_InitializePWMPort(portHandle, &status);
+ pwmHandle = HAL_InitializePWMPort(portHandle, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != pwmHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestPwmCallbackName.c_str());
@@ -53,8 +55,10 @@ TEST(PWMSimTests, TestPwmInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestPwmCallbackName = "Unset";
- pwmHandle = HAL_InitializePWMPort(portHandle, &status);
+ pwmHandle = HAL_InitializePWMPort(portHandle, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, pwmHandle);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
EXPECT_EQ(RESOURCE_IS_ALLOCATED, status);
EXPECT_STREQ("Unset", gTestPwmCallbackName.c_str());
@@ -67,7 +71,7 @@ TEST(PWMSimTests, TestPwmInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestPwmCallbackName = "Unset";
- pwmHandle = HAL_InitializePWMPort(portHandle, &status);
+ pwmHandle = HAL_InitializePWMPort(portHandle, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != pwmHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("Initialized", gTestPwmCallbackName.c_str());
diff --git a/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp b/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp
index 6e5004667d..af85318006 100644
--- a/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp
+++ b/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp
@@ -35,16 +35,18 @@ TEST(RelaySimTests, TestRelayInitialization) {
status = 0;
portHandle = 8000;
gTestRelayCallbackName = "Unset";
- pdpHandle = HAL_InitializeRelayPort(portHandle, true, &status);
+ pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, pdpHandle);
- EXPECT_EQ(PARAMETER_OUT_OF_RANGE, status);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
+ EXPECT_EQ(RESOURCE_OUT_OF_RANGE, status);
EXPECT_STREQ("Unset", gTestRelayCallbackName.c_str());
// Successful setup
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestRelayCallbackName = "Unset";
- pdpHandle = HAL_InitializeRelayPort(portHandle, true, &status);
+ pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != pdpHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("InitializedForward", gTestRelayCallbackName.c_str());
@@ -53,8 +55,10 @@ TEST(RelaySimTests, TestRelayInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestRelayCallbackName = "Unset";
- pdpHandle = HAL_InitializeRelayPort(portHandle, true, &status);
+ pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status);
EXPECT_EQ(HAL_kInvalidHandle, pdpHandle);
+ EXPECT_EQ(HAL_USE_LAST_ERROR, status);
+ HAL_GetLastError(&status);
EXPECT_EQ(RESOURCE_IS_ALLOCATED, status);
EXPECT_STREQ("Unset", gTestRelayCallbackName.c_str());
@@ -67,7 +71,7 @@ TEST(RelaySimTests, TestRelayInitialization) {
status = 0;
portHandle = HAL_GetPort(INDEX_TO_TEST);
gTestRelayCallbackName = "Unset";
- pdpHandle = HAL_InitializeRelayPort(portHandle, true, &status);
+ pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status);
EXPECT_TRUE(HAL_kInvalidHandle != pdpHandle);
EXPECT_EQ(0, status);
EXPECT_STREQ("InitializedForward", gTestRelayCallbackName.c_str());
diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java
deleted file mode 100644
index e5affb2958..0000000000
--- a/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java
+++ /dev/null
@@ -1,1108 +0,0 @@
-// Copyright (c) FIRST and other WPILib contributors.
-// Open Source Software; you can modify and/or share it under the terms of
-// the WPILib BSD license file in the root directory of this project.
-
-package edu.wpi.first.wpilibj.networktables;
-
-import edu.wpi.first.networktables.ConnectionInfo;
-import edu.wpi.first.networktables.ConnectionNotification;
-import edu.wpi.first.networktables.EntryInfo;
-import edu.wpi.first.networktables.EntryNotification;
-import edu.wpi.first.networktables.NetworkTableEntry;
-import edu.wpi.first.networktables.NetworkTableInstance;
-import edu.wpi.first.networktables.NetworkTableType;
-import edu.wpi.first.networktables.NetworkTableValue;
-import edu.wpi.first.networktables.NetworkTablesJNI;
-import edu.wpi.first.networktables.PersistentException;
-import edu.wpi.first.wpilibj.tables.IRemote;
-import edu.wpi.first.wpilibj.tables.IRemoteConnectionListener;
-import edu.wpi.first.wpilibj.tables.ITable;
-import edu.wpi.first.wpilibj.tables.ITableListener;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.function.Consumer;
-
-/**
- * A network table that knows its subtable path.
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable} instead.
- */
-@Deprecated
-@SuppressWarnings("checkstyle:all")
-public class NetworkTable implements ITable, IRemote {
- /** The path separator for sub-tables and keys */
- public static final char PATH_SEPARATOR = '/';
- /** The default port that network tables operates on */
- public static final int DEFAULT_PORT = 1735;
-
- private static boolean client = false;
- private static boolean enableDS = true;
- private static boolean running = false;
- private static int port = DEFAULT_PORT;
- private static String persistentFilename = "networktables.ini";
-
- private static synchronized void checkInit() {
- if (running) throw new IllegalStateException("Network tables has already been initialized");
- }
-
- /**
- * initializes network tables
- *
- * @deprecated Use {@link NetworkTableInstance#startServer()} or {@link
- * NetworkTableInstance#startClient()} instead.
- */
- @Deprecated
- public static synchronized void initialize() {
- if (running) shutdown();
- NetworkTableInstance inst = NetworkTableInstance.getDefault();
- if (client) {
- inst.startClient();
- if (enableDS) inst.startDSClient(port);
- } else inst.startServer(persistentFilename, "", port);
- running = true;
- }
-
- /**
- * shuts down network tables
- *
- * @deprecated Use {@link NetworkTableInstance#stopServer()} or {@link
- * NetworkTableInstance#stopClient()} instead.
- */
- @Deprecated
- public static synchronized void shutdown() {
- if (!running) return;
- NetworkTableInstance inst = NetworkTableInstance.getDefault();
- if (client) {
- inst.stopDSClient();
- inst.stopClient();
- } else inst.stopServer();
- running = false;
- }
-
- /**
- * set that network tables should be a server This must be called before initialize or getTable
- *
- * @deprecated Use {@link NetworkTableInstance#startServer()} instead.
- */
- @Deprecated
- public static synchronized void setServerMode() {
- if (!client) return;
- checkInit();
- client = false;
- }
-
- /**
- * set that network tables should be a client This must be called before initialize or getTable
- *
- * @deprecated Use {@link NetworkTableInstance#startClient()} instead.
- */
- @Deprecated
- public static synchronized void setClientMode() {
- if (client) return;
- checkInit();
- client = true;
- }
-
- /**
- * set the team the robot is configured for (this will set the mdns address that network tables
- * will connect to in client mode) This must be called before initialize or getTable
- *
- * @param team the team number
- * @deprecated Use {@link NetworkTableInstance#setServerTeam(int)} or {@link
- * NetworkTableInstance#startClientTeam(int)} instead.
- */
- @Deprecated
- public static synchronized void setTeam(int team) {
- NetworkTableInstance inst = NetworkTableInstance.getDefault();
- inst.setServerTeam(team, port);
- if (enableDS) inst.startDSClient(port);
- }
-
- /**
- * @param address the address that network tables will connect to in client mode
- * @deprecated Use {@link NetworkTableInstance#setServer(String)} or {@link
- * NetworkTableInstance#startClient(String)} instead.
- */
- @Deprecated
- public static synchronized void setIPAddress(final String address) {
- String[] addresses = new String[1];
- addresses[0] = address;
- setIPAddress(addresses);
- }
-
- /**
- * @param addresses the adresses that network tables will connect to in client mode (in round
- * robin order)
- * @deprecated Use {@link NetworkTableInstance#setServer(String[])} or {@link
- * NetworkTableInstance#startClient(String[])} instead.
- */
- @Deprecated
- public static synchronized void setIPAddress(final String[] addresses) {
- NetworkTableInstance inst = NetworkTableInstance.getDefault();
- inst.setServer(addresses, port);
-
- // Stop the DS client if we're explicitly connecting to localhost
- if (addresses.length > 0
- && (addresses[0].equals("localhost") || addresses[0].equals("127.0.0.1")))
- inst.stopDSClient();
- else if (enableDS) inst.startDSClient(port);
- }
-
- /**
- * Set the port number that network tables will connect to in client mode or listen to in server
- * mode.
- *
- * @param aport the port number
- * @deprecated Use the appropriate parameters to {@link NetworkTableInstance#setServer(String,
- * int)}, {@link NetworkTableInstance#startClient(String, int)}, {@link
- * NetworkTableInstance#startServer(String, String, int)}, and {@link
- * NetworkTableInstance#startDSClient(int)} instead.
- */
- @Deprecated
- public static synchronized void setPort(int aport) {
- if (port == aport) return;
- checkInit();
- port = aport;
- }
-
- /**
- * Enable requesting the server address from the Driver Station.
- *
- * @param enabled whether to enable the connection to the local DS
- * @deprecated Use {@link NetworkTableInstance#startDSClient()} and {@link
- * NetworkTableInstance#stopDSClient()} instead.
- */
- @Deprecated
- public static synchronized void setDSClientEnabled(boolean enabled) {
- NetworkTableInstance inst = NetworkTableInstance.getDefault();
- enableDS = enabled;
- if (enableDS) inst.startDSClient(port);
- else inst.stopDSClient();
- }
-
- /**
- * Sets the persistent filename.
- *
- * @param filename the filename that the network tables server uses for automatic loading and
- * saving of persistent values
- * @deprecated Use the appropriate parameter to {@link NetworkTableInstance#startServer()}
- * instead.
- */
- @Deprecated
- public static synchronized void setPersistentFilename(final String filename) {
- if (persistentFilename.equals(filename)) return;
- checkInit();
- persistentFilename = filename;
- }
-
- /**
- * Sets the network identity. This is provided in the connection info on the remote end.
- *
- * @param name identity
- * @deprecated Use {@link NetworkTableInstance#setNetworkIdentity(String)} instead.
- */
- @Deprecated
- public static void setNetworkIdentity(String name) {
- NetworkTableInstance.getDefault().setNetworkIdentity(name);
- }
-
- public static boolean[] toNative(Boolean[] arr) {
- boolean[] out = new boolean[arr.length];
- for (int i = 0; i < arr.length; i++) out[i] = arr[i];
- return out;
- }
-
- public static double[] toNative(Number[] arr) {
- double[] out = new double[arr.length];
- for (int i = 0; i < arr.length; i++) out[i] = arr[i].doubleValue();
- return out;
- }
-
- public static Boolean[] fromNative(boolean[] arr) {
- Boolean[] out = new Boolean[arr.length];
- for (int i = 0; i < arr.length; i++) out[i] = arr[i];
- return out;
- }
-
- public static Double[] fromNative(double[] arr) {
- Double[] out = new Double[arr.length];
- for (int i = 0; i < arr.length; i++) out[i] = arr[i];
- return out;
- }
-
- /**
- * Gets the table with the specified key. If the table does not exist, a new table will be
- * created.
- * This will automatically initialize network tables if it has not been already
- *
- * @deprecated Use {@link NetworkTableInstance#getTable(String)} instead.
- * @param key the key name
- * @return the network table requested
- */
- @Deprecated
- public static synchronized NetworkTable getTable(String key) {
- if (!running) initialize();
- String theKey;
- if (key.isEmpty() || key.equals("/")) {
- theKey = "";
- } else if (key.charAt(0) == NetworkTable.PATH_SEPARATOR) {
- theKey = key;
- } else {
- theKey = NetworkTable.PATH_SEPARATOR + key;
- }
- return new NetworkTable(NetworkTableInstance.getDefault(), theKey);
- }
-
- private final String path;
- private final String pathWithSep;
- private final NetworkTableInstance inst;
-
- NetworkTable(NetworkTableInstance inst, String path) {
- this.path = path;
- this.pathWithSep = path + PATH_SEPARATOR;
- this.inst = inst;
- }
-
- @Override
- public String toString() {
- return "NetworkTable: " + path;
- }
-
- private final ConcurrentMap entries =
- new ConcurrentHashMap();
-
- /**
- * Gets the entry for a subkey.
- *
- * @param key the key name
- * @return Network table entry.
- */
- private NetworkTableEntry getEntry(String key) {
- NetworkTableEntry entry = entries.get(key);
- if (entry == null) {
- entry = inst.getEntry(pathWithSep + key);
- entries.putIfAbsent(key, entry);
- }
- return entry;
- }
-
- /**
- * Gets the current network connections.
- *
- * @return An array of connection information.
- * @deprecated Use {@link NetworkTableInstance#getConnections()} instead.
- */
- @Deprecated
- public static ConnectionInfo[] connections() {
- return NetworkTableInstance.getDefault().getConnections();
- }
-
- /**
- * Determine whether or not a network connection is active.
- *
- * @return True if connected, false if not connected.
- * @deprecated Use {@link NetworkTableInstance#isConnected()} instead.
- */
- @Override
- @Deprecated
- public boolean isConnected() {
- return inst.isConnected();
- }
-
- /**
- * Determine whether NetworkTables is operating as a server or as a client.
- *
- * @return True if operating as a server, false otherwise.
- * @deprecated Use {@link NetworkTableInstance#getNetworkMode()} instead.
- */
- @Override
- @Deprecated
- public boolean isServer() {
- return (inst.getNetworkMode() & NetworkTableInstance.kNetModeServer) != 0;
- }
-
- /* Backwards compatibility shims for IRemoteConnectionListener */
- private static class ConnectionListenerAdapter implements Consumer {
- public int uid;
- private final IRemote targetSource;
- private final IRemoteConnectionListener targetListener;
-
- public ConnectionListenerAdapter(
- IRemote targetSource, IRemoteConnectionListener targetListener) {
- this.targetSource = targetSource;
- this.targetListener = targetListener;
- }
-
- @Override
- public void accept(ConnectionNotification event) {
- if (event.connected) targetListener.connectedEx(targetSource, event.conn);
- else targetListener.disconnectedEx(targetSource, event.conn);
- }
- }
-
- private static final HashMap
- globalConnectionListenerMap =
- new HashMap();
-
- private static IRemote staticRemote =
- new IRemote() {
- @Override
- public void addConnectionListener(
- IRemoteConnectionListener listener, boolean immediateNotify) {
- NetworkTable.addGlobalConnectionListener(listener, immediateNotify);
- }
-
- @Override
- public void removeConnectionListener(IRemoteConnectionListener listener) {
- NetworkTable.removeGlobalConnectionListener(listener);
- }
-
- @Override
- public boolean isConnected() {
- ConnectionInfo[] conns = NetworkTableInstance.getDefault().getConnections();
- return conns.length > 0;
- }
-
- @Override
- public boolean isServer() {
- return (NetworkTableInstance.getDefault().getNetworkMode()
- & NetworkTableInstance.kNetModeServer)
- != 0;
- }
- };
-
- private final HashMap
- connectionListenerMap = new HashMap();
-
- /**
- * Add a connection listener.
- *
- * @param listener connection listener
- * @param immediateNotify call listener immediately for all existing connections
- * @deprecated Use {@link NetworkTableInstance#addConnectionListener(Consumer, boolean)} instead.
- */
- @Deprecated
- public static synchronized void addGlobalConnectionListener(
- IRemoteConnectionListener listener, boolean immediateNotify) {
- ConnectionListenerAdapter adapter = new ConnectionListenerAdapter(staticRemote, listener);
- if (globalConnectionListenerMap.putIfAbsent(listener, adapter) != null) {
- throw new IllegalStateException("Cannot add the same listener twice");
- }
- adapter.uid = NetworkTableInstance.getDefault().addConnectionListener(adapter, immediateNotify);
- }
-
- /**
- * Remove a connection listener.
- *
- * @param listener connection listener
- * @deprecated Use {@link NetworkTableInstance#removeConnectionListener(int)} instead.
- */
- @Deprecated
- public static synchronized void removeGlobalConnectionListener(
- IRemoteConnectionListener listener) {
- ConnectionListenerAdapter adapter = globalConnectionListenerMap.remove(listener);
- if (adapter != null) {
- NetworkTableInstance.getDefault().removeConnectionListener(adapter.uid);
- }
- }
-
- /**
- * Add a connection listener.
- *
- * @param listener connection listener
- * @param immediateNotify call listener immediately for all existing connections
- * @deprecated Use {@link NetworkTableInstance#addConnectionListener(Consumer, boolean)} instead.
- */
- @Override
- @Deprecated
- public synchronized void addConnectionListener(
- IRemoteConnectionListener listener, boolean immediateNotify) {
- ConnectionListenerAdapter adapter = new ConnectionListenerAdapter(this, listener);
- if (connectionListenerMap.putIfAbsent(listener, adapter) != null) {
- throw new IllegalStateException("Cannot add the same listener twice");
- }
- adapter.uid = inst.addConnectionListener(adapter, immediateNotify);
- }
-
- /**
- * Remove a connection listener.
- *
- * @param listener connection listener
- * @deprecated Use {@link NetworkTableInstance#removeConnectionListener(int)} instead.
- */
- @Override
- @Deprecated
- public synchronized void removeConnectionListener(IRemoteConnectionListener listener) {
- ConnectionListenerAdapter adapter = connectionListenerMap.get(listener);
- if (adapter != null && connectionListenerMap.remove(listener, adapter)) {
- inst.removeConnectionListener(adapter.uid);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link
- * edu.wpi.first.networktables.NetworkTable#addEntryListener(TableEntryListener, int)} instead
- * (with flags value of NOTIFY_NEW | NOTIFY_UPDATE).
- */
- @Override
- @Deprecated
- public void addTableListener(ITableListener listener) {
- addTableListenerEx(listener, NOTIFY_NEW | NOTIFY_UPDATE);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link
- * edu.wpi.first.networktables.NetworkTable#addEntryListener(TableEntryListener, int)} instead
- * (with flags value of NOTIFY_NEW | NOTIFY_UPDATE | NOTIFY_IMMEDIATE).
- */
- @Override
- @Deprecated
- public void addTableListener(ITableListener listener, boolean immediateNotify) {
- int flags = NOTIFY_NEW | NOTIFY_UPDATE;
- if (immediateNotify) flags |= NOTIFY_IMMEDIATE;
- addTableListenerEx(listener, flags);
- }
-
- /* Base class for listeners; stores uid to implement remove functions */
- private static class ListenerBase {
- public int uid;
- }
-
- private static class OldTableListenerAdapter extends ListenerBase
- implements Consumer {
- private final int prefixLen;
- private final ITable targetSource;
- private final ITableListener targetListener;
-
- public OldTableListenerAdapter(
- int prefixLen, ITable targetSource, ITableListener targetListener) {
- this.prefixLen = prefixLen;
- this.targetSource = targetSource;
- this.targetListener = targetListener;
- }
-
- @Override
- public void accept(EntryNotification event) {
- String relativeKey = event.name.substring(prefixLen);
- if (relativeKey.indexOf(PATH_SEPARATOR) != -1) return;
- targetListener.valueChangedEx(targetSource, relativeKey, event.value.getValue(), event.flags);
- }
- }
-
- private final HashMap> oldListenerMap =
- new HashMap>();
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link
- * edu.wpi.first.networktables.NetworkTable#addEntryListener(TableEntryListener, int)}
- * instead.
- */
- @Override
- @Deprecated
- public synchronized void addTableListenerEx(ITableListener listener, int flags) {
- List adapters = oldListenerMap.get(listener);
- if (adapters == null) {
- adapters = new ArrayList();
- oldListenerMap.put(listener, adapters);
- }
- OldTableListenerAdapter adapter =
- new OldTableListenerAdapter(path.length() + 1, this, listener);
- adapter.uid = inst.addEntryListener(pathWithSep, adapter, flags);
- adapters.add(adapter);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable#addEntryListener(String,
- * TableEntryListener, int)} or {@link NetworkTableEntry#addListener(Consumer, int)} instead.
- */
- @Override
- @Deprecated
- public void addTableListener(String key, ITableListener listener, boolean immediateNotify) {
- int flags = NOTIFY_NEW | NOTIFY_UPDATE;
- if (immediateNotify) flags |= NOTIFY_IMMEDIATE;
- addTableListenerEx(key, listener, flags);
- }
-
- private static class OldKeyListenerAdapter extends ListenerBase
- implements Consumer {
- private final String relativeKey;
- private final ITable targetSource;
- private final ITableListener targetListener;
-
- public OldKeyListenerAdapter(
- String relativeKey, ITable targetSource, ITableListener targetListener) {
- this.relativeKey = relativeKey;
- this.targetSource = targetSource;
- this.targetListener = targetListener;
- }
-
- @Override
- public void accept(EntryNotification event) {
- targetListener.valueChangedEx(targetSource, relativeKey, event.value.getValue(), event.flags);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable#addEntryListener(String,
- * TableEntryListener, int)} or {@link NetworkTableEntry#addListener(Consumer, int)} instead.
- */
- @Override
- @Deprecated
- public synchronized void addTableListenerEx(String key, ITableListener listener, int flags) {
- List adapters = oldListenerMap.get(listener);
- if (adapters == null) {
- adapters = new ArrayList();
- oldListenerMap.put(listener, adapters);
- }
- OldKeyListenerAdapter adapter = new OldKeyListenerAdapter(key, this, listener);
- adapter.uid = inst.addEntryListener(getEntry(key), adapter, flags);
- adapters.add(adapter);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link
- * edu.wpi.first.networktables.NetworkTable#addSubTableListener(TableListener, boolean)}
- * instead.
- */
- @Override
- @Deprecated
- public void addSubTableListener(final ITableListener listener) {
- addSubTableListener(listener, false);
- }
-
- private static class OldSubListenerAdapter extends ListenerBase
- implements Consumer {
- private final int prefixLen;
- private final ITable targetSource;
- private final ITableListener targetListener;
- private final Set notifiedTables = new HashSet();
-
- public OldSubListenerAdapter(
- int prefixLen, ITable targetSource, ITableListener targetListener) {
- this.prefixLen = prefixLen;
- this.targetSource = targetSource;
- this.targetListener = targetListener;
- }
-
- @Override
- public void accept(EntryNotification event) {
- String relativeKey = event.name.substring(prefixLen);
- int endSubTable = relativeKey.indexOf(PATH_SEPARATOR);
- if (endSubTable == -1) return;
- String subTableKey = relativeKey.substring(0, endSubTable);
- if (notifiedTables.contains(subTableKey)) return;
- notifiedTables.add(subTableKey);
- targetListener.valueChangedEx(
- targetSource, subTableKey, targetSource.getSubTable(subTableKey), event.flags);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link
- * edu.wpi.first.networktables.NetworkTable#addSubTableListener(TableListener, boolean)}
- * instead.
- */
- @Override
- @Deprecated
- public synchronized void addSubTableListener(final ITableListener listener, boolean localNotify) {
- List adapters = oldListenerMap.get(listener);
- if (adapters == null) {
- adapters = new ArrayList();
- oldListenerMap.put(listener, adapters);
- }
- OldSubListenerAdapter adapter = new OldSubListenerAdapter(path.length() + 1, this, listener);
- int flags = NOTIFY_NEW | NOTIFY_IMMEDIATE;
- if (localNotify) flags |= NOTIFY_LOCAL;
- adapter.uid = inst.addEntryListener(pathWithSep, adapter, flags);
- adapters.add(adapter);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable#removeTableListener(int)}
- * instead.
- */
- @Override
- @Deprecated
- public synchronized void removeTableListener(ITableListener listener) {
- List adapters = oldListenerMap.remove(listener);
- if (adapters != null) {
- for (ListenerBase adapter : adapters) inst.removeEntryListener(adapter.uid);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public ITable getSubTable(String key) {
- return new NetworkTable(inst, pathWithSep + key);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean containsKey(String key) {
- return getEntry(key).exists();
- }
-
- @Override
- public boolean containsSubTable(String key) {
- int[] handles =
- NetworkTablesJNI.getEntries(inst.getHandle(), pathWithSep + key + PATH_SEPARATOR, 0);
- return handles.length != 0;
- }
-
- /**
- * @param types bitmask of types; 0 is treated as a "don't care".
- * @return keys currently in the table
- */
- @Override
- public Set getKeys(int types) {
- Set keys = new HashSet();
- int prefixLen = path.length() + 1;
- for (EntryInfo info : inst.getEntryInfo(pathWithSep, types)) {
- String relativeKey = info.name.substring(prefixLen);
- if (relativeKey.indexOf(PATH_SEPARATOR) != -1) continue;
- keys.add(relativeKey);
- // populate entries as we go
- if (entries.get(relativeKey) == null) {
- entries.putIfAbsent(relativeKey, new NetworkTableEntry(inst, info.entry));
- }
- }
- return keys;
- }
-
- /** {@inheritDoc} */
- @Override
- public Set getKeys() {
- return getKeys(0);
- }
-
- /** {@inheritDoc} */
- @Override
- public Set getSubTables() {
- Set keys = new HashSet();
- int prefixLen = path.length() + 1;
- for (EntryInfo info : inst.getEntryInfo(pathWithSep, 0)) {
- String relativeKey = info.name.substring(prefixLen);
- int endSubTable = relativeKey.indexOf(PATH_SEPARATOR);
- if (endSubTable == -1) continue;
- keys.add(relativeKey.substring(0, endSubTable));
- }
- return keys;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putNumber(String key, double value) {
- return getEntry(key).setNumber(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultNumber(String key, double defaultValue) {
- return getEntry(key).setDefaultDouble(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNumber(String key, double defaultValue) {
- return getEntry(key).getDouble(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putString(String key, String value) {
- return getEntry(key).setString(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultString(String key, String defaultValue) {
- return getEntry(key).setDefaultString(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public String getString(String key, String defaultValue) {
- return getEntry(key).getString(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putBoolean(String key, boolean value) {
- return getEntry(key).setBoolean(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultBoolean(String key, boolean defaultValue) {
- return getEntry(key).setDefaultBoolean(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean getBoolean(String key, boolean defaultValue) {
- return getEntry(key).getBoolean(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putBooleanArray(String key, boolean[] value) {
- return getEntry(key).setBooleanArray(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putBooleanArray(String key, Boolean[] value) {
- return getEntry(key).setBooleanArray(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultBooleanArray(String key, boolean[] defaultValue) {
- return getEntry(key).setDefaultBooleanArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultBooleanArray(String key, Boolean[] defaultValue) {
- return getEntry(key).setDefaultBooleanArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean[] getBooleanArray(String key, boolean[] defaultValue) {
- return getEntry(key).getBooleanArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public Boolean[] getBooleanArray(String key, Boolean[] defaultValue) {
- return getEntry(key).getBooleanArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putNumberArray(String key, double[] value) {
- return getEntry(key).setDoubleArray(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putNumberArray(String key, Double[] value) {
- return getEntry(key).setNumberArray(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultNumberArray(String key, double[] defaultValue) {
- return getEntry(key).setDefaultDoubleArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultNumberArray(String key, Double[] defaultValue) {
- return getEntry(key).setDefaultNumberArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public double[] getNumberArray(String key, double[] defaultValue) {
- return getEntry(key).getDoubleArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public Double[] getNumberArray(String key, Double[] defaultValue) {
- return getEntry(key).getDoubleArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putStringArray(String key, String[] value) {
- return getEntry(key).setStringArray(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultStringArray(String key, String[] defaultValue) {
- return getEntry(key).setDefaultStringArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public String[] getStringArray(String key, String[] defaultValue) {
- return getEntry(key).getStringArray(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putRaw(String key, byte[] value) {
- return getEntry(key).setRaw(value);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean setDefaultRaw(String key, byte[] defaultValue) {
- return getEntry(key).setDefaultRaw(defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean putRaw(String key, ByteBuffer value, int len) {
- return getEntry(key).setRaw(value, len);
- }
-
- /** {@inheritDoc} */
- @Override
- public byte[] getRaw(String key, byte[] defaultValue) {
- return getEntry(key).getRaw(defaultValue);
- }
-
- /**
- * Put a value in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putValue(String key, NetworkTableValue value) {
- return getEntry(key).setValue(value);
- }
-
- /**
- * Sets the current value in the table if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultValue(String key, NetworkTableValue defaultValue) {
- return getEntry(key).setDefaultValue(defaultValue);
- }
-
- /**
- * Gets the value associated with a key as a NetworkTableValue object.
- *
- * @param key the key of the value to look up
- * @return the value associated with the given key
- */
- public NetworkTableValue getValue(String key) {
- return getEntry(key).getValue();
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTableEntry#setValue(Object)} instead,
- * e.g. `NetworkTable.getEntry(key).setValue(NetworkTableEntry.makeBoolean(false));` or
- * `NetworkTable.getEntry(key).setValue(new Boolean(false));`
- */
- @Override
- @Deprecated
- public boolean putValue(String key, Object value) throws IllegalArgumentException {
- if (value instanceof Boolean) return putBoolean(key, ((Boolean) value).booleanValue());
- else if (value instanceof Number) return putDouble(key, ((Number) value).doubleValue());
- else if (value instanceof String) return putString(key, (String) value);
- else if (value instanceof byte[]) return putRaw(key, (byte[]) value);
- else if (value instanceof boolean[]) return putBooleanArray(key, (boolean[]) value);
- else if (value instanceof double[]) return putNumberArray(key, (double[]) value);
- else if (value instanceof Boolean[]) return putBooleanArray(key, toNative((Boolean[]) value));
- else if (value instanceof Number[]) return putNumberArray(key, toNative((Number[]) value));
- else if (value instanceof String[]) return putStringArray(key, (String[]) value);
- else if (value instanceof NetworkTableValue)
- return getEntry(key).setValue((NetworkTableValue) value);
- else
- throw new IllegalArgumentException(
- "Value of type " + value.getClass().getName() + " cannot be put into a table");
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTableEntry#getValue()} instead, e.g.
- * `NetworkTable.getEntry(key).getValue();`
- */
- @Override
- @Deprecated
- public Object getValue(String key, Object defaultValue) {
- NetworkTableValue value = getValue(key);
- if (value.getType() == NetworkTableType.kUnassigned) {
- return defaultValue;
- }
- return value.getValue();
- }
-
- /** The persistent flag value. */
- public static final int PERSISTENT = 1;
-
- /** {@inheritDoc} */
- @Override
- public void setPersistent(String key) {
- getEntry(key).setPersistent();
- }
-
- /** {@inheritDoc} */
- @Override
- public void clearPersistent(String key) {
- getEntry(key).clearPersistent();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isPersistent(String key) {
- return getEntry(key).isPersistent();
- }
-
- /** {@inheritDoc} */
- @Override
- public void setFlags(String key, int flags) {
- getEntry(key).setFlags(flags);
- }
-
- /** {@inheritDoc} */
- @Override
- public void clearFlags(String key, int flags) {
- getEntry(key).clearFlags(flags);
- }
-
- /** {@inheritDoc} */
- @Override
- public int getFlags(String key) {
- return getEntry(key).getFlags();
- }
-
- /** {@inheritDoc} */
- @Override
- public void delete(String key) {
- getEntry(key).delete();
- }
-
- /**
- * Deletes ALL keys in ALL subtables. Use with caution!
- *
- * @deprecated Use {@link NetworkTableInstance#deleteAllEntries()} instead.
- */
- @Deprecated
- public static void globalDeleteAll() {
- NetworkTableInstance.getDefault().deleteAllEntries();
- }
-
- /**
- * Flushes all updated values immediately to the network. Note: This is rate-limited to protect
- * the network from flooding. This is primarily useful for synchronizing network updates with user
- * code.
- *
- * @deprecated Use {@link NetworkTableInstance#flush()} instead.
- */
- @Deprecated
- public static void flush() {
- NetworkTableInstance.getDefault().flush();
- }
-
- /**
- * Set the periodic update rate.
- *
- * @param interval update interval in seconds (range 0.01 to 1.0)
- * @deprecated Use {@link NetworkTableInstance#setUpdateRate(double)} instead.
- */
- @Deprecated
- public static void setUpdateRate(double interval) {
- NetworkTableInstance.getDefault().setUpdateRate(interval);
- }
-
- /**
- * Saves persistent keys to a file. The server does this automatically.
- *
- * @param filename file name
- * @throws PersistentException if error saving file
- * @deprecated Use {@link NetworkTableInstance#savePersistent(String)} instead.
- */
- @Deprecated
- public static void savePersistent(String filename) throws PersistentException {
- NetworkTableInstance.getDefault().savePersistent(filename);
- }
-
- /**
- * Loads persistent keys from a file. The server does this automatically.
- *
- * @param filename file name
- * @return List of warnings (errors result in an exception instead)
- * @throws PersistentException if error reading file
- * @deprecated Use {@link NetworkTableInstance#loadPersistent(String)} instead.
- */
- @Deprecated
- public static String[] loadPersistent(String filename) throws PersistentException {
- return NetworkTableInstance.getDefault().loadPersistent(filename);
- }
-
- /*
- * Deprecated Methods
- */
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link #putNumber(String, double)} instead.
- */
- @Override
- @Deprecated
- public boolean putDouble(String key, double value) {
- return putNumber(key, value);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated Use {@link #getNumber(String, double)} instead.
- */
- @Override
- @Deprecated
- public double getDouble(String key, double defaultValue) {
- return getNumber(key, defaultValue);
- }
-
- /** {@inheritDoc} */
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (!(o instanceof NetworkTable)) {
- return false;
- }
- NetworkTable other = (NetworkTable) o;
- return inst.equals(other.inst) && path.equals(other.path);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(inst, path);
- }
-}
diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java
deleted file mode 100644
index 508e8812b5..0000000000
--- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) FIRST and other WPILib contributors.
-// Open Source Software; you can modify and/or share it under the terms of
-// the WPILib BSD license file in the root directory of this project.
-
-package edu.wpi.first.wpilibj.tables;
-
-/**
- * Represents an object that has a remote connection.
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTableInstance}.
- */
-@Deprecated
-@SuppressWarnings("checkstyle:all")
-public interface IRemote {
- /**
- * Register an object to listen for connection and disconnection events
- *
- * @param listener the listener to be register
- * @param immediateNotify if the listener object should be notified of the current connection
- * state
- */
- public void addConnectionListener(IRemoteConnectionListener listener, boolean immediateNotify);
-
- /**
- * Unregister a listener from connection events
- *
- * @param listener the listener to be unregistered
- */
- public void removeConnectionListener(IRemoteConnectionListener listener);
-
- /**
- * Get the current state of the objects connection
- *
- * @return the current connection state
- */
- public boolean isConnected();
-
- /**
- * If the object is acting as a server
- *
- * @return if the object is a server
- */
- public boolean isServer();
-}
diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java
deleted file mode 100644
index ed5d02b8b6..0000000000
--- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) FIRST and other WPILib contributors.
-// Open Source Software; you can modify and/or share it under the terms of
-// the WPILib BSD license file in the root directory of this project.
-
-package edu.wpi.first.wpilibj.tables;
-
-import edu.wpi.first.networktables.ConnectionInfo;
-
-/**
- * A listener that listens for connection changes in a {@link IRemote} object.
- *
- * @deprecated Use Consumer<{@link edu.wpi.first.networktables.ConnectionNotification}>.
- */
-@Deprecated
-@SuppressWarnings("checkstyle:all")
-public interface IRemoteConnectionListener {
- /**
- * Called when an IRemote is connected
- *
- * @param remote the object that connected
- */
- public void connected(IRemote remote);
- /**
- * Called when an IRemote is disconnected
- *
- * @param remote the object that disconnected
- */
- public void disconnected(IRemote remote);
- /**
- * Extended version of connected called when an IRemote is connected. Contains the connection info
- * of the connected remote
- *
- * @param remote the object that connected
- * @param info the connection info for the connected remote
- */
- public default void connectedEx(IRemote remote, ConnectionInfo info) {
- connected(remote);
- }
- /**
- * Extended version of connected called when an IRemote is disconnected. Contains the connection
- * info of the disconnected remote
- *
- * @param remote the object that disconnected
- * @param info the connection info for the disconnected remote
- */
- public default void disconnectedEx(IRemote remote, ConnectionInfo info) {
- disconnected(remote);
- }
-}
diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java
deleted file mode 100644
index 330484a73d..0000000000
--- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java
+++ /dev/null
@@ -1,513 +0,0 @@
-// Copyright (c) FIRST and other WPILib contributors.
-// Open Source Software; you can modify and/or share it under the terms of
-// the WPILib BSD license file in the root directory of this project.
-
-package edu.wpi.first.wpilibj.tables;
-
-import java.nio.ByteBuffer;
-import java.util.Set;
-
-/**
- * A table whose values can be read and written to.
- *
- * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable}.
- */
-@Deprecated
-@SuppressWarnings("checkstyle:all")
-public interface ITable {
-
- /**
- * Checks the table and tells if it contains the specified key
- *
- * @param key the key to search for
- * @return true if the table as a value assigned to the given key
- */
- public boolean containsKey(String key);
-
- /**
- * @param key the key to search for
- * @return true if there is a subtable with the key which contains at least one key/subtable of
- * its own
- */
- public boolean containsSubTable(String key);
-
- /**
- * Returns the table at the specified key. If there is no table at the specified key, it will
- * create a new table
- *
- * @param key the name of the table relative to this one
- * @return a sub table relative to this one
- */
- public ITable getSubTable(String key);
-
- /**
- * Gets all keys in the table (not including sub-tables).
- *
- * @param types bitmask of types; 0 is treated as a "don't care".
- * @return keys currently in the table
- */
- public Set getKeys(int types);
-
- /**
- * Gets all keys in the table (not including sub-tables).
- *
- * @return keys currently in the table
- */
- public Set getKeys();
-
- /**
- * Gets the names of all subtables in the table.
- *
- * @return subtables currently in the table
- */
- public Set getSubTables();
-
- /**
- * Makes a key's value persistent through program restarts. The key cannot be null.
- *
- * @param key the key name
- */
- public void setPersistent(String key);
-
- /**
- * Stop making a key's value persistent through program restarts. The key cannot be null.
- *
- * @param key the key name
- */
- public void clearPersistent(String key);
-
- /**
- * Returns whether the value is persistent through program restarts. The key cannot be null.
- *
- * @param key the key name
- * @return True if the value is persistent.
- */
- public boolean isPersistent(String key);
-
- /**
- * Sets flags on the specified key in this table. The key can not be null.
- *
- * @param key the key name
- * @param flags the flags to set (bitmask)
- */
- public void setFlags(String key, int flags);
-
- /**
- * Clears flags on the specified key in this table. The key can not be null.
- *
- * @param key the key name
- * @param flags the flags to clear (bitmask)
- */
- public void clearFlags(String key, int flags);
-
- /**
- * Returns the flags for the specified key.
- *
- * @param key the key name
- * @return the flags, or 0 if the key is not defined
- */
- public int getFlags(String key);
-
- /**
- * Deletes the specified key in this table. The key can not be null.
- *
- * @param key the key name
- */
- public void delete(String key);
-
- /**
- * Gets the value associated with a key as an object. NOTE: If the value is a double, it will
- * return a Double object, not a primitive. To get the primitive, use {@link #getDouble(String,
- * double)}.
- *
- * @param key the key of the value to look up
- * @param defaultValue the default value if the key is null
- * @return the value associated with the given key
- */
- public Object getValue(String key, Object defaultValue);
-
- /**
- * Put a value in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- * @throws IllegalArgumentException when the value is not supported by the table
- */
- public boolean putValue(String key, Object value) throws IllegalArgumentException;
-
- /**
- * Put a number in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putNumber(String key, double value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultNumber(String key, double defaultValue);
-
- /**
- * Returns the number the key maps to. If the key does not exist or is of different type, it will
- * return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public double getNumber(String key, double defaultValue);
-
- /**
- * Put a string in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putString(String key, String value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultString(String key, String defaultValue);
-
- /**
- * Returns the string the key maps to. If the key does not exist or is of different type, it will
- * return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public String getString(String key, String defaultValue);
-
- /**
- * Put a boolean in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putBoolean(String key, boolean value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultBoolean(String key, boolean defaultValue);
-
- /**
- * Returns the boolean the key maps to. If the key does not exist or is of different type, it will
- * return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public boolean getBoolean(String key, boolean defaultValue);
-
- /**
- * Put a boolean array in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putBooleanArray(String key, boolean[] value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultBooleanArray(String key, boolean[] defaultValue);
-
- /**
- * Put a boolean array in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putBooleanArray(String key, Boolean[] value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultBooleanArray(String key, Boolean[] defaultValue);
-
- /**
- * Returns the boolean array the key maps to. If the key does not exist or is of different type,
- * it will return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public boolean[] getBooleanArray(String key, boolean[] defaultValue);
- /**
- * Returns the boolean array the key maps to. If the key does not exist or is of different type,
- * it will return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public Boolean[] getBooleanArray(String key, Boolean[] defaultValue);
-
- /**
- * Put a number array in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putNumberArray(String key, double[] value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultNumberArray(String key, double[] defaultValue);
-
- /**
- * Put a number array in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putNumberArray(String key, Double[] value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultNumberArray(String key, Double[] defaultValue);
-
- /**
- * Returns the number array the key maps to. If the key does not exist or is of different type, it
- * will return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public double[] getNumberArray(String key, double[] defaultValue);
- /**
- * Returns the number array the key maps to. If the key does not exist or is of different type, it
- * will return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public Double[] getNumberArray(String key, Double[] defaultValue);
-
- /**
- * Put a string array in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putStringArray(String key, String[] value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultStringArray(String key, String[] defaultValue);
-
- /**
- * Returns the string array the key maps to. If the key does not exist or is of different type, it
- * will return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public String[] getStringArray(String key, String[] defaultValue);
-
- /**
- * Put a raw value (byte array) in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @return False if the table key already exists with a different type
- */
- public boolean putRaw(String key, byte[] value);
-
- /**
- * Gets the current value in the table, setting it if it does not exist.
- *
- * @param key the key
- * @param defaultValue the default value to set if key doens't exist.
- * @return False if the table key exists with a different type
- */
- public boolean setDefaultRaw(String key, byte[] defaultValue);
-
- /**
- * Put a raw value (bytes from a byte buffer) in the table
- *
- * @param key the key to be assigned to
- * @param value the value that will be assigned
- * @param len the length of the value
- * @return False if the table key already exists with a different type
- */
- public boolean putRaw(String key, ByteBuffer value, int len);
-
- /**
- * Returns the raw value (byte array) the key maps to. If the key does not exist or is of
- * different type, it will return the default value.
- *
- * @param key the key to look up
- * @param defaultValue the value to be returned if no value is found
- * @return the value associated with the given key or the given default value if there is no value
- * associated with the key
- */
- public byte[] getRaw(String key, byte[] defaultValue);
-
- /** Notifier flag values. */
- public static final int NOTIFY_IMMEDIATE = 0x01;
-
- public static final int NOTIFY_LOCAL = 0x02;
- public static final int NOTIFY_NEW = 0x04;
- public static final int NOTIFY_DELETE = 0x08;
- public static final int NOTIFY_UPDATE = 0x10;
- public static final int NOTIFY_FLAGS = 0x20;
-
- /**
- * Add a listener for changes to the table
- *
- * @param listener the listener to add
- */
- public void addTableListener(ITableListener listener);
- /**
- * Add a listener for changes to the table
- *
- * @param listener the listener to add
- * @param immediateNotify if true then this listener will be notified of all current entries
- * (marked as new)
- */
- public void addTableListener(ITableListener listener, boolean immediateNotify);
- /**
- * Add a listener for changes to the table
- *
- * @param listener the listener to add
- * @param flags bitmask specifying desired notifications
- */
- public void addTableListenerEx(ITableListener listener, int flags);
-
- /**
- * Add a listener for changes to a specific key the table
- *
- * @param key the key to listen for
- * @param listener the listener to add
- * @param immediateNotify if true then this listener will be notified of all current entries
- * (marked as new)
- */
- public void addTableListener(String key, ITableListener listener, boolean immediateNotify);
- /**
- * Add a listener for changes to a specific key the table
- *
- * @param key the key to listen for
- * @param listener the listener to add
- * @param flags bitmask specifying desired notifications
- */
- public void addTableListenerEx(String key, ITableListener listener, int flags);
- /**
- * This will immediately notify the listener of all current sub tables
- *
- * @param listener the listener to notify
- */
- public void addSubTableListener(final ITableListener listener);
- /**
- * This will immediately notify the listener of all current sub tables
- *
- * @param listener the listener to notify
- * @param localNotify if true then this listener will be notified of all local changes in addition
- * to all remote changes
- */
- public void addSubTableListener(final ITableListener listener, boolean localNotify);
- /**
- * Remove a listener from receiving table events
- *
- * @param listener the listener to be removed
- */
- public void removeTableListener(ITableListener listener);
-
- /*
- * Deprecated Methods
- */
-
- /**
- * Maps the specified key to the specified value in this table. The key can not be null. The value
- * can be retrieved by calling the get method with a key that is equal to the original key.
- *
- * @param key the key
- * @param value the value
- * @return False if the table key already exists with a different type
- * @throws IllegalArgumentException if key is null
- * @deprecated Use {@link #putNumber(String, double)} instead.
- */
- @Deprecated
- public boolean putDouble(String key, double value);
-
- /**
- * Returns the value at the specified key.
- *
- * @param key the key
- * @param defaultValue the value returned if the key is undefined
- * @return the value
- * @throws IllegalArgumentException if the value mapped to by the key is not a double
- * @throws IllegalArgumentException if the key is null
- * @deprecated Use {@link #getNumber(String, double)} instead.
- */
- @Deprecated
- public double getDouble(String key, double defaultValue);
-
- /**
- * Gets the full path of this table. Does not include the trailing "/".
- *
- * @return The path to this table (e.g. "", "/foo").
- */
- public String getPath();
-}
diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java
deleted file mode 100644
index 3ff81f17ec..0000000000
--- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) FIRST and other WPILib contributors.
-// Open Source Software; you can modify and/or share it under the terms of
-// the WPILib BSD license file in the root directory of this project.
-
-package edu.wpi.first.wpilibj.tables;
-
-/**
- * A listener that listens to changes in values in a {@link ITable}.
- *
- * @deprecated Use Consumer<{@link edu.wpi.first.networktables.EntryNotification}>, {@link
- * edu.wpi.first.networktables.TableEntryListener}, or {@link
- * edu.wpi.first.networktables.TableListener} as appropriate.
- */
-@FunctionalInterface
-@Deprecated
-@SuppressWarnings("checkstyle:all")
-public interface ITableListener {
- /**
- * Called when a key-value pair is changed in a {@link ITable}
- *
- * @param source the table the key-value pair exists in
- * @param key the key associated with the value that changed
- * @param value the new value
- * @param isNew true if the key did not previously exist in the table, otherwise it is false
- */
- public void valueChanged(ITable source, String key, Object value, boolean isNew);
-
- /**
- * Extended version of valueChanged. Called when a key-value pair is changed in a {@link ITable}.
- * The default implementation simply calls valueChanged(). If this is overridden, valueChanged()
- * will not be called.
- *
- * @param source the table the key-value pair exists in
- * @param key the key associated with the value that changed
- * @param value the new value
- * @param flags update flags; for example, NOTIFY_NEW if the key did not previously exist in the
- * table
- */
- public default void valueChangedEx(ITable source, String key, Object value, int flags) {
- // NOTIFY_NEW = 0x04
- valueChanged(source, key, value, (flags & 0x04) != 0);
- }
-}
diff --git a/ntcore/src/main/native/cpp/Dispatcher.cpp b/ntcore/src/main/native/cpp/Dispatcher.cpp
index ce6df31e59..839faeb1f2 100644
--- a/ntcore/src/main/native/cpp/Dispatcher.cpp
+++ b/ntcore/src/main/native/cpp/Dispatcher.cpp
@@ -18,9 +18,9 @@
using namespace nt;
-void Dispatcher::StartServer(const Twine& persist_filename,
+void Dispatcher::StartServer(const wpi::Twine& persist_filename,
const char* listen_address, unsigned int port) {
- std::string listen_address_copy(StringRef(listen_address).trim());
+ std::string listen_address_copy(wpi::StringRef(listen_address).trim());
DispatcherBase::StartServer(
persist_filename,
std::unique_ptr(new wpi::TCPAcceptor(
@@ -28,7 +28,7 @@ void Dispatcher::StartServer(const Twine& persist_filename,
}
void Dispatcher::SetServer(const char* server_name, unsigned int port) {
- std::string server_name_copy(StringRef(server_name).trim());
+ std::string server_name_copy(wpi::StringRef(server_name).trim());
SetConnector([=]() -> std::unique_ptr {
return wpi::TCPConnector::connect(server_name_copy.c_str(),
static_cast(port), m_logger, 1);
@@ -36,7 +36,7 @@ void Dispatcher::SetServer(const char* server_name, unsigned int port) {
}
void Dispatcher::SetServer(
- ArrayRef> servers) {
+ wpi::ArrayRef> servers) {
wpi::SmallVector, 16> servers_copy;
for (const auto& server : servers) {
servers_copy.emplace_back(std::string{server.first.trim()},
@@ -53,7 +53,7 @@ void Dispatcher::SetServer(
}
void Dispatcher::SetServerTeam(unsigned int team, unsigned int port) {
- std::pair servers[5];
+ std::pair servers[5];
// 10.te.am.2
wpi::SmallString<32> fixed;
@@ -95,7 +95,7 @@ void Dispatcher::SetServerTeam(unsigned int team, unsigned int port) {
}
void Dispatcher::SetServerOverride(const char* server_name, unsigned int port) {
- std::string server_name_copy(StringRef(server_name).trim());
+ std::string server_name_copy(wpi::StringRef(server_name).trim());
SetConnectorOverride([=]() -> std::unique_ptr {
return wpi::TCPConnector::connect(server_name_copy.c_str(),
static_cast(port), m_logger, 1);
@@ -134,7 +134,7 @@ void DispatcherBase::StartLocal() {
}
void DispatcherBase::StartServer(
- const Twine& persist_filename,
+ const wpi::Twine& persist_filename,
std::unique_ptr acceptor) {
{
std::scoped_lock lock(m_user_mutex);
@@ -230,7 +230,7 @@ void DispatcherBase::SetUpdateRate(double interval) {
m_update_rate = static_cast(interval * 1000);
}
-void DispatcherBase::SetIdentity(const Twine& name) {
+void DispatcherBase::SetIdentity(const wpi::Twine& name) {
std::scoped_lock lock(m_user_mutex);
m_identity = name.str();
}
diff --git a/ntcore/src/main/native/cpp/Dispatcher.h b/ntcore/src/main/native/cpp/Dispatcher.h
index f5767d04dc..020f737a17 100644
--- a/ntcore/src/main/native/cpp/Dispatcher.h
+++ b/ntcore/src/main/native/cpp/Dispatcher.h
@@ -45,12 +45,12 @@ class DispatcherBase : public IDispatcher {
unsigned int GetNetworkMode() const;
void StartLocal();
- void StartServer(const Twine& persist_filename,
+ void StartServer(const wpi::Twine& persist_filename,
std::unique_ptr acceptor);
void StartClient();
void Stop();
void SetUpdateRate(double interval);
- void SetIdentity(const Twine& name);
+ void SetIdentity(const wpi::Twine& name);
void Flush();
std::vector GetConnections() const;
bool IsConnected() const;
@@ -132,11 +132,12 @@ class Dispatcher : public DispatcherBase {
wpi::Logger& logger)
: DispatcherBase(storage, notifier, logger) {}
- void StartServer(const Twine& persist_filename, const char* listen_address,
- unsigned int port);
+ void StartServer(const wpi::Twine& persist_filename,
+ const char* listen_address, unsigned int port);
void SetServer(const char* server_name, unsigned int port);
- void SetServer(ArrayRef> servers);
+ void SetServer(
+ wpi::ArrayRef> servers);
void SetServerTeam(unsigned int team, unsigned int port);
void SetServerOverride(const char* server_name, unsigned int port);
diff --git a/ntcore/src/main/native/cpp/EntryNotifier.cpp b/ntcore/src/main/native/cpp/EntryNotifier.cpp
index 81861dfd98..fb05cd9470 100644
--- a/ntcore/src/main/native/cpp/EntryNotifier.cpp
+++ b/ntcore/src/main/native/cpp/EntryNotifier.cpp
@@ -59,7 +59,7 @@ bool impl::EntryNotifierThread::Matches(const EntryListenerData& listener,
unsigned int EntryNotifier::Add(
std::function callback,
- StringRef prefix, unsigned int flags) {
+ wpi::StringRef prefix, unsigned int flags) {
if ((flags & NT_NOTIFY_LOCAL) != 0) {
m_local_notifiers = true;
}
@@ -93,7 +93,7 @@ unsigned int EntryNotifier::AddPolled(unsigned int poller_uid,
return DoAdd(poller_uid, Handle(m_inst, local_id, Handle::kEntry), flags);
}
-void EntryNotifier::NotifyEntry(unsigned int local_id, StringRef name,
+void EntryNotifier::NotifyEntry(unsigned int local_id, wpi::StringRef name,
std::shared_ptr value,
unsigned int flags,
unsigned int only_listener) {
diff --git a/ntcore/src/main/native/cpp/EntryNotifier.h b/ntcore/src/main/native/cpp/EntryNotifier.h
index c80fc627d0..bfc77f7025 100644
--- a/ntcore/src/main/native/cpp/EntryNotifier.h
+++ b/ntcore/src/main/native/cpp/EntryNotifier.h
@@ -29,13 +29,13 @@ struct EntryListenerData
EntryListenerData() = default;
EntryListenerData(
std::function callback_,
- StringRef prefix_, unsigned int flags_)
+ wpi::StringRef prefix_, unsigned int flags_)
: CallbackListenerData(callback_), prefix(prefix_), flags(flags_) {}
EntryListenerData(
std::function callback_,
NT_Entry entry_, unsigned int flags_)
: CallbackListenerData(callback_), entry(entry_), flags(flags_) {}
- EntryListenerData(unsigned int poller_uid_, StringRef prefix_,
+ EntryListenerData(unsigned int poller_uid_, wpi::StringRef prefix_,
unsigned int flags_)
: CallbackListenerData(poller_uid_), prefix(prefix_), flags(flags_) {}
EntryListenerData(unsigned int poller_uid_, NT_Entry entry_,
@@ -93,7 +93,7 @@ class EntryNotifier
unsigned int AddPolled(unsigned int poller_uid, unsigned int local_id,
unsigned int flags) override;
- void NotifyEntry(unsigned int local_id, StringRef name,
+ void NotifyEntry(unsigned int local_id, wpi::StringRef name,
std::shared_ptr value, unsigned int flags,
unsigned int only_listener = UINT_MAX) override;
diff --git a/ntcore/src/main/native/cpp/IEntryNotifier.h b/ntcore/src/main/native/cpp/IEntryNotifier.h
index 031621ff4b..bfc6da34b9 100644
--- a/ntcore/src/main/native/cpp/IEntryNotifier.h
+++ b/ntcore/src/main/native/cpp/IEntryNotifier.h
@@ -31,7 +31,7 @@ class IEntryNotifier {
virtual unsigned int AddPolled(unsigned int poller_uid, unsigned int local_id,
unsigned int flags) = 0;
- virtual void NotifyEntry(unsigned int local_id, StringRef name,
+ virtual void NotifyEntry(unsigned int local_id, wpi::StringRef name,
std::shared_ptr value, unsigned int flags,
unsigned int only_listener = UINT_MAX) = 0;
};
diff --git a/ntcore/src/main/native/cpp/IRpcServer.h b/ntcore/src/main/native/cpp/IRpcServer.h
index 4d90a3751d..1abce862f4 100644
--- a/ntcore/src/main/native/cpp/IRpcServer.h
+++ b/ntcore/src/main/native/cpp/IRpcServer.h
@@ -14,7 +14,7 @@ namespace nt {
class IRpcServer {
public:
- typedef std::function SendResponseFunc;
+ typedef std::function SendResponseFunc;
IRpcServer() = default;
IRpcServer(const IRpcServer&) = delete;
@@ -24,7 +24,7 @@ class IRpcServer {
virtual void RemoveRpc(unsigned int rpc_uid) = 0;
virtual void ProcessRpc(unsigned int local_id, unsigned int call_uid,
- StringRef name, StringRef params,
+ wpi::StringRef name, wpi::StringRef params,
const ConnectionInfo& conn,
SendResponseFunc send_response,
unsigned int rpc_uid) = 0;
diff --git a/ntcore/src/main/native/cpp/IStorage.h b/ntcore/src/main/native/cpp/IStorage.h
index e4c97b52e5..47b3b50b01 100644
--- a/ntcore/src/main/native/cpp/IStorage.h
+++ b/ntcore/src/main/native/cpp/IStorage.h
@@ -50,10 +50,10 @@ class IStorage {
// Filename-based save/load functions. Used both by periodic saves and
// accessible directly via the user API.
- virtual const char* SavePersistent(const Twine& filename,
+ virtual const char* SavePersistent(const wpi::Twine& filename,
bool periodic) const = 0;
virtual const char* LoadPersistent(
- const Twine& filename,
+ const wpi::Twine& filename,
std::function warn) = 0;
};
diff --git a/ntcore/src/main/native/cpp/NetworkConnection.cpp b/ntcore/src/main/native/cpp/NetworkConnection.cpp
index 85957e2318..84c8d981e8 100644
--- a/ntcore/src/main/native/cpp/NetworkConnection.cpp
+++ b/ntcore/src/main/native/cpp/NetworkConnection.cpp
@@ -142,7 +142,7 @@ std::string NetworkConnection::remote_id() const {
return m_remote_id;
}
-void NetworkConnection::set_remote_id(StringRef remote_id) {
+void NetworkConnection::set_remote_id(wpi::StringRef remote_id) {
std::scoped_lock lock(m_remote_id_mutex);
m_remote_id = remote_id;
}
diff --git a/ntcore/src/main/native/cpp/NetworkConnection.h b/ntcore/src/main/native/cpp/NetworkConnection.h
index c7c659993e..69015054c0 100644
--- a/ntcore/src/main/native/cpp/NetworkConnection.h
+++ b/ntcore/src/main/native/cpp/NetworkConnection.h
@@ -76,7 +76,7 @@ class NetworkConnection : public INetworkConnection {
void set_state(State state) final;
std::string remote_id() const;
- void set_remote_id(StringRef remote_id);
+ void set_remote_id(wpi::StringRef remote_id);
uint64_t last_update() const { return m_last_update; }
diff --git a/ntcore/src/main/native/cpp/RpcServer.cpp b/ntcore/src/main/native/cpp/RpcServer.cpp
index d413cd8438..88a53b796d 100644
--- a/ntcore/src/main/native/cpp/RpcServer.cpp
+++ b/ntcore/src/main/native/cpp/RpcServer.cpp
@@ -27,7 +27,7 @@ void RpcServer::RemoveRpc(unsigned int rpc_uid) {
}
void RpcServer::ProcessRpc(unsigned int local_id, unsigned int call_uid,
- StringRef name, StringRef params,
+ wpi::StringRef name, wpi::StringRef params,
const ConnectionInfo& conn,
SendResponseFunc send_response,
unsigned int rpc_uid) {
diff --git a/ntcore/src/main/native/cpp/RpcServer.h b/ntcore/src/main/native/cpp/RpcServer.h
index 4d20c50686..e4d1b1d63d 100644
--- a/ntcore/src/main/native/cpp/RpcServer.h
+++ b/ntcore/src/main/native/cpp/RpcServer.h
@@ -22,8 +22,8 @@ namespace impl {
typedef std::pair RpcIdPair;
struct RpcNotifierData : public RpcAnswer {
- RpcNotifierData(NT_Entry entry_, NT_RpcCall call_, StringRef name_,
- StringRef params_, const ConnectionInfo& conn_,
+ RpcNotifierData(NT_Entry entry_, NT_RpcCall call_, wpi::StringRef name_,
+ wpi::StringRef params_, const ConnectionInfo& conn_,
IRpcServer::SendResponseFunc send_response_)
: RpcAnswer{entry_, call_, name_, params_, conn_},
send_response{std::move(send_response_)} {}
@@ -93,9 +93,9 @@ class RpcServer
unsigned int AddPolled(unsigned int poller_uid);
void RemoveRpc(unsigned int rpc_uid) override;
- void ProcessRpc(unsigned int local_id, unsigned int call_uid, StringRef name,
- StringRef params, const ConnectionInfo& conn,
- SendResponseFunc send_response,
+ void ProcessRpc(unsigned int local_id, unsigned int call_uid,
+ wpi::StringRef name, wpi::StringRef params,
+ const ConnectionInfo& conn, SendResponseFunc send_response,
unsigned int rpc_uid) override;
bool PostRpcResponse(unsigned int local_id, unsigned int call_uid,
diff --git a/ntcore/src/main/native/cpp/Storage.cpp b/ntcore/src/main/native/cpp/Storage.cpp
index 63929fc175..f666976053 100644
--- a/ntcore/src/main/native/cpp/Storage.cpp
+++ b/ntcore/src/main/native/cpp/Storage.cpp
@@ -91,7 +91,7 @@ void Storage::ProcessIncomingEntryAssign(std::shared_ptr msg,
INetworkConnection* conn) {
std::unique_lock lock(m_mutex);
unsigned int id = msg->id();
- StringRef name = msg->str();
+ wpi::StringRef name = msg->str();
Entry* entry;
bool may_need_update = false;
SequenceNumber seq_num(msg->seq_num_uid());
@@ -359,7 +359,7 @@ void Storage::ProcessIncomingExecuteRpc(
unsigned int call_uid = msg->seq_num_uid();
m_rpc_server.ProcessRpc(
entry->local_id, call_uid, entry->name, msg->str(), conn_info,
- [=](StringRef result) {
+ [=](wpi::StringRef result) {
auto c = conn_weak.lock();
if (c) {
c->QueueOutgoing(Message::RpcResponse(id, call_uid, result));
@@ -442,7 +442,7 @@ void Storage::ApplyInitialAssignments(
}
SequenceNumber seq_num(msg->seq_num_uid());
- StringRef name = msg->str();
+ wpi::StringRef name = msg->str();
Entry* entry = GetOrNew(name);
entry->seq_num = seq_num;
@@ -509,7 +509,7 @@ void Storage::ApplyInitialAssignments(
}
}
-std::shared_ptr Storage::GetEntryValue(StringRef name) const {
+std::shared_ptr Storage::GetEntryValue(wpi::StringRef name) const {
std::scoped_lock lock(m_mutex);
auto i = m_entries.find(name);
if (i == m_entries.end()) {
@@ -526,7 +526,7 @@ std::shared_ptr Storage::GetEntryValue(unsigned int local_id) const {
return m_localmap[local_id]->value;
}
-bool Storage::SetDefaultEntryValue(StringRef name,
+bool Storage::SetDefaultEntryValue(wpi::StringRef name,
std::shared_ptr value) {
if (name.empty()) {
return false;
@@ -566,7 +566,7 @@ bool Storage::SetDefaultEntryValue(unsigned int local_id,
return true;
}
-bool Storage::SetEntryValue(StringRef name, std::shared_ptr value) {
+bool Storage::SetEntryValue(wpi::StringRef name, std::shared_ptr value) {
if (name.empty()) {
return true;
}
@@ -664,7 +664,8 @@ void Storage::SetEntryValueImpl(Entry* entry, std::shared_ptr value,
}
}
-void Storage::SetEntryTypeValue(StringRef name, std::shared_ptr value) {
+void Storage::SetEntryTypeValue(wpi::StringRef name,
+ std::shared_ptr value) {
if (name.empty()) {
return;
}
@@ -694,7 +695,7 @@ void Storage::SetEntryTypeValue(unsigned int local_id,
SetEntryValueImpl(entry, value, lock, true);
}
-void Storage::SetEntryFlags(StringRef name, unsigned int flags) {
+void Storage::SetEntryFlags(wpi::StringRef name, unsigned int flags) {
if (name.empty()) {
return;
}
@@ -746,7 +747,7 @@ void Storage::SetEntryFlagsImpl(Entry* entry, unsigned int flags,
}
}
-unsigned int Storage::GetEntryFlags(StringRef name) const {
+unsigned int Storage::GetEntryFlags(wpi::StringRef name) const {
std::scoped_lock lock(m_mutex);
auto i = m_entries.find(name);
if (i == m_entries.end()) {
@@ -763,7 +764,7 @@ unsigned int Storage::GetEntryFlags(unsigned int local_id) const {
return m_localmap[local_id]->flags;
}
-void Storage::DeleteEntry(StringRef name) {
+void Storage::DeleteEntry(wpi::StringRef name) {
std::unique_lock lock(m_mutex);
auto i = m_entries.find(name);
if (i == m_entries.end()) {
@@ -872,9 +873,9 @@ void Storage::DeleteAllEntries() {
dispatcher->QueueOutgoing(Message::ClearEntries(), nullptr, nullptr);
}
-Storage::Entry* Storage::GetOrNew(const Twine& name) {
+Storage::Entry* Storage::GetOrNew(const wpi::Twine& name) {
wpi::SmallString<128> nameBuf;
- StringRef nameStr = name.toStringRef(nameBuf);
+ wpi::StringRef nameStr = name.toStringRef(nameBuf);
auto& entry = m_entries[nameStr];
if (!entry) {
m_localmap.emplace_back(new Entry(nameStr));
@@ -884,7 +885,7 @@ Storage::Entry* Storage::GetOrNew(const Twine& name) {
return entry;
}
-unsigned int Storage::GetEntry(const Twine& name) {
+unsigned int Storage::GetEntry(const wpi::Twine& name) {
if (name.isTriviallyEmpty() ||
(name.isSingleStringRef() && name.getSingleStringRef().empty())) {
return UINT_MAX;
@@ -893,10 +894,10 @@ unsigned int Storage::GetEntry(const Twine& name) {
return GetOrNew(name)->local_id;
}
-std::vector Storage::GetEntries(const Twine& prefix,
+std::vector Storage::GetEntries(const wpi::Twine& prefix,
unsigned int types) {
wpi::SmallString<128> prefixBuf;
- StringRef prefixStr = prefix.toStringRef(prefixBuf);
+ wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
std::scoped_lock lock(m_mutex);
std::vector ids;
for (auto& i : m_entries) {
@@ -969,10 +970,10 @@ uint64_t Storage::GetEntryLastChange(unsigned int local_id) const {
return entry->value->last_change();
}
-std::vector Storage::GetEntryInfo(int inst, const Twine& prefix,
+std::vector Storage::GetEntryInfo(int inst, const wpi::Twine& prefix,
unsigned int types) {
wpi::SmallString<128> prefixBuf;
- StringRef prefixStr = prefix.toStringRef(prefixBuf);
+ wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
std::scoped_lock lock(m_mutex);
std::vector infos;
for (auto& i : m_entries) {
@@ -996,11 +997,11 @@ std::vector Storage::GetEntryInfo(int inst, const Twine& prefix,
}
unsigned int Storage::AddListener(
- const Twine& prefix,
+ const wpi::Twine& prefix,
std::function callback,
unsigned int flags) const {
wpi::SmallString<128> prefixBuf;
- StringRef prefixStr = prefix.toStringRef(prefixBuf);
+ wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
std::scoped_lock lock(m_mutex);
unsigned int uid = m_notifier.Add(callback, prefixStr, flags);
// perform immediate notifications
@@ -1036,10 +1037,10 @@ unsigned int Storage::AddListener(
}
unsigned int Storage::AddPolledListener(unsigned int poller,
- const Twine& prefix,
+ const wpi::Twine& prefix,
unsigned int flags) const {
wpi::SmallString<128> prefixBuf;
- StringRef prefixStr = prefix.toStringRef(prefixBuf);
+ wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
std::scoped_lock lock(m_mutex);
unsigned int uid = m_notifier.AddPolled(poller, prefixStr, flags);
// perform immediate notifications
@@ -1110,11 +1111,11 @@ bool Storage::GetPersistentEntries(
}
bool Storage::GetEntries(
- const Twine& prefix,
+ const wpi::Twine& prefix,
std::vector>>* entries)
const {
wpi::SmallString<128> prefixBuf;
- StringRef prefixStr = prefix.toStringRef(prefixBuf);
+ wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
// copy values out of storage as quickly as possible so lock isn't held
{
std::scoped_lock lock(m_mutex);
@@ -1138,7 +1139,7 @@ bool Storage::GetEntries(
return true;
}
-void Storage::CreateRpc(unsigned int local_id, StringRef def,
+void Storage::CreateRpc(unsigned int local_id, wpi::StringRef def,
unsigned int rpc_uid) {
std::unique_lock lock(m_mutex);
if (local_id >= m_localmap.size()) {
@@ -1183,7 +1184,7 @@ void Storage::CreateRpc(unsigned int local_id, StringRef def,
}
}
-unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
+unsigned int Storage::CallRpc(unsigned int local_id, wpi::StringRef params) {
std::unique_lock lock(m_mutex);
if (local_id >= m_localmap.size()) {
return 0;
@@ -1201,7 +1202,7 @@ unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
unsigned int call_uid = entry->rpc_call_uid;
auto msg = Message::ExecuteRpc(entry->id, call_uid, params);
- StringRef name{entry->name};
+ wpi::StringRef name{entry->name};
if (m_server) {
// RPCs are unlikely to be used locally on the server, but handle it
@@ -1217,7 +1218,7 @@ unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
unsigned int call_uid = msg->seq_num_uid();
m_rpc_server.ProcessRpc(
local_id, call_uid, name, msg->str(), conn_info,
- [=](StringRef result) {
+ [=](wpi::StringRef result) {
std::scoped_lock lock(m_mutex);
m_rpc_results.insert(
std::make_pair(RpcIdPair{local_id, call_uid}, result));
diff --git a/ntcore/src/main/native/cpp/Storage.h b/ntcore/src/main/native/cpp/Storage.h
index 73bc0c617c..96968b4573 100644
--- a/ntcore/src/main/native/cpp/Storage.h
+++ b/ntcore/src/main/native/cpp/Storage.h
@@ -72,35 +72,35 @@ class Storage : public IStorage {
// User functions. These are the actual implementations of the corresponding
// user API functions in ntcore_cpp.
- std::shared_ptr GetEntryValue(StringRef name) const;
+ std::shared_ptr GetEntryValue(wpi::StringRef name) const;
std::shared_ptr GetEntryValue(unsigned int local_id) const;
- bool SetDefaultEntryValue(StringRef name, std::shared_ptr value);
+ bool SetDefaultEntryValue(wpi::StringRef name, std::shared_ptr value);
bool SetDefaultEntryValue(unsigned int local_id,
std::shared_ptr value);
- bool SetEntryValue(StringRef name, std::shared_ptr value);
+ bool SetEntryValue(wpi::StringRef name, std::shared_ptr value);
bool SetEntryValue(unsigned int local_id, std::shared_ptr value);
- void SetEntryTypeValue(StringRef name, std::shared_ptr value);
+ void SetEntryTypeValue(wpi::StringRef name, std::shared_ptr value);
void SetEntryTypeValue(unsigned int local_id, std::shared_ptr value);
- void SetEntryFlags(StringRef name, unsigned int flags);
+ void SetEntryFlags(wpi::StringRef name, unsigned int flags);
void SetEntryFlags(unsigned int local_id, unsigned int flags);
- unsigned int GetEntryFlags(StringRef name) const;
+ unsigned int GetEntryFlags(wpi::StringRef name) const;
unsigned int GetEntryFlags(unsigned int local_id) const;
- void DeleteEntry(StringRef name);
+ void DeleteEntry(wpi::StringRef name);
void DeleteEntry(unsigned int local_id);
void DeleteAllEntries();
- std::vector GetEntryInfo(int inst, const Twine& prefix,
+ std::vector GetEntryInfo(int inst, const wpi::Twine& prefix,
unsigned int types);
unsigned int AddListener(
- const Twine& prefix,
+ const wpi::Twine& prefix,
std::function callback,
unsigned int flags) const;
unsigned int AddListener(
@@ -108,14 +108,16 @@ class Storage : public IStorage {
std::function callback,
unsigned int flags) const;
- unsigned int AddPolledListener(unsigned int poller_uid, const Twine& prefix,
+ unsigned int AddPolledListener(unsigned int poller_uid,
+ const wpi::Twine& prefix,
unsigned int flags) const;
unsigned int AddPolledListener(unsigned int poller_uid, unsigned int local_id,
unsigned int flags) const;
// Index-only
- unsigned int GetEntry(const Twine& name);
- std::vector GetEntries(const Twine& prefix, unsigned int types);
+ unsigned int GetEntry(const wpi::Twine& name);
+ std::vector GetEntries(const wpi::Twine& prefix,
+ unsigned int types);
EntryInfo GetEntryInfo(int inst, unsigned int local_id) const;
std::string GetEntryName(unsigned int local_id) const;
NT_Type GetEntryType(unsigned int local_id) const;
@@ -123,29 +125,32 @@ class Storage : public IStorage {
// Filename-based save/load functions. Used both by periodic saves and
// accessible directly via the user API.
- const char* SavePersistent(const Twine& filename,
+ const char* SavePersistent(const wpi::Twine& filename,
bool periodic) const override;
const char* LoadPersistent(
- const Twine& filename,
+ const wpi::Twine& filename,
std::function warn) override;
- const char* SaveEntries(const Twine& filename, const Twine& prefix) const;
+ const char* SaveEntries(const wpi::Twine& filename,
+ const wpi::Twine& prefix) const;
const char* LoadEntries(
- const Twine& filename, const Twine& prefix,
+ const wpi::Twine& filename, const wpi::Twine& prefix,
std::function warn);
// Stream-based save/load functions (exposed for testing purposes). These
// implement the guts of the filename-based functions.
void SavePersistent(wpi::raw_ostream& os, bool periodic) const;
- bool LoadEntries(wpi::raw_istream& is, const Twine& prefix, bool persistent,
+ bool LoadEntries(wpi::raw_istream& is, const wpi::Twine& prefix,
+ bool persistent,
std::function warn);
- void SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const;
+ void SaveEntries(wpi::raw_ostream& os, const wpi::Twine& prefix) const;
// RPC configuration needs to come through here as RPC definitions are
// actually special Storage value types.
- void CreateRpc(unsigned int local_id, StringRef def, unsigned int rpc_uid);
- unsigned int CallRpc(unsigned int local_id, StringRef params);
+ void CreateRpc(unsigned int local_id, wpi::StringRef def,
+ unsigned int rpc_uid);
+ unsigned int CallRpc(unsigned int local_id, wpi::StringRef params);
bool GetRpcResult(unsigned int local_id, unsigned int call_uid,
std::string* result);
bool GetRpcResult(unsigned int local_id, unsigned int call_uid,
@@ -237,7 +242,7 @@ class Storage : public IStorage {
bool periodic,
std::vector>>* entries)
const;
- bool GetEntries(const Twine& prefix,
+ bool GetEntries(const wpi::Twine& prefix,
std::vector>>*
entries) const;
void SetEntryValueImpl(Entry* entry, std::shared_ptr value,
@@ -251,7 +256,7 @@ class Storage : public IStorage {
template
void DeleteAllEntriesImpl(bool local, F should_delete);
void DeleteAllEntriesImpl(bool local);
- Entry* GetOrNew(const Twine& name);
+ Entry* GetOrNew(const wpi::Twine& name);
};
} // namespace nt
diff --git a/ntcore/src/main/native/cpp/Storage_load.cpp b/ntcore/src/main/native/cpp/Storage_load.cpp
index 956321d60f..04904aaa03 100644
--- a/ntcore/src/main/native/cpp/Storage_load.cpp
+++ b/ntcore/src/main/native/cpp/Storage_load.cpp
@@ -27,7 +27,7 @@ class LoadPersistentImpl {
LoadPersistentImpl(wpi::raw_istream& is, WarnFunc warn)
: m_is(is), m_warn(std::move(warn)) {}
- bool Load(StringRef prefix, std::vector* entries);
+ bool Load(wpi::StringRef prefix, std::vector* entries);
private:
bool ReadLine();
@@ -138,7 +138,8 @@ static wpi::StringRef UnescapeString(wpi::StringRef source,
return wpi::StringRef{buf.data(), buf.size()};
}
-bool LoadPersistentImpl::Load(StringRef prefix, std::vector* entries) {
+bool LoadPersistentImpl::Load(wpi::StringRef prefix,
+ std::vector* entries) {
if (!ReadHeader()) {
return false; // header
}
@@ -373,10 +374,10 @@ std::shared_ptr LoadPersistentImpl::ReadStringArrayValue() {
}
bool Storage::LoadEntries(
- wpi::raw_istream& is, const Twine& prefix, bool persistent,
+ wpi::raw_istream& is, const wpi::Twine& prefix, bool persistent,
std::function warn) {
wpi::SmallString<128> prefixBuf;
- StringRef prefixStr = prefix.toStringRef(prefixBuf);
+ wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
// entries to add
std::vector entries;
@@ -456,7 +457,7 @@ bool Storage::LoadEntries(
}
const char* Storage::LoadPersistent(
- const Twine& filename,
+ const wpi::Twine& filename,
std::function warn) {
std::error_code ec;
wpi::raw_fd_istream is(filename, ec);
@@ -470,7 +471,7 @@ const char* Storage::LoadPersistent(
}
const char* Storage::LoadEntries(
- const Twine& filename, const Twine& prefix,
+ const wpi::Twine& filename, const wpi::Twine& prefix,
std::function warn) {
std::error_code ec;
wpi::raw_fd_istream is(filename, ec);
diff --git a/ntcore/src/main/native/cpp/Storage_save.cpp b/ntcore/src/main/native/cpp/Storage_save.cpp
index 113cd4a5ba..e6eff1862d 100644
--- a/ntcore/src/main/native/cpp/Storage_save.cpp
+++ b/ntcore/src/main/native/cpp/Storage_save.cpp
@@ -190,7 +190,7 @@ void Storage::SavePersistent(wpi::raw_ostream& os, bool periodic) const {
SavePersistentImpl(os).Save(entries);
}
-const char* Storage::SavePersistent(const Twine& filename,
+const char* Storage::SavePersistent(const wpi::Twine& filename,
bool periodic) const {
wpi::SmallString<128> fn;
filename.toVector(fn);
@@ -240,7 +240,8 @@ done:
return err;
}
-void Storage::SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const {
+void Storage::SaveEntries(wpi::raw_ostream& os,
+ const wpi::Twine& prefix) const {
std::vector entries;
if (!GetEntries(prefix, &entries)) {
return;
@@ -248,8 +249,8 @@ void Storage::SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const {
SavePersistentImpl(os).Save(entries);
}
-const char* Storage::SaveEntries(const Twine& filename,
- const Twine& prefix) const {
+const char* Storage::SaveEntries(const wpi::Twine& filename,
+ const wpi::Twine& prefix) const {
wpi::SmallString<128> fn;
filename.toVector(fn);
wpi::SmallString<128> tmp = fn;
diff --git a/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp b/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp
index f28adeca4e..75f9c713eb 100644
--- a/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp
+++ b/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp
@@ -1549,7 +1549,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_startClient__I_3Ljava_lang_Str
}
std::vector names;
- std::vector> servers;
+ std::vector> servers;
names.reserve(len);
servers.reserve(len);
for (int i = 0; i < len; ++i) {
@@ -1561,7 +1561,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_startClient__I_3Ljava_lang_Str
}
names.emplace_back(JStringRef{env, elem}.str());
servers.emplace_back(
- std::make_pair(nt::StringRef(names.back()), portInts[i]));
+ std::make_pair(wpi::StringRef(names.back()), portInts[i]));
}
env->ReleaseIntArrayElements(ports, portInts, JNI_ABORT);
nt::StartClient(inst, servers);
@@ -1636,7 +1636,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_setServer__I_3Ljava_lang_Strin
}
std::vector