RoboRIO No Robot Code and Comms Light Red

Just deployed and it was successful. Robot code light is red in drivers station when connected via both ethernet or bridge. Thanks

Almost certainly the cause is that your code is crashing at runtime. You should open up the DS window, click on the little gear icon above the messages window to open a bigger console window. You will likely see errors and a stack trace being printed there from the crash.

Getting a repeated initialization message instead:


It’s just doing this repeatedly

There’s nothing after that? Does it just go back to the “Robot program starting” message? Is this a C++ program? You may need to post your code somewhere for us to help further.

Yeah, it goes back to that message. It’s C++, code is here

You may just need to start adding print statements to help isolate the problem. E.g. in various steps of constructors and RobotInit. The other thing to try would be to run it in the debugger and see where it’s actually crashing.

Well when I deployed the code again the console messages from before did not pause–it continued writing the initialization code as if nothing happened. It’s like it’s not actually receiving the code.

Try resetting / power cycling the RoboRIO.

1 Like

Tried that a few times already and it did not do anything. Also, does cout print to the RoboRio log or is there a different command for that?

cout will print to the log. you will need to flush it with std::endl or similar. Is the Riolog window in vscode showing anything different? The deploys are succeeding?

Deploys are succeeding and none of the print statements (which I do end with std::endl) are printing. I have one in the start of RobotInit and one at the end and one in the constructor code for Robot.cpp. The Riolog in vs code shows the same thing.

Try creating a new template program and deploying it. You do only have one roboRIO, correct?

Blank template built and deployed fine. We have another RIO but it would be a task to remove it from last year’s bot. Also, that does not seem to be the problem since the code deployed fine when it was empty.

Does the blank template run correctly? E.g. does it successfully run and those messages no longer print?

With your original program you might want to try debugging it. https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/debugging-robot-program.html

Yeah, it runs correctly.
I get this error: image on the code we wrote (not the template). Not sure if that changes anything.

I will try debugging.

Should just be passing the 0 I2C port to the constructor of the Lidar, right?

The constructor takes a pointer. 0 is a null pointer. But then the constructor doesn’t even use the value, because that part is commented out. It passes an uninitialized m_port to HAL_InitializeI2C instead. Which won’t work, but shouldn’t crash. Actually, it might crash, as it’s completely uninitialized, rather than 0. That might be the problem. Try actually initializing m_port in the LIDARLite_v3 class.

I’ll add that your code is very hard to read because of naming and the fact it uses inheritance instead of composition.

Sorry the code is hard to read, I’m the only programmer on my team.

What do I initialize m_port with? All the examples I’ve found have passed it a char but that’s not working.

Use one of the constants here: https://github.com/wpilibsuite/allwpilib/blob/42da07396c3c198709b11668a56d339effffb462/hal/src/main/native/include/hal/I2CTypes.h#L21

Changed the code; uploaded again here. Still have the red comms light and no robot code. It still seems to be looking for joysticks from last year which we don’t have this year, like it doesn’t even get to the construction of the joystick objects.

However, the problem is certainly something to do with the LidarLiteV3 class. I just changed it to an frc::Ultrasonic object and change the code accordingly and the robot code works fine.