Team2168 / 2015_Main_Robot

Source code for the 2015 season
2 stars 0 forks source link

Modify driverstation.java to remove warning #66

Open NotInControl opened 9 years ago

NotInControl commented 9 years ago

modify wpilibj file, and distribute new file to all team members to remove repeated joystick unplugged warnings. The file has an interval setting which is set for once a second.

jcorcoran commented 9 years ago

Depending on where that print statement is, it may be easier to extend the Joystick class (or make a copy), that way everyone doesn't need to modify their wpilib jars. This will avoid wpilib updates from squashing our changes. On Feb 21, 2015 7:44 PM, "Kevin" notifications@github.com wrote:

modify wpilibj file, and distribute new file to all team members to remove repeated joystick unplugged warnings. The file has an interval setting which is set for once a second.

— Reply to this email directly or view it on GitHub https://github.com/Team2168/2015_Main_Robot/issues/66.

NotInControl commented 9 years ago

its in the driverstation.java file

jcorcoran commented 9 years ago

Instead of modifying a class within wpilib (this is going to be a headache to distribute/maintain)...

We should investigate using the Driverstation getStickAxisCount and getStickButtonCount methods within the F310 class. (there's one for POV too). Might just need to do this for axes, as those are called directly from commands right now, which is why we see the message repeatedly.

These methods should return zero if the joystick isn't plugged in if I understand correctly. Then button/axis/pov getters can then check the count and not actually call out to the Joystick class to get a value if the count isn't greater than zero. This will avoid the call down to DriverStation, and as a result prevent the periodic print statements.

If we approach fixing it that way, we keep the fix within our user code and everything just works.

http://team2168.org/javadoc/edu/wpi/first/wpilibj/DriverStation.html

NotInControl commented 9 years ago

If we went that route, wouldn't the check only be performed once in our code (when the F310 class is instantiated), and if you plugged in a joystick into the DS after that, the warning will still show up?

I agree the optimal solution would be to keep the fix on our side

jcorcoran commented 9 years ago

The warning shows up only when you are clearing the joystick class. If you can determine a way to stop clearing into the joystick class for instances of joystick that are not plugged in, then you won't get warnings any longer.

I don't see a way to actually stop the driver station class: from printing warnings. Ideally there would be a way to check if a joystick is plugged in on a port. We would need WPI lib modified to do that. I don't want to modify files within the jar.

jcorcoran commented 9 years ago

Querying *

NotInControl commented 9 years ago

I believe the DriverStation queries every instantiated joystick, which gets created in OI.java constructor. So I believe the only way to prevent the message without altering the DriverStation.java file, would be too stop the instantiation of sticks which aren't plugged in.

And I don't want to do that, because that's worse than modifying the WPILib, you wouldn't be able to plug in a new joystick after OI was instantiated. I guess we can table this, and think about this more later, its not a priority just an annoyance.

jcorcoran commented 9 years ago

Driver station doesn't query sticks. The warnings happen as a result of a call from the Joystick class. Look at the source for the get methods. If you want me to post line numbers I can, only have my phone right now and its annoying.