Go to Post first post and the FRC "well what is a stick" comes in. Toothpick, does it need to be round, does a carbon fiber chain of Buckie balls count as a stick. CD posters are sooooo predictable. - Foster [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2013, 01:51
tac tac is offline
Registered User
FRC #4765
 
Join Date: Feb 2013
Location: Santa Clara
Posts: 1
tac is an unknown quantity at this point
CANNotInitializedException

We've been trying to get our CANJaguar code working, but it keeps returning the CANNotInitializedException.

Our code right now is

Code:
public void robotInit(){
     try {
          CANJaguar armMotor = new CANJaguar (4,       CANJaguar.ControlMode.kPosition);
     } catch (CANTimeoutException ex){
          ex.printStackTrace();
}
What the console says:
Code:
[Squawk VM] Version: 2011 FRC, Nov  5 2011, 14:34:13
[cRIO] FPGA Hardware GUID: 0x1394f6dc1feb42ec6910e5767ed1d22c
[cRIO] FPGA Software GUID: 0xa14c11bde4bb64aef6a86fc52a294cd9
[cRIO] DIO LoopTiming: 260, expecting: 261
[cRIO] edu.wpi.first.wpilibj.can.CANNotInitializedException
[cRIO]     at edu.wpi.first.wpilibj.can.CANExceptionFactory.checkStatus(CANExceptionFactory.java:44)
[cRIO]     at edu.wpi.first.wpilibj.can.JaguarCANDriver.sendMessage(JaguarCANDriver.java:36)
[cRIO]     at edu.wpi.first.wpilibj.CANJaguar.sendMessage(CANJaguar.java:574)
[cRIO]     at edu.wpi.first.wpilibj.CANJaguar.getTransaction(CANJaguar.java:637)
[cRIO]     at edu.wpi.first.wpilibj.CANJaguar.getFirmwareVersion(CANJaguar.java:1199)
[cRIO]     at edu.wpi.first.wpilibj.CANJaguar.initCANJaguar(CANJaguar.java:247)
[cRIO]     at edu.wpi.first.wpilibj.CANJaguar.<init>(CANJaguar.java:286)
[cRIO]     at edu.wpi.first.wpilibj.templates.RobotTemplate.robotInit(RobotTemplate.java:70)
[cRIO]     at edu.wpi.first.wpilibj.SimpleRobot.startCompetition(SimpleRobot.java:104)
[cRIO]     at edu.wpi.first.wpilibj.RobotBase.startApp(RobotBase.java:156)
[cRIO]     in virtual method #10 of javax.microedition.midlet.MIDlet(bci=17)
[cRIO]     at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(64)
[cRIO]     at com.sun.squawk.imp.MIDletMainWrapper.main(110)
[cRIO]     in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO]     at com.sun.squawk.Isolate.run(1506)
[cRIO]     at java.lang.Thread.run(231)
[cRIO]     in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO]     in static method #3 of com.sun.squawk.VM(bci=6)
[cRIO] WARNING: Robots don't quit!
[cRIO] ---> The startCompetition() method (or methods called by it) should have handled the exception above.
[cRIO] task 0x25c7bb8 (System Web Services Load Thread) deleted: errno=0 (0) status=0 (0)
[cRIO] task 0x28784f8 (mDNS resolve) deleted: errno=0 (0) status=0 (0)
[cRIO] task 0x2bff230 (mDNS resolve) deleted: errno=0 (0) status=0 (0)
We'd love your help. Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 16-02-2013, 22:49
arithehun arithehun is offline
Registered User
AKA: Ari Falkner
FRC #3024
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Ashland, Oregon
Posts: 27
arithehun is an unknown quantity at this point
Re: CANNotInitializedException

Also, you cannot define a jaguar inside of a code block (in this case, your "try" block, and then use it anywhere outside of the block. Outside of any method, but inside your class, type (you may have already done this):

Code:
CANJaguar armMotor;
Then, change your code that you displayed to this:
(Basically remove the CANJaguar variable marker):

Code:
public void robotInit(){
     try {
          armMotor = new CANJaguar (4,       CANJaguar.ControlMode.kPosition);
     } catch (CANTimeoutException ex){
          ex.printStackTrace();
}
Essentially, what is happening is that you're not initializing your global CANJaguar variable. How Java works is that it allows global and local variables of the same name. So the Jaguar that you're initializing isn't the same one that you're using at line 70. You made a new Jaguar also called "armMotor" and initialized that one. Because it had a conflicting name, Java resolved this by "hiding" the global variable from that function. The armMotor inside robotInit() was discarded after robotInit ended. The other armMotor that you defined elsewhere was never touched. By removing the CANJaguar reference, you're not creating a new variable anymore but instead initializing the existing global one, which is what you intended on doing.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-01-2014, 21:46
Metis Metis is offline
Registered User
FRC #4203
 
Join Date: Jan 2014
Location: Oneonta, NY
Posts: 5
Metis is an unknown quantity at this point
Re: CANNotInitializedException

The described error will occur if the cRIO has not had a CAN plugin set when the firmware was flashed. You need to re-image the cRIO to solve the problem.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-01-2014, 21:06
Ipiano's Avatar
Ipiano Ipiano is offline
Registered User
AKA: Andrew Stelter
FRC #3018 (Nordic Storm)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Mankato, Minnesota
Posts: 27
Ipiano is an unknown quantity at this point
Re: CANNotInitializedException

AriTheHun, I believe you would be correct if the issue were a CANTimeoutException, but this is a CANNotInitializedException, which, as Metis said, is supposed to occur when the CAN Driver is not properly loaded.
__________________
________
Genius is one percent inspiration and ninety-nine percent perspiration.
--Thomas A. Edison
Reply With Quote
  #5   Spotlight this post!  
Unread 16-01-2014, 07:51
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: CANNotInitializedException

Quote:
Originally Posted by arithehun View Post
Also, you cannot define a jaguar inside of a code block (in this case, your "try" block, and then use it anywhere outside of the block. Outside of any method, but inside your class, type (you may have already done this):

Code:
CANJaguar armMotor;
Then, change your code that you displayed to this:
(Basically remove the CANJaguar variable marker):

Code:
public void robotInit(){
     try {
          armMotor = new CANJaguar (4,       CANJaguar.ControlMode.kPosition);
     } catch (CANTimeoutException ex){
          ex.printStackTrace();
}
Essentially, what is happening is that you're not initializing your global CANJaguar variable. How Java works is that it allows global and local variables of the same name. So the Jaguar that you're initializing isn't the same one that you're using at line 70. You made a new Jaguar also called "armMotor" and initialized that one. Because it had a conflicting name, Java resolved this by "hiding" the global variable from that function. The armMotor inside robotInit() was discarded after robotInit ended. The other armMotor that you defined elsewhere was never touched. By removing the CANJaguar reference, you're not creating a new variable anymore but instead initializing the existing global one, which is what you intended on doing.
This would actually cause a compilation error, not a runtime error as the jaguar object would be out of scope when you tried to use it.
Reply With Quote
  #6   Spotlight this post!  
Unread 16-01-2014, 15:13
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: CANNotInitializedException

Quote:
Originally Posted by Ipiano View Post
AriTheHun, I believe you would be correct if the issue were a CANTimeoutException, but this is a CANNotInitializedException, which, as Metis said, is supposed to occur when the CAN Driver is not properly loaded.
So does it work if you select a CAN driver in the imaging tool?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi