001 /*----------------------------------------------------------------------------*/ 002 /* Copyright (c) FIRST 2008-2012. All Rights Reserved. */ 003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 004 /* must be accompanied by the FIRST BSD license file in the root directory of */ 005 /* the project. */ 006 /*----------------------------------------------------------------------------*/ 007 008 package edu.wpi.first.wpilibj.can; 009 010 /** 011 * Exception indicating that the CAN driver layer has not been initialized. 012 * This happens when an entry-point is called before a CAN driver plugin 013 * has been installed. 014 */ 015 public class CANJaguarVersionException extends RuntimeException { 016 017 public static final int kMinLegalFIRSTFirmwareVersion = 101; 018 // 3330 was the first shipping RDK firmware version for the Jaguar 019 public static final int kMinRDKFirmwareVersion = 3330; 020 021 public CANJaguarVersionException(int deviceNumber, int fwVersion) { 022 super(getString(deviceNumber, fwVersion)); 023 System.out.println("fwVersion[" + deviceNumber + "]: " + fwVersion); 024 } 025 026 static String getString(int deviceNumber, int fwVersion) { 027 String msg; 028 if (fwVersion < kMinRDKFirmwareVersion) { 029 msg = "Jaguar " + deviceNumber + 030 " firmware is too old. It must be updated to at least version " + 031 Integer.toString(kMinLegalFIRSTFirmwareVersion) + 032 " of the FIRST approved firmware!"; 033 } else { 034 msg = "Jaguar " + deviceNumber + 035 " firmware is not FIRST approved. It must be updated to at least version " + 036 Integer.toString(kMinLegalFIRSTFirmwareVersion) + 037 " of the FIRST approved firmware!"; 038 } 039 return msg; 040 } 041 }