NetworkTable client not connecting

We decided to use a Raspberry pi 3 to do vision processing this year. In order to communicate values with the RoboRIO, I’m trying to send a few numbers from the pi (python) to the RIO (java) using networktables.

Both the RIO and the pi are connected to the Radio via ethernet, and I am able to ping the RIO from the pi successfully. As well, I tested to make sure that each side could get and put numbers from their local version of the network table (they can). However, the pi and RIO can not get numbers that the other puts onto the table.

The RIO is currently set up with the static IP 10.6.86.2 (though I did try originally with the default, assigned IP ending in .23). Using isConnected() from the pi returns false, while the RIO returns true (I’m assuming this should always be the case because it’s the server). Unless Raspbian has a default firewall, there shouldn’t be anything on the pi to block I/O data.

This is the code being run from the pi. A loop should probably be made to run this in place of one of my team members spamming the run command into the terminal (out of frustration, of course), but I believe that it wouldn’t make too much of a difference. The only exception that I can think of would be that the pi isn’t being given enough time to connect to the network table and put its values up before killing off its end of the table.

And without making anyone root through this year’s code in search of fragments of network table lines scattered about, I’ll list what I’m doing from the RIO with generally where and the line number (at this moment): import NetworkTable from wpilib (outside the class, 11), declare NetworkTable piTalk (inside the class but outside of methods, 41), set NetworkTable to server mode (in robotInit, 105), set piTalk equal to the NetworkTable with the key (set on line 83) of “SmartDashboard” (in robotInit, 107), get the numbers with keys “angle” and “distance” from piTalk with default values 360 and 0 and put them onto the SmartDashboard so I can see them (in autonomous, lines 158 and 159).

I had my team member put in the loop today. The pi started being able to connect to the RIO, though not 100% of the time (according to my team mate that I have working on vision).

I believe the exception I was thinking of is exactly what was happening here, so adding in a loop for the pi to get stuck in until isConnected() returned true worked perfectly. This will be implemented later by using an if statement in place of the while, just in case I want to run something other than the network table.

As you’ve noticed, NetworkTables doesn’t immediately connect, so using it the way you were originally using it won’t work. I’ll add a note to the documentation about this.

I wouldn’t recommend sitting in a loop waiting for isConnected to occur, and then executing your code… why not just execute your code and send values? There’s no harm in sending them when it’s not connected.