Updates the CANJaguar to free itself before throwing an exception in the constructor. This allows it to be allocated later without throwing an Allocation exception.

Change-Id: Ifbd15fecad92fa17a1c4b92d444b67221dacb4b5
This commit is contained in:
Jonathan Leitschuh
2014-07-24 16:47:36 -04:00
parent 78e6cf7208
commit 3ec797a8cf

View File

@@ -13,7 +13,6 @@ import java.nio.ByteOrder;
import edu.wpi.first.wpilibj.can.CANExceptionFactory;
import edu.wpi.first.wpilibj.can.CANJNI;
import edu.wpi.first.wpilibj.can.CANMessageNotFoundException;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable;
import edu.wpi.first.wpilibj.tables.ITable;
import edu.wpi.first.wpilibj.tables.ITableListener;
@@ -206,6 +205,8 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW
!m_receivedStatusMessage1 ||
!m_receivedStatusMessage2 ||
!receivedFirmwareVersion) {
/* Free the resource */
free();
throw new CANMessageNotFoundException();
}