SmartDashboard GetString() Not Working

Hello,

My team has a dashboard issue that plagued us today. In our cpp code, three strings are read in with SmartDashboard::GetString() to collect what auton we entered, backup auton (for the other side of the switch being our color), and our field position. We experienced in about 50% of our games, some of which where the one of two strings would read, but not the other, the GetString() returning an empty string in an otherwise visibly filled out field.

As far as we can tell, this only happens in actual matches. In the pit, on the practice field, the code receives the correct input 100% of the time with various checks I have to make sure the text field - visibly filled in to us - isn’t “secretly” empty, such as manually clearing the text fields on DisabledInit, clearing the fields if GetString() returns empty in DisabledPeriodic, and only reading in the data if it’s not an empty string.

Despite all of this, our auton in the last game mind bendingly did not have GetString() return “” in DisabledPeriodic, but when AutonInit occurred, it read in blank anyways (and I made the mistake of inserting a default “cross the line” auton instead of just not changing the read in auton from earlier, if it was working earlier that is).

I’m so confused.

Should I just read in from a text file? Is that more reliable than the "Smart"Dashboard?

What version of the plugins are you on? You might want to try Shuffleboard as well.

2018.2.2. I posted this on the Programming forum and someone suggested that it was AutonInit during matches that was messing it up. I’m reading it out of only DisabledPeriodic now, and it seems to be working.

Now the dashboard puts back the string it gets as it gets it, and I was able to determine that GetString() doesn’t work because the DriverStation has some kind of connection issue between closing the laptop/disconnecting/idk. Rebooting the DriverStation would open up the DashBoard and even autopopulate the text fields with what failed to read in last time. Figures.

GitHub - RyanDraves/FRC-2018-Team-5162 is the code.

The best way to do autonomous play-choosing is using the SendableChooser class. The docs aren’t bad, but they lend themselves to Command based robots and “plays” if you don’t get a little creative. However, there are some great threads here in the C++ area which cover how to use it with either addresses or pointers to strings which make your logic super easy to implement. It is the “intended” way that WPI has given teams for selecting autonomous plays.