[hal] Add initial SystemServer support (#7463)

This commit is contained in:
Thad House
2024-12-01 04:31:26 +00:00
committed by GitHub
parent 82132c3272
commit c51f65bd4f
39 changed files with 1658 additions and 83 deletions

View File

@@ -19,6 +19,13 @@ def main():
subprocess.run(
[sys.executable, f"{REPO_ROOT}/hal/generate_usage_reporting.py"], check=True
)
subprocess.run(
[
sys.executable,
f"{REPO_ROOT}/hal/generate_nanopb.py",
],
check=True,
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/ntcore/generate_topics.py"], check=True
)

View File

@@ -187,7 +187,7 @@ model {
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib library: 'cscore', linkage: 'shared'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -93,7 +93,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -64,30 +64,22 @@ def simProjects = ['halsim_gui']
deploy {
targets {
roborio(RemoteTarget) {
directory = '/home/lvuser'
systemcore(RemoteTarget) {
directory = '/home/systemcore'
maxChannels = 4
locations {
ssh(SshDeployLocation) {
address = "172.22.11.2"
user = 'admin'
password = ''
address = "robot.local"
user = 'systemcore'
password = 'systemcorerules2027'
ipv6 = false
}
}
def remote = it
artifacts.registerFactory(WPIJREArtifact) {
return objects.newInstance(WPIJREArtifact, it, remote)
}
artifacts {
all {
predeploy << { ctx ->
ctx.execute('. /etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t 2> /dev/null')
ctx.execute("sed -i -e 's/\"exec /\"/' /usr/local/frc/bin/frcRunRobot.sh")
}
postdeploy << { ctx ->
ctx.execute("sync")
ctx.execute("ldconfig")
@@ -95,43 +87,40 @@ deploy {
}
developerRobotCpp(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
libraryDirectory = '/home/systemcore/frc/third-party/lib'
def excludes = getLibraryFilter().getExcludes()
excludes.add('**/*.so.debug')
excludes.add('**/*.so.*.debug')
postdeploy << { ctx ->
ctx.execute("echo '/home/lvuser/developerRobotCpp' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCpp\"")
ctx.execute("echo '/home/systemcore/developerRobotCpp' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/systemcore/developerRobotCpp\"")
ctx.execute('chmod +x developerRobotCpp')
}
}
developerRobotCppStatic(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
libraryDirectory = '/home/systemcore/frc/third-party/lib'
postdeploy << { ctx ->
ctx.execute("echo '/home/lvuser/developerRobotCppStatic' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCppStatic\"")
ctx.execute("echo '/home/systemcore/developerRobotCppStatic' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/systemcore/developerRobotCppStatic\"")
ctx.execute('chmod +x developerRobotCppStatic')
}
}
developerRobotCppJava(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
libraryDirectory = '/home/systemcore/frc/third-party/lib'
def excludes = getLibraryFilter().getExcludes()
excludes.add('**/*.so.debug')
excludes.add('**/*.so.*.debug')
}
jre(WPIJREArtifact) {
}
developerRobotJava(JavaArtifact) {
jarTask = shadowJar
postdeploy << { ctx ->
ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseSerialGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/lvuser/developerRobot-all.jar' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
ctx.execute("echo '/usr/bin/java -XX:+UseG1GC -Djava.library.path=/home/systemcore/frc/third-party/lib -jar /home/systemcore/developerRobot-all.jar' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
}
}
}
@@ -141,23 +130,23 @@ deploy {
tasks.register('deployJava') {
try {
dependsOn tasks.named('deployjreroborio')
dependsOn tasks.named('deploydeveloperRobotJavaroborio')
dependsOn tasks.named('deploydeveloperRobotCppJavaroborio') // Deploying shared C++ is how to get the Java shared libraries.
dependsOn tasks.named('deployjresystemcore')
dependsOn tasks.named('deploydeveloperRobotJavasystemcore')
dependsOn tasks.named('deploydeveloperRobotCppJavasystemcore') // Deploying shared C++ is how to get the Java shared libraries.
} catch (ignored) {
}
}
tasks.register('deployShared') {
try {
dependsOn tasks.named('deploydeveloperRobotCpproborio')
dependsOn tasks.named('deploydeveloperRobotCppsystemcore')
} catch (ignored) {
}
}
tasks.register('deployStatic') {
try {
dependsOn tasks.named('deploydeveloperRobotCppStaticroborio')
dependsOn tasks.named('deploydeveloperRobotCppStaticsystemcore')
} catch (ignored) {
}
}
@@ -179,10 +168,10 @@ model {
}
}
binaries.all { binary ->
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
if (binary.buildType.name == 'debug') {
deploy.targets.roborio.artifacts.developerRobotCpp.binary = binary
deploy.targets.roborio.artifacts.developerRobotCppJava.binary = binary
deploy.targets.systemcore.artifacts.developerRobotCpp.binary = binary
deploy.targets.systemcore.artifacts.developerRobotCppJava.binary = binary
}
}
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
@@ -201,14 +190,10 @@ model {
project(':hal').addHalJniDependency(binary)
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
} else {
def systemArch = getCurrentArch()
if (binary.targetPlatform.name == systemArch) {
simProjects.each {
lib project: ":simulation:$it", library: it, linkage: 'shared'
}
def systemArch = getCurrentArch()
if (binary.targetPlatform.name == systemArch) {
simProjects.each {
lib project: ":simulation:$it", library: it, linkage: 'shared'
}
}
}
@@ -229,9 +214,9 @@ model {
}
}
binaries.all { binary ->
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
if (binary.buildType.name == 'debug') {
deploy.targets.roborio.artifacts.developerRobotCppStatic.binary = binary
deploy.targets.systemcore.artifacts.developerRobotCppStatic.binary = binary
}
}
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
@@ -244,9 +229,6 @@ model {
project(':hal').addHalDependency(binary, 'static')
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
}
}
@@ -302,20 +284,6 @@ model {
}
}
}
installAthena(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCpp') {
dependsOn it.tasks.install
}
}
}
installAthenaStatic(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCppStatic') {
dependsOn it.tasks.install
}
}
}
installSystemCore(Task) {
$.binaries.each {
@@ -324,6 +292,7 @@ model {
}
}
}
installSystemCoreStatic(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore && it.component.name == 'developerRobotCppStatic') {

View File

@@ -85,7 +85,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
@@ -112,7 +112,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
@@ -153,7 +153,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -17,6 +17,7 @@ generatedFileExclude {
hal/src/main/native/systemcore/ctre/
hal/src/main/native/systemcore/rev/
UsageReporting\.h$
src/generated/main/native/cpp
}
modifiableFileExclude {

View File

@@ -9,6 +9,22 @@ cc_library(
visibility = ["//hal:__subpackages__"],
)
cc_library(
name = "mrc_cc_headers",
hdrs = glob(["src/mrc/include/**"]),
includes = ["src/mrc/include"],
strip_include_prefix = "src/mrc/include",
visibility = ["//hal:__subpackages__"],
)
cc_library(
name = "generated_mrc_cc_headers",
hdrs = glob(["src/generated/main/native/cpp/mrc/protobuf/**"]),
includes = ["src/generated/main/native/cpp/mrc/protobuf"],
strip_include_prefix = "src/generated/main/native/cpp/mrc/protobuf",
visibility = ["//hal:__subpackages__"],
)
filegroup(
name = "generated_java",
srcs = glob(["src/generated/main/java/**/*.java"]),
@@ -39,7 +55,10 @@ filegroup(
cc_library(
name = "wpiHal.static",
srcs = [":platform-srcs"] + glob(
["src/main/native/cpp/**"],
[
"src/main/native/cpp/**",
"src/generated/main/native/cpp/**",
],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
@@ -48,6 +67,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":generated_cc_headers",
":mrc_cc_headers",
":generated_mrc_cc_headers",
"//wpiutil:wpiutil.static",
] + HAL_DEPS,
)

View File

@@ -36,10 +36,11 @@ ext {
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
srcDir 'src/mrc/include'
}
}
}
} else {
} else {
it.sources {
simCpp(CppSourceSet) {
source {
@@ -49,10 +50,22 @@ ext {
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
srcDir 'src/mrc/include'
}
}
}
}
it.sources {
nanopbCpp(CppSourceSet) {
source {
srcDirs 'src/generated/main/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/generated/main/native/cpp'
}
}
}
}
exeSplitSetup = {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
@@ -107,3 +120,32 @@ model {
}
}
}
model {
components {
all {
it.sources.each {
it.exportedHeaders {
srcDirs 'src/mrc/include',
'src/generated/main/native/cpp/mrc/protobuf'
}
}
}
}
binaries {
all {
if (!it.buildable || !(it instanceof NativeBinarySpec)) {
return
}
if (it.component.name == "${nativeName}JNI") {
project(':ntcore').addNtcoreDependency(it, 'static')
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
} else {
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
}
}
}

88
hal/generate_nanopb.py Normal file
View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
# 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.
import argparse
import os
import shutil
import subprocess
import sys
from pathlib import Path
def generate_nanopb(nanopb: Path, output_directory: Path, proto_dir: Path):
shutil.rmtree(output_directory.absolute(), ignore_errors=True)
os.makedirs(output_directory.absolute())
proto_files = proto_dir.glob("*.proto")
for path in proto_files:
absolute_filename = path.absolute()
subprocess.run(
[
sys.executable,
nanopb,
f"-I{absolute_filename.parent}",
f"-D{output_directory.absolute()}",
"-S.cpp",
"-e.npb",
absolute_filename,
],
check=True,
)
java_files = (output_directory).glob("*")
for java_file in java_files:
with (java_file).open(encoding="utf-8") as f:
content = f.read()
java_file.write_text(
"// Copyright (c) FIRST and other WPILib contributors.\n// Open Source Software; you can modify and/or share it under the terms of\n// the WPILib BSD license file in the root directory of this project.\n"
+ content,
encoding="utf-8",
newline="\n",
)
def main():
script_path = Path(__file__).resolve()
dirname = script_path.parent
root_path = dirname.parent
nanopb_path = os.path.join(
root_path,
"wpiutil",
"src",
"main",
"native",
"thirdparty",
"nanopb",
"generator",
"nanopb_generator.py",
)
parser = argparse.ArgumentParser()
parser.add_argument(
"--nanopb",
help="Nanopb generator command",
default=nanopb_path,
)
parser.add_argument(
"--output_directory",
help="Optional. If set, will output the generated files to this directory, otherwise it will use a path relative to the script",
default=dirname / "src/generated/main/native/cpp/mrc/protobuf",
type=Path,
)
parser.add_argument(
"--proto_directory",
help="Optional. If set, will use this directory to glob for protobuf files",
default=dirname / "src/mrc/proto",
type=Path,
)
args = parser.parse_args()
generate_nanopb(args.nanopb, args.output_directory, args.proto_directory)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,305 @@
// 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.
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.9 */
#include "MrcComm.npb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
#include <span>
#include <string_view>
static const uint8_t file_descriptor[] {
0x0a,0x0d,0x4d,0x72,0x63,0x43,0x6f,0x6d,0x6d,0x2e,
0x70,0x72,0x6f,0x74,0x6f,0x12,0x09,0x6d,0x72,0x63,
0x2e,0x70,0x72,0x6f,0x74,0x6f,0x22,0x7a,0x0a,0x14,
0x50,0x72,0x6f,0x74,0x6f,0x62,0x75,0x66,0x4a,0x6f,
0x79,0x73,0x74,0x69,0x63,0x6b,0x44,0x61,0x74,0x61,
0x12,0x20,0x0a,0x0b,0x42,0x75,0x74,0x74,0x6f,0x6e,
0x43,0x6f,0x75,0x6e,0x74,0x18,0x01,0x20,0x01,0x28,
0x0d,0x52,0x0b,0x42,0x75,0x74,0x74,0x6f,0x6e,0x43,
0x6f,0x75,0x6e,0x74,0x12,0x18,0x0a,0x07,0x42,0x75,
0x74,0x74,0x6f,0x6e,0x73,0x18,0x02,0x20,0x01,0x28,
0x07,0x52,0x07,0x42,0x75,0x74,0x74,0x6f,0x6e,0x73,
0x12,0x12,0x0a,0x04,0x41,0x78,0x65,0x73,0x18,0x03,
0x20,0x03,0x28,0x02,0x52,0x04,0x41,0x78,0x65,0x73,
0x12,0x12,0x0a,0x04,0x50,0x4f,0x56,0x73,0x18,0x04,
0x20,0x03,0x28,0x11,0x52,0x04,0x50,0x4f,0x56,0x73,
0x22,0xac,0x01,0x0a,0x13,0x50,0x72,0x6f,0x74,0x6f,
0x62,0x75,0x66,0x43,0x6f,0x6e,0x74,0x72,0x6f,0x6c,
0x44,0x61,0x74,0x61,0x12,0x20,0x0a,0x0b,0x43,0x6f,
0x6e,0x74,0x72,0x6f,0x6c,0x57,0x6f,0x72,0x64,0x18,
0x01,0x20,0x01,0x28,0x0d,0x52,0x0b,0x43,0x6f,0x6e,
0x74,0x72,0x6f,0x6c,0x57,0x6f,0x72,0x64,0x12,0x1c,
0x0a,0x09,0x4d,0x61,0x74,0x63,0x68,0x54,0x69,0x6d,
0x65,0x18,0x02,0x20,0x01,0x28,0x02,0x52,0x09,0x4d,
0x61,0x74,0x63,0x68,0x54,0x69,0x6d,0x65,0x12,0x3d,
0x0a,0x09,0x4a,0x6f,0x79,0x73,0x74,0x69,0x63,0x6b,
0x73,0x18,0x03,0x20,0x03,0x28,0x0b,0x32,0x1f,0x2e,
0x6d,0x72,0x63,0x2e,0x70,0x72,0x6f,0x74,0x6f,0x2e,
0x50,0x72,0x6f,0x74,0x6f,0x62,0x75,0x66,0x4a,0x6f,
0x79,0x73,0x74,0x69,0x63,0x6b,0x44,0x61,0x74,0x61,
0x52,0x09,0x4a,0x6f,0x79,0x73,0x74,0x69,0x63,0x6b,
0x73,0x12,0x16,0x0a,0x06,0x4f,0x70,0x4d,0x6f,0x64,
0x65,0x18,0x04,0x20,0x01,0x28,0x09,0x52,0x06,0x4f,
0x70,0x4d,0x6f,0x64,0x65,0x22,0xd8,0x01,0x0a,0x1a,
0x50,0x72,0x6f,0x74,0x6f,0x62,0x75,0x66,0x4a,0x6f,
0x79,0x73,0x74,0x69,0x63,0x6b,0x44,0x65,0x73,0x63,
0x72,0x69,0x70,0x74,0x6f,0x72,0x12,0x22,0x0a,0x0c,
0x4a,0x6f,0x79,0x73,0x74,0x69,0x63,0x6b,0x4e,0x61,
0x6d,0x65,0x18,0x01,0x20,0x01,0x28,0x09,0x52,0x0c,
0x4a,0x6f,0x79,0x73,0x74,0x69,0x63,0x6b,0x4e,0x61,
0x6d,0x65,0x12,0x1c,0x0a,0x09,0x41,0x78,0x69,0x73,
0x54,0x79,0x70,0x65,0x73,0x18,0x02,0x20,0x03,0x28,
0x05,0x52,0x09,0x41,0x78,0x69,0x73,0x54,0x79,0x70,
0x65,0x73,0x12,0x16,0x0a,0x06,0x49,0x73,0x58,0x62,
0x6f,0x78,0x18,0x03,0x20,0x01,0x28,0x08,0x52,0x06,
0x49,0x73,0x58,0x62,0x6f,0x78,0x12,0x22,0x0a,0x0c,
0x4a,0x6f,0x79,0x73,0x74,0x69,0x63,0x6b,0x54,0x79,
0x70,0x65,0x18,0x04,0x20,0x01,0x28,0x05,0x52,0x0c,
0x4a,0x6f,0x79,0x73,0x74,0x69,0x63,0x6b,0x54,0x79,
0x70,0x65,0x12,0x20,0x0a,0x0b,0x42,0x75,0x74,0x74,
0x6f,0x6e,0x43,0x6f,0x75,0x6e,0x74,0x18,0x05,0x20,
0x01,0x28,0x05,0x52,0x0b,0x42,0x75,0x74,0x74,0x6f,
0x6e,0x43,0x6f,0x75,0x6e,0x74,0x12,0x1a,0x0a,0x08,
0x50,0x6f,0x76,0x43,0x6f,0x75,0x6e,0x74,0x18,0x06,
0x20,0x01,0x28,0x05,0x52,0x08,0x50,0x6f,0x76,0x43,
0x6f,0x75,0x6e,0x74,0x22,0x7e,0x0a,0x1a,0x50,0x72,
0x6f,0x74,0x6f,0x62,0x75,0x66,0x4a,0x6f,0x79,0x73,
0x74,0x69,0x63,0x6b,0x4f,0x75,0x74,0x70,0x75,0x74,
0x44,0x61,0x74,0x61,0x12,0x1e,0x0a,0x0a,0x48,0x69,
0x64,0x4f,0x75,0x74,0x70,0x75,0x74,0x73,0x18,0x01,
0x20,0x01,0x28,0x07,0x52,0x0a,0x48,0x69,0x64,0x4f,
0x75,0x74,0x70,0x75,0x74,0x73,0x12,0x1e,0x0a,0x0a,
0x4c,0x65,0x66,0x74,0x52,0x75,0x6d,0x62,0x6c,0x65,
0x18,0x02,0x20,0x01,0x28,0x02,0x52,0x0a,0x4c,0x65,
0x66,0x74,0x52,0x75,0x6d,0x62,0x6c,0x65,0x12,0x20,
0x0a,0x0b,0x52,0x69,0x67,0x68,0x74,0x52,0x75,0x6d,
0x62,0x6c,0x65,0x18,0x03,0x20,0x01,0x28,0x02,0x52,
0x0b,0x52,0x69,0x67,0x68,0x74,0x52,0x75,0x6d,0x62,
0x6c,0x65,0x22,0x5f,0x0a,0x13,0x50,0x72,0x6f,0x74,
0x6f,0x62,0x75,0x66,0x56,0x65,0x72,0x73,0x69,0x6f,
0x6e,0x49,0x6e,0x66,0x6f,0x12,0x1a,0x0a,0x08,0x44,
0x65,0x76,0x69,0x63,0x65,0x49,0x64,0x18,0x01,0x20,
0x01,0x28,0x07,0x52,0x08,0x44,0x65,0x76,0x69,0x63,
0x65,0x49,0x64,0x12,0x12,0x0a,0x04,0x4e,0x61,0x6d,
0x65,0x18,0x02,0x20,0x01,0x28,0x09,0x52,0x04,0x4e,
0x61,0x6d,0x65,0x12,0x18,0x0a,0x07,0x56,0x65,0x72,
0x73,0x69,0x6f,0x6e,0x18,0x03,0x20,0x01,0x28,0x09,
0x52,0x07,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x22,
0x95,0x01,0x0a,0x11,0x50,0x72,0x6f,0x74,0x6f,0x62,
0x75,0x66,0x4d,0x61,0x74,0x63,0x68,0x49,0x6e,0x66,
0x6f,0x12,0x1c,0x0a,0x09,0x45,0x76,0x65,0x6e,0x74,
0x4e,0x61,0x6d,0x65,0x18,0x01,0x20,0x01,0x28,0x09,
0x52,0x09,0x45,0x76,0x65,0x6e,0x74,0x4e,0x61,0x6d,
0x65,0x12,0x20,0x0a,0x0b,0x4d,0x61,0x74,0x63,0x68,
0x4e,0x75,0x6d,0x62,0x65,0x72,0x18,0x02,0x20,0x01,
0x28,0x05,0x52,0x0b,0x4d,0x61,0x74,0x63,0x68,0x4e,
0x75,0x6d,0x62,0x65,0x72,0x12,0x22,0x0a,0x0c,0x52,
0x65,0x70,0x6c,0x61,0x79,0x4e,0x75,0x6d,0x62,0x65,
0x72,0x18,0x03,0x20,0x01,0x28,0x05,0x52,0x0c,0x52,
0x65,0x70,0x6c,0x61,0x79,0x4e,0x75,0x6d,0x62,0x65,
0x72,0x12,0x1c,0x0a,0x09,0x4d,0x61,0x74,0x63,0x68,
0x54,0x79,0x70,0x65,0x18,0x04,0x20,0x01,0x28,0x05,
0x52,0x09,0x4d,0x61,0x74,0x63,0x68,0x54,0x79,0x70,
0x65,0x42,0x0f,0x0a,0x0d,0x63,0x6f,0x6d,0x2e,0x6d,
0x72,0x63,0x2e,0x70,0x72,0x6f,0x74,0x6f,0x4a,0xa1,
0x0c,0x0a,0x06,0x12,0x04,0x00,0x00,0x2e,0x01,0x0a,
0x08,0x0a,0x01,0x0c,0x12,0x03,0x00,0x00,0x12,0x0a,
0x08,0x0a,0x01,0x02,0x12,0x03,0x02,0x00,0x12,0x0a,
0x08,0x0a,0x01,0x08,0x12,0x03,0x04,0x00,0x26,0x0a,
0x09,0x0a,0x02,0x08,0x01,0x12,0x03,0x04,0x00,0x26,
0x0a,0x0a,0x0a,0x02,0x04,0x00,0x12,0x04,0x06,0x00,
0x0b,0x01,0x0a,0x0a,0x0a,0x03,0x04,0x00,0x01,0x12,
0x03,0x06,0x08,0x1c,0x0a,0x0b,0x0a,0x04,0x04,0x00,
0x02,0x00,0x12,0x03,0x07,0x04,0x1b,0x0a,0x0c,0x0a,
0x05,0x04,0x00,0x02,0x00,0x05,0x12,0x03,0x07,0x04,
0x0a,0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,0x00,0x01,
0x12,0x03,0x07,0x0b,0x16,0x0a,0x0c,0x0a,0x05,0x04,
0x00,0x02,0x00,0x03,0x12,0x03,0x07,0x19,0x1a,0x0a,
0x0b,0x0a,0x04,0x04,0x00,0x02,0x01,0x12,0x03,0x08,
0x04,0x18,0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,0x01,
0x05,0x12,0x03,0x08,0x04,0x0b,0x0a,0x0c,0x0a,0x05,
0x04,0x00,0x02,0x01,0x01,0x12,0x03,0x08,0x0c,0x13,
0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,0x01,0x03,0x12,
0x03,0x08,0x16,0x17,0x0a,0x0b,0x0a,0x04,0x04,0x00,
0x02,0x02,0x12,0x03,0x09,0x04,0x1c,0x0a,0x0c,0x0a,
0x05,0x04,0x00,0x02,0x02,0x04,0x12,0x03,0x09,0x04,
0x0c,0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,0x02,0x05,
0x12,0x03,0x09,0x0d,0x12,0x0a,0x0c,0x0a,0x05,0x04,
0x00,0x02,0x02,0x01,0x12,0x03,0x09,0x13,0x17,0x0a,
0x0c,0x0a,0x05,0x04,0x00,0x02,0x02,0x03,0x12,0x03,
0x09,0x1a,0x1b,0x0a,0x0b,0x0a,0x04,0x04,0x00,0x02,
0x03,0x12,0x03,0x0a,0x04,0x1d,0x0a,0x0c,0x0a,0x05,
0x04,0x00,0x02,0x03,0x04,0x12,0x03,0x0a,0x04,0x0c,
0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,0x03,0x05,0x12,
0x03,0x0a,0x0d,0x13,0x0a,0x0c,0x0a,0x05,0x04,0x00,
0x02,0x03,0x01,0x12,0x03,0x0a,0x14,0x18,0x0a,0x0c,
0x0a,0x05,0x04,0x00,0x02,0x03,0x03,0x12,0x03,0x0a,
0x1b,0x1c,0x0a,0x0a,0x0a,0x02,0x04,0x01,0x12,0x04,
0x0d,0x00,0x12,0x01,0x0a,0x0a,0x0a,0x03,0x04,0x01,
0x01,0x12,0x03,0x0d,0x08,0x1b,0x0a,0x0b,0x0a,0x04,
0x04,0x01,0x02,0x00,0x12,0x03,0x0e,0x04,0x1b,0x0a,
0x0c,0x0a,0x05,0x04,0x01,0x02,0x00,0x05,0x12,0x03,
0x0e,0x04,0x0a,0x0a,0x0c,0x0a,0x05,0x04,0x01,0x02,
0x00,0x01,0x12,0x03,0x0e,0x0b,0x16,0x0a,0x0c,0x0a,
0x05,0x04,0x01,0x02,0x00,0x03,0x12,0x03,0x0e,0x19,
0x1a,0x0a,0x0b,0x0a,0x04,0x04,0x01,0x02,0x01,0x12,
0x03,0x0f,0x04,0x18,0x0a,0x0c,0x0a,0x05,0x04,0x01,
0x02,0x01,0x05,0x12,0x03,0x0f,0x04,0x09,0x0a,0x0c,
0x0a,0x05,0x04,0x01,0x02,0x01,0x01,0x12,0x03,0x0f,
0x0a,0x13,0x0a,0x0c,0x0a,0x05,0x04,0x01,0x02,0x01,
0x03,0x12,0x03,0x0f,0x16,0x17,0x0a,0x0b,0x0a,0x04,
0x04,0x01,0x02,0x02,0x12,0x03,0x10,0x04,0x30,0x0a,
0x0c,0x0a,0x05,0x04,0x01,0x02,0x02,0x04,0x12,0x03,
0x10,0x04,0x0c,0x0a,0x0c,0x0a,0x05,0x04,0x01,0x02,
0x02,0x06,0x12,0x03,0x10,0x0d,0x21,0x0a,0x0c,0x0a,
0x05,0x04,0x01,0x02,0x02,0x01,0x12,0x03,0x10,0x22,
0x2b,0x0a,0x0c,0x0a,0x05,0x04,0x01,0x02,0x02,0x03,
0x12,0x03,0x10,0x2e,0x2f,0x0a,0x0b,0x0a,0x04,0x04,
0x01,0x02,0x03,0x12,0x03,0x11,0x04,0x16,0x0a,0x0c,
0x0a,0x05,0x04,0x01,0x02,0x03,0x05,0x12,0x03,0x11,
0x04,0x0a,0x0a,0x0c,0x0a,0x05,0x04,0x01,0x02,0x03,
0x01,0x12,0x03,0x11,0x0b,0x11,0x0a,0x0c,0x0a,0x05,
0x04,0x01,0x02,0x03,0x03,0x12,0x03,0x11,0x14,0x15,
0x0a,0x0a,0x0a,0x02,0x04,0x02,0x12,0x04,0x14,0x00,
0x1b,0x01,0x0a,0x0a,0x0a,0x03,0x04,0x02,0x01,0x12,
0x03,0x14,0x08,0x22,0x0a,0x0b,0x0a,0x04,0x04,0x02,
0x02,0x00,0x12,0x03,0x15,0x04,0x1c,0x0a,0x0c,0x0a,
0x05,0x04,0x02,0x02,0x00,0x05,0x12,0x03,0x15,0x04,
0x0a,0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x00,0x01,
0x12,0x03,0x15,0x0b,0x17,0x0a,0x0c,0x0a,0x05,0x04,
0x02,0x02,0x00,0x03,0x12,0x03,0x15,0x1a,0x1b,0x0a,
0x0b,0x0a,0x04,0x04,0x02,0x02,0x01,0x12,0x03,0x16,
0x04,0x21,0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x01,
0x04,0x12,0x03,0x16,0x04,0x0c,0x0a,0x0c,0x0a,0x05,
0x04,0x02,0x02,0x01,0x05,0x12,0x03,0x16,0x0d,0x12,
0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x01,0x01,0x12,
0x03,0x16,0x13,0x1c,0x0a,0x0c,0x0a,0x05,0x04,0x02,
0x02,0x01,0x03,0x12,0x03,0x16,0x1f,0x20,0x0a,0x0b,
0x0a,0x04,0x04,0x02,0x02,0x02,0x12,0x03,0x17,0x04,
0x14,0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x02,0x05,
0x12,0x03,0x17,0x04,0x08,0x0a,0x0c,0x0a,0x05,0x04,
0x02,0x02,0x02,0x01,0x12,0x03,0x17,0x09,0x0f,0x0a,
0x0c,0x0a,0x05,0x04,0x02,0x02,0x02,0x03,0x12,0x03,
0x17,0x12,0x13,0x0a,0x0b,0x0a,0x04,0x04,0x02,0x02,
0x03,0x12,0x03,0x18,0x04,0x1b,0x0a,0x0c,0x0a,0x05,
0x04,0x02,0x02,0x03,0x05,0x12,0x03,0x18,0x04,0x09,
0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x03,0x01,0x12,
0x03,0x18,0x0a,0x16,0x0a,0x0c,0x0a,0x05,0x04,0x02,
0x02,0x03,0x03,0x12,0x03,0x18,0x19,0x1a,0x0a,0x0b,
0x0a,0x04,0x04,0x02,0x02,0x04,0x12,0x03,0x19,0x04,
0x1a,0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x04,0x05,
0x12,0x03,0x19,0x04,0x09,0x0a,0x0c,0x0a,0x05,0x04,
0x02,0x02,0x04,0x01,0x12,0x03,0x19,0x0a,0x15,0x0a,
0x0c,0x0a,0x05,0x04,0x02,0x02,0x04,0x03,0x12,0x03,
0x19,0x18,0x19,0x0a,0x0b,0x0a,0x04,0x04,0x02,0x02,
0x05,0x12,0x03,0x1a,0x04,0x17,0x0a,0x0c,0x0a,0x05,
0x04,0x02,0x02,0x05,0x05,0x12,0x03,0x1a,0x04,0x09,
0x0a,0x0c,0x0a,0x05,0x04,0x02,0x02,0x05,0x01,0x12,
0x03,0x1a,0x0a,0x12,0x0a,0x0c,0x0a,0x05,0x04,0x02,
0x02,0x05,0x03,0x12,0x03,0x1a,0x15,0x16,0x0a,0x0a,
0x0a,0x02,0x04,0x03,0x12,0x04,0x1d,0x00,0x21,0x01,
0x0a,0x0a,0x0a,0x03,0x04,0x03,0x01,0x12,0x03,0x1d,
0x08,0x22,0x0a,0x0b,0x0a,0x04,0x04,0x03,0x02,0x00,
0x12,0x03,0x1e,0x04,0x1b,0x0a,0x0c,0x0a,0x05,0x04,
0x03,0x02,0x00,0x05,0x12,0x03,0x1e,0x04,0x0b,0x0a,
0x0c,0x0a,0x05,0x04,0x03,0x02,0x00,0x01,0x12,0x03,
0x1e,0x0c,0x16,0x0a,0x0c,0x0a,0x05,0x04,0x03,0x02,
0x00,0x03,0x12,0x03,0x1e,0x19,0x1a,0x0a,0x0b,0x0a,
0x04,0x04,0x03,0x02,0x01,0x12,0x03,0x1f,0x04,0x19,
0x0a,0x0c,0x0a,0x05,0x04,0x03,0x02,0x01,0x05,0x12,
0x03,0x1f,0x04,0x09,0x0a,0x0c,0x0a,0x05,0x04,0x03,
0x02,0x01,0x01,0x12,0x03,0x1f,0x0a,0x14,0x0a,0x0c,
0x0a,0x05,0x04,0x03,0x02,0x01,0x03,0x12,0x03,0x1f,
0x17,0x18,0x0a,0x0b,0x0a,0x04,0x04,0x03,0x02,0x02,
0x12,0x03,0x20,0x04,0x1a,0x0a,0x0c,0x0a,0x05,0x04,
0x03,0x02,0x02,0x05,0x12,0x03,0x20,0x04,0x09,0x0a,
0x0c,0x0a,0x05,0x04,0x03,0x02,0x02,0x01,0x12,0x03,
0x20,0x0a,0x15,0x0a,0x0c,0x0a,0x05,0x04,0x03,0x02,
0x02,0x03,0x12,0x03,0x20,0x18,0x19,0x0a,0x0a,0x0a,
0x02,0x04,0x04,0x12,0x04,0x23,0x00,0x27,0x01,0x0a,
0x0a,0x0a,0x03,0x04,0x04,0x01,0x12,0x03,0x23,0x08,
0x1b,0x0a,0x0b,0x0a,0x04,0x04,0x04,0x02,0x00,0x12,
0x03,0x24,0x04,0x19,0x0a,0x0c,0x0a,0x05,0x04,0x04,
0x02,0x00,0x05,0x12,0x03,0x24,0x04,0x0b,0x0a,0x0c,
0x0a,0x05,0x04,0x04,0x02,0x00,0x01,0x12,0x03,0x24,
0x0c,0x14,0x0a,0x0c,0x0a,0x05,0x04,0x04,0x02,0x00,
0x03,0x12,0x03,0x24,0x17,0x18,0x0a,0x0b,0x0a,0x04,
0x04,0x04,0x02,0x01,0x12,0x03,0x25,0x04,0x14,0x0a,
0x0c,0x0a,0x05,0x04,0x04,0x02,0x01,0x05,0x12,0x03,
0x25,0x04,0x0a,0x0a,0x0c,0x0a,0x05,0x04,0x04,0x02,
0x01,0x01,0x12,0x03,0x25,0x0b,0x0f,0x0a,0x0c,0x0a,
0x05,0x04,0x04,0x02,0x01,0x03,0x12,0x03,0x25,0x12,
0x13,0x0a,0x0b,0x0a,0x04,0x04,0x04,0x02,0x02,0x12,
0x03,0x26,0x04,0x17,0x0a,0x0c,0x0a,0x05,0x04,0x04,
0x02,0x02,0x05,0x12,0x03,0x26,0x04,0x0a,0x0a,0x0c,
0x0a,0x05,0x04,0x04,0x02,0x02,0x01,0x12,0x03,0x26,
0x0b,0x12,0x0a,0x0c,0x0a,0x05,0x04,0x04,0x02,0x02,
0x03,0x12,0x03,0x26,0x15,0x16,0x0a,0x0a,0x0a,0x02,
0x04,0x05,0x12,0x04,0x29,0x00,0x2e,0x01,0x0a,0x0a,
0x0a,0x03,0x04,0x05,0x01,0x12,0x03,0x29,0x08,0x19,
0x0a,0x0b,0x0a,0x04,0x04,0x05,0x02,0x00,0x12,0x03,
0x2a,0x04,0x19,0x0a,0x0c,0x0a,0x05,0x04,0x05,0x02,
0x00,0x05,0x12,0x03,0x2a,0x04,0x0a,0x0a,0x0c,0x0a,
0x05,0x04,0x05,0x02,0x00,0x01,0x12,0x03,0x2a,0x0b,
0x14,0x0a,0x0c,0x0a,0x05,0x04,0x05,0x02,0x00,0x03,
0x12,0x03,0x2a,0x17,0x18,0x0a,0x0b,0x0a,0x04,0x04,
0x05,0x02,0x01,0x12,0x03,0x2b,0x04,0x1a,0x0a,0x0c,
0x0a,0x05,0x04,0x05,0x02,0x01,0x05,0x12,0x03,0x2b,
0x04,0x09,0x0a,0x0c,0x0a,0x05,0x04,0x05,0x02,0x01,
0x01,0x12,0x03,0x2b,0x0a,0x15,0x0a,0x0c,0x0a,0x05,
0x04,0x05,0x02,0x01,0x03,0x12,0x03,0x2b,0x18,0x19,
0x0a,0x0b,0x0a,0x04,0x04,0x05,0x02,0x02,0x12,0x03,
0x2c,0x04,0x1b,0x0a,0x0c,0x0a,0x05,0x04,0x05,0x02,
0x02,0x05,0x12,0x03,0x2c,0x04,0x09,0x0a,0x0c,0x0a,
0x05,0x04,0x05,0x02,0x02,0x01,0x12,0x03,0x2c,0x0a,
0x16,0x0a,0x0c,0x0a,0x05,0x04,0x05,0x02,0x02,0x03,
0x12,0x03,0x2c,0x19,0x1a,0x0a,0x0b,0x0a,0x04,0x04,
0x05,0x02,0x03,0x12,0x03,0x2d,0x04,0x18,0x0a,0x0c,
0x0a,0x05,0x04,0x05,0x02,0x03,0x05,0x12,0x03,0x2d,
0x04,0x09,0x0a,0x0c,0x0a,0x05,0x04,0x05,0x02,0x03,
0x01,0x12,0x03,0x2d,0x0a,0x13,0x0a,0x0c,0x0a,0x05,
0x04,0x05,0x02,0x03,0x03,0x12,0x03,0x2d,0x16,0x17,
0x62,0x06,0x70,0x72,0x6f,0x74,0x6f,0x33,
};
static const char file_name[] = "MrcComm.proto";
static const char mrc_proto_ProtobufJoystickData_name[] = "mrc.proto.ProtobufJoystickData";
std::string_view mrc_proto_ProtobufJoystickData::msg_name(void) noexcept { return mrc_proto_ProtobufJoystickData_name; }
pb_filedesc_t mrc_proto_ProtobufJoystickData::file_descriptor(void) noexcept { return {::file_name, ::file_descriptor}; }
PB_BIND(mrc_proto_ProtobufJoystickData, mrc_proto_ProtobufJoystickData, AUTO)
static const char mrc_proto_ProtobufControlData_name[] = "mrc.proto.ProtobufControlData";
std::string_view mrc_proto_ProtobufControlData::msg_name(void) noexcept { return mrc_proto_ProtobufControlData_name; }
pb_filedesc_t mrc_proto_ProtobufControlData::file_descriptor(void) noexcept { return {::file_name, ::file_descriptor}; }
PB_BIND(mrc_proto_ProtobufControlData, mrc_proto_ProtobufControlData, AUTO)
static const char mrc_proto_ProtobufJoystickDescriptor_name[] = "mrc.proto.ProtobufJoystickDescriptor";
std::string_view mrc_proto_ProtobufJoystickDescriptor::msg_name(void) noexcept { return mrc_proto_ProtobufJoystickDescriptor_name; }
pb_filedesc_t mrc_proto_ProtobufJoystickDescriptor::file_descriptor(void) noexcept { return {::file_name, ::file_descriptor}; }
PB_BIND(mrc_proto_ProtobufJoystickDescriptor, mrc_proto_ProtobufJoystickDescriptor, AUTO)
static const char mrc_proto_ProtobufJoystickOutputData_name[] = "mrc.proto.ProtobufJoystickOutputData";
std::string_view mrc_proto_ProtobufJoystickOutputData::msg_name(void) noexcept { return mrc_proto_ProtobufJoystickOutputData_name; }
pb_filedesc_t mrc_proto_ProtobufJoystickOutputData::file_descriptor(void) noexcept { return {::file_name, ::file_descriptor}; }
PB_BIND(mrc_proto_ProtobufJoystickOutputData, mrc_proto_ProtobufJoystickOutputData, AUTO)
static const char mrc_proto_ProtobufVersionInfo_name[] = "mrc.proto.ProtobufVersionInfo";
std::string_view mrc_proto_ProtobufVersionInfo::msg_name(void) noexcept { return mrc_proto_ProtobufVersionInfo_name; }
pb_filedesc_t mrc_proto_ProtobufVersionInfo::file_descriptor(void) noexcept { return {::file_name, ::file_descriptor}; }
PB_BIND(mrc_proto_ProtobufVersionInfo, mrc_proto_ProtobufVersionInfo, AUTO)
static const char mrc_proto_ProtobufMatchInfo_name[] = "mrc.proto.ProtobufMatchInfo";
std::string_view mrc_proto_ProtobufMatchInfo::msg_name(void) noexcept { return mrc_proto_ProtobufMatchInfo_name; }
pb_filedesc_t mrc_proto_ProtobufMatchInfo::file_descriptor(void) noexcept { return {::file_name, ::file_descriptor}; }
PB_BIND(mrc_proto_ProtobufMatchInfo, mrc_proto_ProtobufMatchInfo, AUTO)

View File

@@ -0,0 +1,185 @@
// 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.
/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.9 */
#ifndef PB_MRC_PROTO_MRCCOMM_NPB_H_INCLUDED
#define PB_MRC_PROTO_MRCCOMM_NPB_H_INCLUDED
#include <pb.h>
#include <span>
#include <string_view>
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
/* Struct definitions */
typedef struct _mrc_proto_ProtobufJoystickData {
static const pb_msgdesc_t* msg_descriptor(void) noexcept;
static std::string_view msg_name(void) noexcept;
static pb_filedesc_t file_descriptor(void) noexcept;
uint32_t ButtonCount;
uint32_t Buttons;
pb_callback_t Axes;
pb_callback_t POVs;
} mrc_proto_ProtobufJoystickData;
typedef struct _mrc_proto_ProtobufControlData {
static const pb_msgdesc_t* msg_descriptor(void) noexcept;
static std::string_view msg_name(void) noexcept;
static pb_filedesc_t file_descriptor(void) noexcept;
uint32_t ControlWord;
float MatchTime;
pb_callback_t Joysticks;
pb_callback_t OpMode;
} mrc_proto_ProtobufControlData;
typedef struct _mrc_proto_ProtobufJoystickDescriptor {
static const pb_msgdesc_t* msg_descriptor(void) noexcept;
static std::string_view msg_name(void) noexcept;
static pb_filedesc_t file_descriptor(void) noexcept;
pb_callback_t JoystickName;
pb_callback_t AxisTypes;
bool IsXbox;
int32_t JoystickType;
int32_t ButtonCount;
int32_t PovCount;
} mrc_proto_ProtobufJoystickDescriptor;
typedef struct _mrc_proto_ProtobufJoystickOutputData {
static const pb_msgdesc_t* msg_descriptor(void) noexcept;
static std::string_view msg_name(void) noexcept;
static pb_filedesc_t file_descriptor(void) noexcept;
uint32_t HidOutputs;
float LeftRumble;
float RightRumble;
} mrc_proto_ProtobufJoystickOutputData;
typedef struct _mrc_proto_ProtobufVersionInfo {
static const pb_msgdesc_t* msg_descriptor(void) noexcept;
static std::string_view msg_name(void) noexcept;
static pb_filedesc_t file_descriptor(void) noexcept;
uint32_t DeviceId;
pb_callback_t Name;
pb_callback_t Version;
} mrc_proto_ProtobufVersionInfo;
typedef struct _mrc_proto_ProtobufMatchInfo {
static const pb_msgdesc_t* msg_descriptor(void) noexcept;
static std::string_view msg_name(void) noexcept;
static pb_filedesc_t file_descriptor(void) noexcept;
pb_callback_t EventName;
int32_t MatchNumber;
int32_t ReplayNumber;
int32_t MatchType;
} mrc_proto_ProtobufMatchInfo;
/* Initializer values for message structs */
#define mrc_proto_ProtobufJoystickData_init_default {0, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define mrc_proto_ProtobufControlData_init_default {0, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define mrc_proto_ProtobufJoystickDescriptor_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, 0, 0, 0}
#define mrc_proto_ProtobufJoystickOutputData_init_default {0, 0, 0}
#define mrc_proto_ProtobufVersionInfo_init_default {0, {{NULL}, NULL}, {{NULL}, NULL}}
#define mrc_proto_ProtobufMatchInfo_init_default {{{NULL}, NULL}, 0, 0, 0}
#define mrc_proto_ProtobufJoystickData_init_zero {0, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define mrc_proto_ProtobufControlData_init_zero {0, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define mrc_proto_ProtobufJoystickDescriptor_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, 0, 0, 0}
#define mrc_proto_ProtobufJoystickOutputData_init_zero {0, 0, 0}
#define mrc_proto_ProtobufVersionInfo_init_zero {0, {{NULL}, NULL}, {{NULL}, NULL}}
#define mrc_proto_ProtobufMatchInfo_init_zero {{{NULL}, NULL}, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */
#define mrc_proto_ProtobufJoystickData_ButtonCount_tag 1
#define mrc_proto_ProtobufJoystickData_Buttons_tag 2
#define mrc_proto_ProtobufJoystickData_Axes_tag 3
#define mrc_proto_ProtobufJoystickData_POVs_tag 4
#define mrc_proto_ProtobufControlData_ControlWord_tag 1
#define mrc_proto_ProtobufControlData_MatchTime_tag 2
#define mrc_proto_ProtobufControlData_Joysticks_tag 3
#define mrc_proto_ProtobufControlData_OpMode_tag 4
#define mrc_proto_ProtobufJoystickDescriptor_JoystickName_tag 1
#define mrc_proto_ProtobufJoystickDescriptor_AxisTypes_tag 2
#define mrc_proto_ProtobufJoystickDescriptor_IsXbox_tag 3
#define mrc_proto_ProtobufJoystickDescriptor_JoystickType_tag 4
#define mrc_proto_ProtobufJoystickDescriptor_ButtonCount_tag 5
#define mrc_proto_ProtobufJoystickDescriptor_PovCount_tag 6
#define mrc_proto_ProtobufJoystickOutputData_HidOutputs_tag 1
#define mrc_proto_ProtobufJoystickOutputData_LeftRumble_tag 2
#define mrc_proto_ProtobufJoystickOutputData_RightRumble_tag 3
#define mrc_proto_ProtobufVersionInfo_DeviceId_tag 1
#define mrc_proto_ProtobufVersionInfo_Name_tag 2
#define mrc_proto_ProtobufVersionInfo_Version_tag 3
#define mrc_proto_ProtobufMatchInfo_EventName_tag 1
#define mrc_proto_ProtobufMatchInfo_MatchNumber_tag 2
#define mrc_proto_ProtobufMatchInfo_ReplayNumber_tag 3
#define mrc_proto_ProtobufMatchInfo_MatchType_tag 4
/* Struct field encoding specification for nanopb */
#define mrc_proto_ProtobufJoystickData_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, ButtonCount, 1) \
X(a, STATIC, SINGULAR, FIXED32, Buttons, 2) \
X(a, CALLBACK, REPEATED, FLOAT, Axes, 3) \
X(a, CALLBACK, REPEATED, SINT32, POVs, 4)
#define mrc_proto_ProtobufJoystickData_CALLBACK pb_default_field_callback
#define mrc_proto_ProtobufJoystickData_DEFAULT NULL
#define mrc_proto_ProtobufControlData_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, ControlWord, 1) \
X(a, STATIC, SINGULAR, FLOAT, MatchTime, 2) \
X(a, CALLBACK, REPEATED, MESSAGE, Joysticks, 3) \
X(a, CALLBACK, SINGULAR, STRING, OpMode, 4)
#define mrc_proto_ProtobufControlData_CALLBACK pb_default_field_callback
#define mrc_proto_ProtobufControlData_DEFAULT NULL
#define mrc_proto_ProtobufControlData_Joysticks_MSGTYPE mrc_proto_ProtobufJoystickData
#define mrc_proto_ProtobufJoystickDescriptor_FIELDLIST(X, a) \
X(a, CALLBACK, SINGULAR, STRING, JoystickName, 1) \
X(a, CALLBACK, REPEATED, INT32, AxisTypes, 2) \
X(a, STATIC, SINGULAR, BOOL, IsXbox, 3) \
X(a, STATIC, SINGULAR, INT32, JoystickType, 4) \
X(a, STATIC, SINGULAR, INT32, ButtonCount, 5) \
X(a, STATIC, SINGULAR, INT32, PovCount, 6)
#define mrc_proto_ProtobufJoystickDescriptor_CALLBACK pb_default_field_callback
#define mrc_proto_ProtobufJoystickDescriptor_DEFAULT NULL
#define mrc_proto_ProtobufJoystickOutputData_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FIXED32, HidOutputs, 1) \
X(a, STATIC, SINGULAR, FLOAT, LeftRumble, 2) \
X(a, STATIC, SINGULAR, FLOAT, RightRumble, 3)
#define mrc_proto_ProtobufJoystickOutputData_CALLBACK NULL
#define mrc_proto_ProtobufJoystickOutputData_DEFAULT NULL
#define mrc_proto_ProtobufVersionInfo_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FIXED32, DeviceId, 1) \
X(a, CALLBACK, SINGULAR, STRING, Name, 2) \
X(a, CALLBACK, SINGULAR, STRING, Version, 3)
#define mrc_proto_ProtobufVersionInfo_CALLBACK pb_default_field_callback
#define mrc_proto_ProtobufVersionInfo_DEFAULT NULL
#define mrc_proto_ProtobufMatchInfo_FIELDLIST(X, a) \
X(a, CALLBACK, SINGULAR, STRING, EventName, 1) \
X(a, STATIC, SINGULAR, INT32, MatchNumber, 2) \
X(a, STATIC, SINGULAR, INT32, ReplayNumber, 3) \
X(a, STATIC, SINGULAR, INT32, MatchType, 4)
#define mrc_proto_ProtobufMatchInfo_CALLBACK pb_default_field_callback
#define mrc_proto_ProtobufMatchInfo_DEFAULT NULL
/* Maximum encoded size of messages (where known) */
/* mrc_proto_ProtobufJoystickData_size depends on runtime parameters */
/* mrc_proto_ProtobufControlData_size depends on runtime parameters */
/* mrc_proto_ProtobufJoystickDescriptor_size depends on runtime parameters */
/* mrc_proto_ProtobufVersionInfo_size depends on runtime parameters */
/* mrc_proto_ProtobufMatchInfo_size depends on runtime parameters */
#define MRC_PROTO_MRCCOMM_NPB_H_MAX_SIZE mrc_proto_ProtobufJoystickOutputData_size
#define mrc_proto_ProtobufJoystickOutputData_size 15
#endif

View File

@@ -0,0 +1,163 @@
// 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 <string>
#include <utility>
#include <wpi/protobuf/ProtobufCallbacks.h>
#include "hal/proto/ControlData.h"
static_assert(sizeof(mrc::ControlFlags) == sizeof(uint32_t));
namespace {
constexpr uint32_t EnabledMask = 0x1;
constexpr uint32_t EStopMask = 0x8;
constexpr uint32_t FmsConnectedMask = 0x10;
constexpr uint32_t DsConnectedMask = 0x20;
constexpr uint32_t WatchdogActiveMask = 0x40;
constexpr uint32_t AllianceMask = 0x1F80;
constexpr uint32_t EnabledShift = 0;
constexpr uint32_t EStopShift = 3;
constexpr uint32_t FmsConnectedShift = 4;
constexpr uint32_t DsConnectedShift = 5;
constexpr uint32_t WatchdogActiveShift = 6;
constexpr uint32_t AllianceShift = 7;
#define WORD_TO_INT(Name) Ret |= (Word.Name << Name##Shift)
constexpr uint32_t FromControlWord(mrc::ControlFlags Word) {
uint32_t Ret = 0;
WORD_TO_INT(Enabled);
WORD_TO_INT(EStop);
WORD_TO_INT(FmsConnected);
WORD_TO_INT(DsConnected);
WORD_TO_INT(WatchdogActive);
WORD_TO_INT(Alliance);
return Ret;
}
#undef WORD_TO_INT
#define INT_TO_WORD(Name) Ret.Name = ((Word & Name##Mask) >> Name##Shift)
constexpr mrc::ControlFlags ToControlWord(uint32_t Word) {
mrc::ControlFlags Ret = {};
INT_TO_WORD(Enabled);
INT_TO_WORD(EStop);
INT_TO_WORD(FmsConnected);
INT_TO_WORD(DsConnected);
INT_TO_WORD(WatchdogActive);
INT_TO_WORD(Alliance);
return Ret;
}
} // namespace
std::optional<mrc::ControlData> wpi::Protobuf<mrc::ControlData>::Unpack(
InputStream& Stream) {
wpi::UnpackCallback<mrc::Joystick, MRC_MAX_NUM_JOYSTICKS> JoystickCb;
wpi::UnpackCallback<std::string> OpModeCb;
mrc_proto_ProtobufControlData Msg{
.ControlWord = 0,
.MatchTime = 0,
.Joysticks = JoystickCb.Callback(),
.OpMode = OpModeCb.Callback(),
};
if (!Stream.Decode(Msg)) {
return {};
}
auto Joysticks = JoystickCb.Items();
auto OpMode = OpModeCb.Items();
mrc::ControlData ControlData;
if (!OpMode.empty()) {
ControlData.MoveOpMode(std::move(OpMode[0]));
}
ControlData.ControlWord = ToControlWord(Msg.ControlWord);
ControlData.MatchTime = Msg.MatchTime;
ControlData.SetJoystickCount(Joysticks.size());
for (size_t i = 0; i < ControlData.GetJoystickCount(); i++) {
ControlData.Joysticks()[i] = Joysticks[i];
}
return ControlData;
}
bool wpi::Protobuf<mrc::ControlData>::Pack(OutputStream& Stream,
const mrc::ControlData& Value) {
std::string_view OpMode = Value.GetOpMode();
wpi::PackCallback OpModeCb{&OpMode};
std::span<const mrc::Joystick> Sticks = Value.Joysticks();
wpi::PackCallback Joysticks{Sticks};
mrc_proto_ProtobufControlData Msg{
.ControlWord = FromControlWord(Value.ControlWord),
.MatchTime = Value.MatchTime,
.Joysticks = Joysticks.Callback(),
.OpMode = OpModeCb.Callback(),
};
return Stream.Encode(Msg);
}
std::optional<mrc::Joystick> wpi::Protobuf<mrc::Joystick>::Unpack(
InputStream& Stream) {
wpi::UnpackCallback<float, MRC_MAX_NUM_AXES> AxesCb;
wpi::UnpackCallback<uint16_t, MRC_MAX_NUM_POVS> PovsCb;
mrc_proto_ProtobufJoystickData Msg{
.ButtonCount = 0,
.Buttons = 0,
.Axes = AxesCb.Callback(),
.POVs = PovsCb.Callback(),
};
if (!Stream.Decode(Msg)) {
return {};
}
auto Axes = AxesCb.Items();
auto Povs = PovsCb.Items();
mrc::Joystick Joystick;
Joystick.Axes.SetCount(Axes.size());
for (size_t i = 0; i < Joystick.Axes.GetCount(); i++) {
Joystick.Axes.Axes()[i] = Axes[i];
}
Joystick.Povs.SetCount(Povs.size());
for (size_t i = 0; i < Joystick.Povs.GetCount(); i++) {
Joystick.Povs.Povs()[i] = Povs[i];
}
Joystick.Buttons.SetCount(Msg.ButtonCount);
Joystick.Buttons.Buttons = Msg.Buttons;
return Joystick;
}
bool wpi::Protobuf<mrc::Joystick>::Pack(OutputStream& Stream,
const mrc::Joystick& Value) {
wpi::PackCallback AxesCb{Value.Axes.Axes()};
wpi::PackCallback PovsCb{Value.Povs.Povs()};
mrc_proto_ProtobufJoystickData Msg{
.ButtonCount = static_cast<uint32_t>(Value.Buttons.GetCount()),
.Buttons = Value.Buttons.Buttons,
.Axes = AxesCb.Callback(),
.POVs = PovsCb.Callback(),
};
return Stream.Encode(Msg);
}

View File

@@ -0,0 +1,68 @@
// 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 <string>
#include <utility>
#include <wpi/protobuf/ProtobufCallbacks.h>
#include "hal/proto/JoystickDescriptor.h"
std::optional<mrc::JoystickDescriptor>
wpi::Protobuf<mrc::JoystickDescriptor>::Unpack(InputStream& Stream) {
wpi::UnpackCallback<std::string> JoystickNameCb;
wpi::UnpackCallback<uint8_t, MRC_MAX_NUM_AXES> AxisTypesCb;
mrc_proto_ProtobufJoystickDescriptor Msg;
Msg.JoystickName = JoystickNameCb.Callback();
Msg.AxisTypes = AxisTypesCb.Callback();
if (!Stream.Decode(Msg)) {
return {};
}
auto JoystickName = JoystickNameCb.Items();
auto AxisTypes = AxisTypesCb.Items();
if (JoystickName.empty()) {
return {};
}
mrc::JoystickDescriptor OutputData;
OutputData.MoveName(std::move(JoystickName[0]));
OutputData.SetAxesCount(AxisTypes.size());
for (size_t i = 0; i < OutputData.GetAxesCount(); i++) {
OutputData.AxesTypes()[i] = AxisTypes[i];
}
OutputData.SetPovsCount(Msg.PovCount);
OutputData.SetButtonsCount(Msg.ButtonCount);
OutputData.IsXbox = Msg.IsXbox ? 1 : 0;
OutputData.Type = Msg.JoystickType;
return OutputData;
}
bool wpi::Protobuf<mrc::JoystickDescriptor>::Pack(
OutputStream& Stream, const mrc::JoystickDescriptor& Value) {
std::string_view JoystickName = Value.GetName();
wpi::PackCallback JoystickNameCb{&JoystickName};
std::span<const uint8_t> AxisTypes = Value.AxesTypes();
wpi::PackCallback AxisTypesCb{AxisTypes};
mrc_proto_ProtobufJoystickDescriptor Msg{
.JoystickName = JoystickNameCb.Callback(),
.AxisTypes = AxisTypesCb.Callback(),
.IsXbox = Value.IsXbox ? true : false,
.JoystickType = Value.Type,
.ButtonCount = static_cast<int32_t>(Value.GetButtonsCount()),
.PovCount = static_cast<int32_t>(Value.GetPovsCount()),
};
return Stream.Encode(Msg);
}

View File

@@ -0,0 +1,33 @@
// 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 <wpi/protobuf/ProtobufCallbacks.h>
#include "hal/proto/JoystickOutputData.h"
std::optional<mrc::JoystickOutputData>
wpi::Protobuf<mrc::JoystickOutputData>::Unpack(InputStream& Stream) {
mrc_proto_ProtobufJoystickOutputData Msg;
if (!Stream.Decode(Msg)) {
return {};
}
return mrc::JoystickOutputData{
.HidOutputs = Msg.HidOutputs,
.LeftRumble = Msg.LeftRumble,
.RightRumble = Msg.RightRumble,
};
}
bool wpi::Protobuf<mrc::JoystickOutputData>::Pack(
OutputStream& Stream, const mrc::JoystickOutputData& Value) {
mrc_proto_ProtobufJoystickOutputData Msg{
.HidOutputs = Value.HidOutputs,
.LeftRumble = Value.LeftRumble,
.RightRumble = Value.RightRumble,
};
return Stream.Encode(Msg);
}

View File

@@ -0,0 +1,52 @@
// 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 <string>
#include <utility>
#include <wpi/protobuf/ProtobufCallbacks.h>
#include "hal/proto/MatchInfo.h"
std::optional<mrc::MatchInfo> wpi::Protobuf<mrc::MatchInfo>::Unpack(
InputStream& Stream) {
wpi::UnpackCallback<std::string> NameCb;
mrc_proto_ProtobufMatchInfo Msg;
Msg.EventName = NameCb.Callback();
if (!Stream.Decode(Msg)) {
return {};
}
auto Name = NameCb.Items();
if (Name.empty()) {
return {};
}
mrc::MatchInfo OutputData;
OutputData.MoveEventName(std::move(Name[0]));
OutputData.MatchNumber = Msg.MatchNumber;
OutputData.ReplayNumber = Msg.ReplayNumber;
OutputData.Type = static_cast<mrc::MatchType>(Msg.MatchType);
return OutputData;
}
bool wpi::Protobuf<mrc::MatchInfo>::Pack(OutputStream& Stream,
const mrc::MatchInfo& Value) {
std::string_view EventNameStr = Value.GetEventName();
wpi::PackCallback EventName{&EventNameStr};
mrc_proto_ProtobufMatchInfo Msg{
.EventName = EventName.Callback(),
.MatchNumber = Value.MatchNumber,
.ReplayNumber = Value.ReplayNumber,
.MatchType = static_cast<int32_t>(Value.Type),
};
return Stream.Encode(Msg);
}

View File

@@ -0,0 +1,56 @@
// 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 <string>
#include <utility>
#include <wpi/protobuf/ProtobufCallbacks.h>
#include "hal/proto/VersionInfo.h"
std::optional<mrc::VersionInfo> wpi::Protobuf<mrc::VersionInfo>::Unpack(
InputStream& Stream) {
wpi::UnpackCallback<std::string> NameCb;
wpi::UnpackCallback<std::string> VersionCb;
mrc_proto_ProtobufVersionInfo Msg{
.DeviceId = 0,
.Name = NameCb.Callback(),
.Version = VersionCb.Callback(),
};
if (!Stream.Decode(Msg)) {
return {};
}
auto Name = NameCb.Items();
auto Version = VersionCb.Items();
if (Name.empty() || Version.empty()) {
return {};
}
mrc::VersionInfo ToRet;
ToRet.DeviceId = Msg.DeviceId;
ToRet.MoveName(std::move(Name[0]));
ToRet.MoveVersion(std::move(Version[0]));
return ToRet;
}
bool wpi::Protobuf<mrc::VersionInfo>::Pack(OutputStream& Stream,
const mrc::VersionInfo& Value) {
std::string_view NameView = Value.GetName();
std::string_view VersionView = Value.GetVersion();
wpi::PackCallback NameCb{&NameView};
wpi::PackCallback VersionCb{&VersionView};
mrc_proto_ProtobufVersionInfo Msg{
.DeviceId = Value.DeviceId,
.Name = NameCb.Callback(),
.Version = VersionCb.Callback(),
};
return Stream.Encode(Msg);
}

View File

@@ -0,0 +1,30 @@
// 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 <stdint.h>
#include <wpi/protobuf/Protobuf.h>
#include "MrcComm.npb.h"
#include "mrc/NetComm.h"
template <>
struct wpi::Protobuf<mrc::ControlData> {
using MessageStruct = mrc_proto_ProtobufControlData;
using InputStream = wpi::ProtoInputStream<mrc::ControlData>;
using OutputStream = wpi::ProtoOutputStream<mrc::ControlData>;
static std::optional<mrc::ControlData> Unpack(InputStream& Stream);
static bool Pack(OutputStream& Stream, const mrc::ControlData& Value);
};
template <>
struct wpi::Protobuf<mrc::Joystick> {
using MessageStruct = mrc_proto_ProtobufJoystickData;
using InputStream = wpi::ProtoInputStream<mrc::Joystick>;
using OutputStream = wpi::ProtoOutputStream<mrc::Joystick>;
static std::optional<mrc::Joystick> Unpack(InputStream& Stream);
static bool Pack(OutputStream& Stream, const mrc::Joystick& Value);
};

View File

@@ -0,0 +1,21 @@
// 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 <stdint.h>
#include <wpi/protobuf/Protobuf.h>
#include "MrcComm.npb.h"
#include "mrc/NetComm.h"
template <>
struct wpi::Protobuf<mrc::JoystickDescriptor> {
using MessageStruct = mrc_proto_ProtobufJoystickDescriptor;
using InputStream = wpi::ProtoInputStream<mrc::JoystickDescriptor>;
using OutputStream = wpi::ProtoOutputStream<mrc::JoystickDescriptor>;
static std::optional<mrc::JoystickDescriptor> Unpack(InputStream& Stream);
static bool Pack(OutputStream& Stream, const mrc::JoystickDescriptor& Value);
};

View File

@@ -0,0 +1,21 @@
// 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 <stdint.h>
#include <wpi/protobuf/Protobuf.h>
#include "MrcComm.npb.h"
#include "mrc/NetComm.h"
template <>
struct wpi::Protobuf<mrc::JoystickOutputData> {
using MessageStruct = mrc_proto_ProtobufJoystickOutputData;
using InputStream = wpi::ProtoInputStream<mrc::JoystickOutputData>;
using OutputStream = wpi::ProtoOutputStream<mrc::JoystickOutputData>;
static std::optional<mrc::JoystickOutputData> Unpack(InputStream& Stream);
static bool Pack(OutputStream& Stream, const mrc::JoystickOutputData& Value);
};

View File

@@ -0,0 +1,21 @@
// 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 <stdint.h>
#include <wpi/protobuf/Protobuf.h>
#include "MrcComm.npb.h"
#include "mrc/NetComm.h"
template <>
struct wpi::Protobuf<mrc::MatchInfo> {
using MessageStruct = mrc_proto_ProtobufMatchInfo;
using InputStream = wpi::ProtoInputStream<mrc::MatchInfo>;
using OutputStream = wpi::ProtoOutputStream<mrc::MatchInfo>;
static std::optional<mrc::MatchInfo> Unpack(InputStream& Stream);
static bool Pack(OutputStream& Stream, const mrc::MatchInfo& Value);
};

View File

@@ -0,0 +1,21 @@
// 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 <stdint.h>
#include <wpi/protobuf/Protobuf.h>
#include "MrcComm.npb.h"
#include "mrc/NetComm.h"
template <>
struct wpi::Protobuf<mrc::VersionInfo> {
using MessageStruct = mrc_proto_ProtobufVersionInfo;
using InputStream = wpi::ProtoInputStream<mrc::VersionInfo>;
using OutputStream = wpi::ProtoOutputStream<mrc::VersionInfo>;
static std::optional<mrc::VersionInfo> Unpack(InputStream& Stream);
static bool Pack(OutputStream& Stream, const mrc::VersionInfo& Value);
};

View File

@@ -27,11 +27,11 @@
#include "HALInitializer.h"
#include "HALInternal.h"
#include "SystemServer.h"
#include "hal/DriverStation.h"
#include "hal/Errors.h"
#include "hal/Notifier.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/roborio/HMB.h"
using namespace hal;
@@ -337,6 +337,8 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
prctl(PR_SET_PDEATHSIG, SIGTERM);
hal::InitializeSystemServer();
// // Return false if program failed to kill an existing program
// if (!killExistingProgram(timeout, mode)) {
// return false;

View File

@@ -0,0 +1,35 @@
// 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 "SystemServer.h"
#include "mrc/NtNetComm.h"
namespace hal {
static nt::NetworkTableInstance ServerInstance;
void InitializeSystemServer() {
if (ServerInstance) {
return;
}
ServerInstance = nt::NetworkTableInstance::Create();
ServerInstance.SetServer("localhost", ROBOT_SYSTEM_SERVER_NT_PORT);
ServerInstance.StartClient4("RobotProgram");
}
void ShutdownSystemServer() {
if (!ServerInstance) {
return;
}
ServerInstance.StopClient();
nt::NetworkTableInstance::Destroy(ServerInstance);
}
nt::NetworkTableInstance GetSystemServer() {
return ServerInstance;
}
} // namespace hal

View File

@@ -0,0 +1,13 @@
// 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 hal {
void InitializeSystemServer();
void ShutdownSystemServer();
nt::NetworkTableInstance GetSystemServer();
} // namespace hal

View File

@@ -0,0 +1,308 @@
// 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 <stdint.h>
#include <array>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include "mrc/NtNetComm.h"
namespace mrc {
struct ControlFlags {
uint32_t Enabled : 1;
uint32_t ModeReserved : 2;
uint32_t EStop : 1;
uint32_t FmsConnected : 1;
uint32_t DsConnected : 1;
uint32_t WatchdogActive : 1;
uint32_t Alliance : 6;
uint32_t Reserved : 19;
};
struct JoystickAxes {
public:
std::span<float> Axes() { return std::span{AxesStore.data(), GetCount()}; }
std::span<const float> Axes() const {
return std::span{AxesStore.data(), GetCount()};
}
void SetCount(uint8_t NewCount) {
Count = (std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_AXES));
}
size_t GetCount() const { return Count; }
private:
std::array<float, MRC_MAX_NUM_AXES> AxesStore;
uint8_t Count{0};
};
struct JoystickPovs {
public:
std::span<int16_t> Povs() { return std::span{PovsStore.data(), GetCount()}; }
std::span<const int16_t> Povs() const {
return std::span{PovsStore.data(), GetCount()};
}
void SetCount(uint8_t NewCount) {
Count = (std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_POVS));
}
size_t GetCount() const { return Count; }
private:
std::array<int16_t, MRC_MAX_NUM_POVS> PovsStore;
uint8_t Count{0};
};
struct JoystickButtons {
uint32_t Buttons;
void SetCount(uint8_t NewCount) {
Count = (std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_BUTTONS));
}
size_t GetCount() const { return Count; }
private:
uint8_t Count{0};
};
struct Joystick {
JoystickAxes Axes;
JoystickPovs Povs;
JoystickButtons Buttons;
};
struct ControlData {
ControlFlags ControlWord;
float MatchTime;
std::span<Joystick> Joysticks() {
return std::span{JoysticksStore.data(), GetJoystickCount()};
}
std::span<const Joystick> Joysticks() const {
return std::span{JoysticksStore.data(), GetJoystickCount()};
}
size_t GetJoystickCount() const { return JoystickCount; }
void SetJoystickCount(uint8_t NewCount) {
JoystickCount =
(std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_JOYSTICKS));
}
void SetOpMode(std::string_view Mode) {
if (Mode.size() > MRC_MAX_OPMODE_LEN) {
Mode = Mode.substr(0, MRC_MAX_OPMODE_LEN);
}
OpMode = Mode;
}
void MoveOpMode(std::string&& Mode) {
OpMode = std::move(Mode);
if (OpMode.size() > MRC_MAX_OPMODE_LEN) {
OpMode.resize(MRC_MAX_OPMODE_LEN);
}
}
std::string_view GetOpMode() const { return OpMode; }
std::span<uint8_t> WritableOpModeBuffer(size_t Len) {
if (Len > MRC_MAX_OPMODE_LEN) {
Len = MRC_MAX_OPMODE_LEN;
}
OpMode.resize(Len);
return std::span<uint8_t>{reinterpret_cast<uint8_t*>(OpMode.data()),
OpMode.size()};
}
private:
std::array<Joystick, MRC_MAX_NUM_JOYSTICKS> JoysticksStore;
uint8_t JoystickCount{0};
std::string OpMode;
};
struct JoystickOutputData {
uint32_t HidOutputs{0};
float LeftRumble{0};
float RightRumble{0};
};
enum class MatchType : uint8_t {
None = 0,
Practice = 1,
Qualification = 2,
Playoff = 3,
Test = 4,
};
struct MatchInfo {
uint16_t MatchNumber{0};
uint8_t ReplayNumber{0};
MatchType Type{MatchType::None};
void SetEventName(std::string_view Name) {
if (Name.size() > MRC_MAX_EVENT_NAME_LEN) {
Name = Name.substr(0, MRC_MAX_EVENT_NAME_LEN);
}
EventName = Name;
}
void MoveEventName(std::string&& Name) {
EventName = std::move(Name);
if (EventName.size() > MRC_MAX_EVENT_NAME_LEN) {
EventName.resize(MRC_MAX_EVENT_NAME_LEN);
}
}
std::string_view GetEventName() const { return EventName; }
std::span<uint8_t> WritableNameBuffer(size_t Len) {
if (Len > MRC_MAX_EVENT_NAME_LEN) {
Len = MRC_MAX_EVENT_NAME_LEN;
}
EventName.resize(Len);
return std::span<uint8_t>{reinterpret_cast<uint8_t*>(EventName.data()),
EventName.size()};
}
private:
std::string EventName;
};
struct JoystickDescriptor {
public:
bool IsXbox{0};
uint8_t Type{0};
std::span<uint8_t> AxesTypes() {
return std::span{AxesTypesStore.data(), GetAxesCount()};
}
std::span<const uint8_t> AxesTypes() const {
return std::span{AxesTypesStore.data(), GetAxesCount()};
}
void SetAxesCount(uint8_t NewCount) {
AxesCount = (std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_AXES));
}
size_t GetAxesCount() const { return AxesCount; }
void SetPovsCount(uint8_t NewCount) {
PovCount = (std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_POVS));
}
size_t GetPovsCount() const { return PovCount; }
void SetButtonsCount(uint8_t NewCount) {
ButtonCount =
(std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_BUTTONS));
}
size_t GetButtonsCount() const { return ButtonCount; }
void SetName(std::string_view Name) {
if (Name.size() > MRC_MAX_JOYSTICK_NAME_LEN) {
Name = Name.substr(0, MRC_MAX_JOYSTICK_NAME_LEN);
}
JoystickName = Name;
}
void MoveName(std::string&& Name) {
JoystickName = std::move(Name);
if (JoystickName.size() > MRC_MAX_JOYSTICK_NAME_LEN) {
JoystickName.resize(MRC_MAX_JOYSTICK_NAME_LEN);
}
}
std::string_view GetName() const { return JoystickName; }
std::span<uint8_t> WritableNameBuffer(size_t Len) {
if (Len > MRC_MAX_JOYSTICK_NAME_LEN) {
Len = MRC_MAX_JOYSTICK_NAME_LEN;
}
JoystickName.resize(Len);
return std::span<uint8_t>{reinterpret_cast<uint8_t*>(JoystickName.data()),
JoystickName.size()};
}
private:
std::string JoystickName;
std::array<uint8_t, MRC_MAX_NUM_AXES> AxesTypesStore;
uint8_t AxesCount{0};
uint8_t ButtonCount{0};
uint8_t PovCount{0};
};
struct VersionInfo {
uint32_t DeviceId{0};
void SetName(std::string_view NewName) {
if (NewName.size() > MRC_MAX_VERSION_SIZE) {
NewName = NewName.substr(0, MRC_MAX_VERSION_SIZE);
}
Name = NewName;
}
void MoveName(std::string&& NewName) {
Name = std::move(NewName);
if (Name.size() > MRC_MAX_VERSION_SIZE) {
Name.resize(MRC_MAX_VERSION_SIZE);
}
}
std::string_view GetName() const { return Name; }
std::span<uint8_t> WritableNameBuffer(size_t Len) {
if (Len > MRC_MAX_VERSION_SIZE) {
Len = MRC_MAX_VERSION_SIZE;
}
Name.resize(Len);
return std::span<uint8_t>{reinterpret_cast<uint8_t*>(Name.data()),
Name.size()};
}
void SetVersion(std::string_view NewVersion) {
if (NewVersion.size() > MRC_MAX_VERSION_SIZE) {
NewVersion = NewVersion.substr(0, MRC_MAX_VERSION_SIZE);
}
Version = NewVersion;
}
void MoveVersion(std::string&& NewVersion) {
Version = std::move(NewVersion);
if (Version.size() > MRC_MAX_VERSION_SIZE) {
Version.resize(MRC_MAX_VERSION_SIZE);
}
}
std::string_view GetVersion() const { return Version; }
std::span<uint8_t> WritableVersionBuffer(size_t Len) {
if (Len > MRC_MAX_VERSION_SIZE) {
Len = MRC_MAX_VERSION_SIZE;
}
Version.resize(Len);
return std::span<uint8_t>{reinterpret_cast<uint8_t*>(Version.data()),
Version.size()};
}
private:
std::string Name;
std::string Version;
};
} // namespace mrc

View File

@@ -0,0 +1,60 @@
// 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
#define ROBOT_SYSTEM_SERVER_NT_PORT 6810
#define ROBOT_CONTROL_DATA_PREFIX "/Netcomm/Control/"
#define ROBOT_WATCHDOG_ACTIVE_PATH (ROBOT_CONTROL_DATA_PREFIX "WatchdogActive")
#define ROBOT_CONTROL_DATA_PATH (ROBOT_CONTROL_DATA_PREFIX "ControlData")
#define ROBOT_GAME_SPECIFIC_MESSAGE_PATH \
(ROBOT_CONTROL_DATA_PREFIX "GameSpecificMessage")
#define ROBOT_MATCH_INFO_PATH (ROBOT_CONTROL_DATA_PREFIX "MatchInfo")
#define ROBOT_JOYSTICK_DESCRIPTORS_PATH \
(ROBOT_CONTROL_DATA_PREFIX "JoystickDescriptors/")
#define ROBOT_STATUS_DATA_PREFIX "/Netcomm/Status/"
#define ROBOT_NEW_ROBOT_PROGRAM_PATH \
(ROBOT_STATUS_DATA_PREFIX "NewRobotProgram")
#define ROBOT_CODE_STARTED_PATH (ROBOT_STATUS_DATA_PREFIX "UserCodeStarted")
#define ROBOT_DISABLED_TRACE_PATH (ROBOT_STATUS_DATA_PREFIX "UserCodeDisabled")
#define ROBOT_AUTON_TRACE_PATH (ROBOT_STATUS_DATA_PREFIX "UserCodeAutonomous")
#define ROBOT_TELEOP_TRACE_PATH (ROBOT_STATUS_DATA_PREFIX "UserCodeTeleop")
#define ROBOT_TEST_TRACE_PATH (ROBOT_STATUS_DATA_PREFIX "UserCodeTest")
#define ROBOT_OUTPUTS_DATA_PREFIX "/Netcomm/Outputs/"
#define ROBOT_JOYSTICK_OUTPUTS_PATH (ROBOT_OUTPUTS_DATA_PREFIX "Joysticks/")
#define ROBOT_CONSOLE_DATA_PREFIX "/Netcomm/Console/"
#define ROBOT_CONSOLE_LINE_PATH (ROBOT_CONSOLE_DATA_PREFIX "ConsoleLine")
#define ROBOT_REPORTING_DATA_PREFIX "/Netcomm/Reporting/"
#define ROBOT_LIB_VERSION_PATH (ROBOT_REPORTING_DATA_PREFIX "LibVersion")
#define ROBOT_USER_REPORTING_PATH (ROBOT_REPORTING_DATA_PREFIX "User")
#define ROBOT_MODES_PREFIX "/Netcomm/Modes/"
#define ROBOT_AVAILABLE_OP_MODES_PATH (ROBOT_MODES_PREFIX "AvailableOpModes")
#define ROBOT_SYSTEM_SERVER_PREFIX "/sys/"
#define ROBOT_BATTERY_VOLTAGE_PATH (ROBOT_SYSTEM_SERVER_PREFIX "battery")
#define ROBOT_RAM_USED_PATH (ROBOT_SYSTEM_SERVER_PREFIX "ram")
#define ROBOT_RAM_BYTES_PATH (ROBOT_SYSTEM_SERVER_PREFIX "ramtotal")
#define ROBOT_STORAGE_USED_PATH (ROBOT_SYSTEM_SERVER_PREFIX "storage")
#define ROBOT_STORAGE_BYTES_PATH (ROBOT_SYSTEM_SERVER_PREFIX "storagetotal")
#define ROBOT_CPU_PATH (ROBOT_SYSTEM_SERVER_PREFIX "cpu")
#define ROBOT_CAN_BW_PATH (ROBOT_SYSTEM_SERVER_PREFIX "canbusban")
#define ROBOT_TEAM_PATH (ROBOT_SYSTEM_SERVER_PREFIX "team")
#define MRC_MAX_NUM_JOYSTICKS 6
#define MRC_MAX_NUM_AXES 12
#define MRC_MAX_NUM_POVS 12
#define MRC_MAX_NUM_BUTTONS 32
#define MRC_MAX_OPMODE_LEN 32
#define MRC_MAX_GAME_SPECIFIC_MESSAGE_LEN 128
#define MRC_MAX_EVENT_NAME_LEN 64
#define MRC_MAX_JOYSTICK_NAME_LEN 256
#define MRC_MAX_VERSION_SIZE 256

View File

@@ -0,0 +1,47 @@
syntax = "proto3";
package mrc.proto;
option java_package = "com.mrc.proto";
message ProtobufJoystickData {
uint32 ButtonCount = 1;
fixed32 Buttons = 2;
repeated float Axes = 3;
repeated sint32 POVs = 4;
}
message ProtobufControlData {
uint32 ControlWord = 1;
float MatchTime = 2;
repeated ProtobufJoystickData Joysticks = 3;
string OpMode = 4;
}
message ProtobufJoystickDescriptor {
string JoystickName = 1;
repeated int32 AxisTypes = 2;
bool IsXbox = 3;
int32 JoystickType = 4;
int32 ButtonCount = 5;
int32 PovCount = 6;
}
message ProtobufJoystickOutputData {
fixed32 HidOutputs = 1;
float LeftRumble = 2;
float RightRumble = 3;
}
message ProtobufVersionInfo {
fixed32 DeviceId = 1;
string Name = 2;
string Version = 3;
}
message ProtobufMatchInfo {
string EventName = 1;
int32 MatchNumber = 2;
int32 ReplayNumber = 3;
int32 MatchType = 4;
}

View File

@@ -91,7 +91,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -33,7 +33,7 @@ model {
"${nativeName}"(NativeExecutableSpec) {
baseName = 'processstarter'
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -93,7 +93,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -42,11 +42,13 @@ model {
}
binaries {
all {
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
withType(GoogleTestTestSuiteBinarySpec) {
project(':hal').addHalDependency(it, 'shared')
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib library: pluginName, linkage: 'shared'

View File

@@ -32,7 +32,7 @@ model {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -23,7 +23,7 @@ apply from: "${rootDir}/shared/plugins/setupBuild.gradle"
model {
binaries {
all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -41,6 +41,7 @@ model {
}
binaries.all {
project(':hal').addHalDependency(it, 'shared')
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
@@ -49,7 +50,7 @@ model {
}
binaries {
all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -44,17 +44,19 @@ model {
binaries {
all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ":simulation:halsim_ws_core", library: "halsim_ws_core", linkage: "static"
}
withType(GoogleTestTestSuiteBinarySpec) {
project(':hal').addHalDependency(it, 'shared')
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib library: pluginName, linkage: 'shared'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {

View File

@@ -23,11 +23,12 @@ apply from: "${rootDir}/shared/plugins/setupBuild.gradle"
model {
binaries {
all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ":simulation:halsim_ws_core", library: "halsim_ws_core", linkage: "static"
}

View File

@@ -92,7 +92,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
@@ -131,7 +131,7 @@ model {
include "**/*.cpp"
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -49,7 +49,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}

View File

@@ -36,7 +36,7 @@ model {
}
binaries.all {
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
@@ -105,7 +105,7 @@ model {
}
binaries {
all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}