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.
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…
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.