mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[hal] Add high level way of getting systemserver NT instance (#7683)
This commit is contained in:
24
hal/src/main/native/cpp/jni/SystemServerJNI.cpp
Normal file
24
hal/src/main/native/cpp/jni/SystemServerJNI.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// 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 <jni.h>
|
||||
|
||||
#include "edu_wpi_first_hal_SystemServerJNI.h"
|
||||
#include "hal/SystemServer.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_SystemServerJNI
|
||||
* Method: getSystemServerHandle
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_SystemServerJNI_getSystemServerHandle
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HAL_GetSystemServerHandle();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
17
hal/src/main/native/include/hal/SystemServer.h
Normal file
17
hal/src/main/native/include/hal/SystemServer.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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 <ntcore_c.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
NT_Inst HAL_GetSystemServerHandle(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
12
hal/src/main/native/sim/SystemServer.cpp
Normal file
12
hal/src/main/native/sim/SystemServer.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
// 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 "hal/SystemServer.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
NT_Inst HAL_GetSystemServerHandle(void) {
|
||||
return 0;
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "SystemServer.h"
|
||||
#include "SystemServerInternal.h"
|
||||
#include "hal/DriverStation.h"
|
||||
#include "hal/Errors.h"
|
||||
#include "hal/proto/ControlData.h"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "CANInternal.h"
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "SystemServer.h"
|
||||
#include "SystemServerInternal.h"
|
||||
#include "hal/DriverStation.h"
|
||||
#include "hal/Errors.h"
|
||||
#include "hal/Notifier.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <atomic>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "SystemServer.h"
|
||||
#include "SystemServerInternal.h"
|
||||
|
||||
namespace hal {
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
#include "SystemServer.h"
|
||||
#include "hal/SystemServer.h"
|
||||
|
||||
#include "SystemServerInternal.h"
|
||||
#include "mrc/NtNetComm.h"
|
||||
|
||||
namespace hal {
|
||||
@@ -33,3 +34,10 @@ nt::NetworkTableInstance GetSystemServer() {
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
|
||||
extern "C" {
|
||||
|
||||
NT_Inst HAL_GetSystemServerHandle(void) {
|
||||
return hal::ServerInstance.GetHandle();
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user