Robot deletes robot code after disabling it

Hey there again!
I am running a command based robot. When I enable it for teleop mode, everything works perfectly. If I disable the robot, and then attempt to re-enable it, the roborio stops comms with the driver station and deletes the code off the roborio. i have to either reset the robot code from the DS every time I disable it before re-enabling it, or let it crash and reboot the roborio and reupload the code.

Any reason for this?

Are you sure it’s actually deleting the code, or rather crashing? If the code crashes fatally, the “robot code” status light on the DS will be red. For example, if you have a method that causes your code to not boot up again afterwards, it would appear that the code has deleted itself. We’ve had some issues where the console in the DS doesn’t actually show the crash errors, so try going into the RIO log through eclipse and seeing if they have any error messages, or SSHing into the RIO to see if the executable is located there as well.

I have SSHed into the roborio, and looked at all the logs I could find. I could not see anything out of the ordinary and I certainly have not found the root cause of my problem. I’ve got a hunch it’s got to do with the frc::Scheduler, but I can’t put my finger on it. If anyone has had the same problem and resolved it, any help is appreciated.

*PS: I’ve noticed that it’s only when re-enabling a mode that has already started. If I start teleop, then disable it, then run autonomous, it will not crash until I enable either one again.

This would be easier to debug if you posted your code. I suspect you are initializing hardware in telopInit and autonomousInit or in a default command for a subsystem, which would cause it to be overallocated the second time you enter that mode and crash.