-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add high level way of getting systemserver nt instance #7683
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aec64f3
Add high level way of getting systemserver nt instance
ThadHouse ba4e26d
Fix generation
ThadHouse fca9abe
Bad generator
ThadHouse c649c7a
Add ntcore to cmake hal
ThadHouse ae2d19a
Formatting
ThadHouse 74c920c
More build fixes
ThadHouse c090f5a
Merge branch '2027' into systemserverhandle
ThadHouse 1538f58
Fix bazel and other things
ThadHouse 74ad821
1 more format
ThadHouse d8c4fc0
Ugh formatting
ThadHouse 5c1a06f
1 more herb fix
ThadHouse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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; | ||
|
||
/** | ||
* SystemServer JNI Functions. | ||
* | ||
* @see "SystemServer.h" | ||
*/ | ||
public class SystemServerJNI extends JNIWrapper { | ||
/** | ||
* Gets the system server NT handle. | ||
* | ||
* @return The system server NT handle | ||
* @see "HAL_GetSystemServerHandle" | ||
*/ | ||
public static native int getSystemServerHandle(); | ||
|
||
/** Utility class. */ | ||
private SystemServerJNI() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
ntcore/src/generated/main/java/edu/wpi/first/networktables/NetworkTableInstance.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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 "frc/SystemServer.h" | ||
|
||
#include <hal/SystemServer.h> | ||
|
||
namespace frc { | ||
|
||
nt::NetworkTableInstance SystemServer::GetSystemServer() { | ||
return nt::NetworkTableInstance{HAL_GetSystemServerHandle()}; | ||
} | ||
|
||
} // namespace frc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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 <networktables/NetworkTableInstance.h> | ||
|
||
namespace frc { | ||
|
||
class SystemServer { | ||
public: | ||
SystemServer() = delete; | ||
|
||
static nt::NetworkTableInstance GetSystemServer(); | ||
}; | ||
|
||
} // namespace frc |
23 changes: 23 additions & 0 deletions
23
wpilibj/src/main/java/edu/wpi/first/wpilibj/SystemServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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; | ||
|
||
import edu.wpi.first.hal.SystemServerJNI; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
|
||
/** Class to get system server NT instance. */ | ||
public final class SystemServer { | ||
/** | ||
* Gets the system server NT Instance. | ||
* | ||
* @return NT Instance | ||
*/ | ||
public static NetworkTableInstance getSystemServer() { | ||
return NetworkTableInstance.fromNativeHandle(SystemServerJNI.getSystemServerHandle()); | ||
} | ||
|
||
/** Utility Class. */ | ||
private SystemServer() {} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually an interesting future conversation... but yes, makes sense for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do need to have that conversation at some point. But for now we just need something working slightly better.
The main reason I'm adding this is I'm probably going to put the IMU code at the high level, purely because I don't want to make the HAL depend on wpimath, and the IMU gives values in a Quaternion.