kauailabs / allwpilib

Fork of Official Repository of WPILibJ and WPILibC, which contain in addition a HAL for the KauaiLabs VMX-pi.
Other
1 stars 3 forks source link

PWM Servo "Only a single Channel Capability is allowed" #5

Closed KadenK closed 5 years ago

KadenK commented 5 years ago

With a simple program trying to control a Hitech servo, the program compiles and deploys properly, but does not run correctly on the Pi.

Program:

public class PWMServo extends TimedRobot {

    Servo servo;
    int time;

  @Override
  public void robotInit() {
      servo = new Servo(0);
  }

  @Override
  public void teleopPeriodic() {
    if (servo.get() < 0.05) {
        servo.set(1);
    }
    else if (servo.get() < 0.95) {
        servo.set(0);
    }
  }
}

Error presented in /var/local/kauailabs/logs/FRC_UserProgram.log

** Robot program starting ** Error at frc.robot.PWMServo.robotInit(PWMServo.java:32): Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -20021. Only a single Channel Capability is allowed at edu.wpi.first.hal.PWMJNI.setPWMPeriodScale(Native Method) at edu.wpi.first.wpilibj.PWM.setPeriodMultiplier(PWM.java:291) at edu.wpi.first.wpilibj.Servo.(Servo.java:39) at frc.robot.PWMServo.robotInit(PWMServo.java:32) at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:63) at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:263) at frc.robot.Main.main(Main.java:27)

Warning at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:274): Robots should not quit, but yours did! Error at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:276): The startCompetition() method (or methods called by it) should have handled the exception above.

kauailabs commented 5 years ago

Fixed in v2019.4.1-vmxpi-beta-9.