View Single Post
  #3   Spotlight this post!  
Unread 02-01-2016, 11:57 PM
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 152
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Can't get driver station to keep robot code light to stay green

Disable() gets called on startup so that you can do the things required to "disable" if there's anything special you'd like to do. Some questions...

Do you ever get the chance to click on "Enable" at the driver station? Or is it dead by then?
If it's dead so quickly, (the green robot code isn't lit) this means the program crashed and the best way to catch a crash is with the debugger. Take a look at screensteps live for "how to debug" ... but the gist is that rather than "Run As...->WPILib", you should use "Debug As...->WPILib" and this will deploy the code, but it will then launch it via the gdb debugger. If you're fortunate, the crash (exception) will get caught by gdb and you can pretty easily tell where the crash is.

To give you a hint of the type of thing I've seen make an early crash pre-enable with my students is not understanding declaring pointers and when they can be used. For instance, at the definition of your "SimpleRobot" class, if you declare a pointer and then try to use the pointer before instantiating it (via 'new'), you'd be using a null pointer. Things like...

Code:
class MyRobot : SimpleRobot {
  Victor *pMotor;
  int curSpeed = pMotor->Get();
....
}
In this case, curSpeed should be declared but not used in that way. It should be used in some place like RobotInit() AFTER doing a pMotor = new Victor(1);

There are many ways to make such an early crash - this is just an example. Give the debugger a try (its a great and valuable tool to know how to use) and if you're still stumped, post your code and we'll take a look for what might be at issue.

Quote:
Originally Posted by urg8rb8 View Post
Robot communications light stays on but the robot code light stays green for like two seconds then turns red. We put printf calls in RobotInit() and Disable() and we see both prints in NetConsole. This tells me that the code is actually being executed by the roborio but why is the Disable() function being called?

We've been at this for a few days and can't figure it out. We've made sure all the pieces of SW have been updated to the latest versions.

Thanks for your help!!
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote