mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Fixes initialization when not using the provided main (#1085)
Helpful for simulation, which might not use our main.
This commit is contained in:
committed by
Peter Johnson
parent
381c25c573
commit
86c1f8ae50
@@ -818,6 +818,7 @@ void DriverStation::GetData() {
|
||||
* This is only called once the first time GetInstance() is called
|
||||
*/
|
||||
DriverStation::DriverStation() {
|
||||
HAL_Initialize(500, 0);
|
||||
m_waitForDataCounter = 0;
|
||||
m_joystickAxes = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
|
||||
m_joystickPOVs = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
|
||||
|
||||
@@ -70,6 +70,11 @@ static void SetupCameraServerShared() {
|
||||
* boot so ensure that it runs.
|
||||
*/
|
||||
RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
|
||||
if (!HAL_Initialize(500, 0)) {
|
||||
wpi::errs() << "FATAL ERROR: HAL could not be initialized\n";
|
||||
wpi::errs().flush();
|
||||
std::terminate();
|
||||
}
|
||||
m_threadId = std::this_thread::get_id();
|
||||
|
||||
RobotState::SetImplementation(DriverStation::GetInstance());
|
||||
|
||||
@@ -185,6 +185,7 @@ public class DriverStation implements RobotState.Interface {
|
||||
* variable.
|
||||
*/
|
||||
private DriverStation() {
|
||||
HAL.initialize(500, 0);
|
||||
m_waitForDataCount = 0;
|
||||
m_waitForDataMutex = new ReentrantLock();
|
||||
m_waitForDataCond = m_waitForDataMutex.newCondition();
|
||||
|
||||
@@ -83,6 +83,7 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
* to put this code into it's own task that loads on boot so ensure that it runs.
|
||||
*/
|
||||
protected RobotBase() {
|
||||
initializeHardwareConfiguration();
|
||||
NetworkTableInstance inst = NetworkTableInstance.getDefault();
|
||||
setupCameraServerShared();
|
||||
inst.setNetworkIdentity("Robot");
|
||||
@@ -219,7 +220,9 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
*/
|
||||
@SuppressWarnings("PMD.UnusedFormalParameter")
|
||||
public static void main(String... args) {
|
||||
initializeHardwareConfiguration();
|
||||
if (!HAL.initialize(500, 0)) {
|
||||
throw new IllegalStateException("Failed to initialize. Terminating");
|
||||
}
|
||||
|
||||
HAL.report(tResourceType.kResourceType_Language, tInstances.kLanguage_Java);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user