mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal] Add initial SystemServer support (#7463)
This commit is contained in:
@@ -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;
|
||||
|
||||
35
hal/src/main/native/systemcore/SystemServer.cpp
Normal file
35
hal/src/main/native/systemcore/SystemServer.cpp
Normal 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
|
||||
13
hal/src/main/native/systemcore/SystemServer.h
Normal file
13
hal/src/main/native/systemcore/SystemServer.h
Normal 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
|
||||
Reference in New Issue
Block a user