Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated at edu.wpi.first.hal.SolenoidJNI.initializeSolenoidPort(Native Method)

Trying to set up two solenoids and am coming across ERROR -1029. I understand that it is supposed to mean I’m creating a device in an already occupied CAN port, but I can’t for the life of me find where I’m duplicating CAN ports or anything of the sort.

The full error message is:

  • Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated
  • Error at frc.robot.subsystems.TshirtCannon.(TshirtCannon.java:14): Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated
  • at edu.wpi.first.hal.SolenoidJNI.initializeSolenoidPort(Native Method)
  • at edu.wpi.first.wpilibj.Solenoid.(Solenoid.java:46)
  • at frc.robot.subsystems.TshirtCannon.(TshirtCannon.java:14)
  • at frc.robot.RobotContainer.(RobotContainer.java:30)
  • at frc.robot.Robot.robotInit(Robot.java:48)
  • at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:94)
  • at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:335)
  • at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:407)
  • at frc.robot.Main.main(Main.java:28)

Heres our code for the cannon:

Any help at all would be appreciated.

You’re initializing TshirtCannon twice. Once in RobotContainer line 30, Another inside of TshirCannon line 18. Initializing the static INSTANCE variable creates an instance. Since you have RobotContainer, you likely don’t need INSTANCE and can just remove it, and the getInstance() getter.

1 Like

That worked and solved the problem. Thank you!!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.