Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Issues with retrieving NetworkTables (http://www.chiefdelphi.com/forums/showthread.php?t=154869)

BertTurtle 06-02-2017 22:14

Issues with retrieving NetworkTables
 
When we try to retrieve NetworkTables our driver station code crashes with the error:
Code:

Unhandled exception: java.lang.IllegalStateException: Network tables has already been initialized
The code on the coprocessor is:
Code:

NetworkTable.setIPAddress("59.40");
NetworkTable table = NetworkTable.getTable("Vision");
table.putNumber("Test Value", 8);

Then the code on the driver station is:
Code:

NetworkTable.setClientMode();
NetworkTable.setIPAddress("59.40");
table = NetworkTable.getTable("Vision");
SmartDashboard.putNumber("Test Value", table.getNumber("Test Value", 0));

We think it has something to do with NetworkTable.setClientMode() because when we remove that line it doesn't crash but we are not able to retrieve the number.

EmileH 06-02-2017 22:17

Re: Issues with retrieving NetworkTables
 
Remove the setIPAddress line on the robot, and make sure on the client you set the IP address to the mDNS address of the robot - roborio-5940-FRC.local.

BertTurtle 06-02-2017 22:27

Re: Issues with retrieving NetworkTables
 
I made the suggested changes and it still has the same error.

EmileH 06-02-2017 22:34

Re: Issues with retrieving NetworkTables
 
Are you calling the setClientMode/setIPAddress/getTable calls repeatedly? They should only be called once on robot initialization.

BertTurtle 08-02-2017 19:55

Re: Issues with retrieving NetworkTables
 
When we delete all of the lines of the robot code except for NetworkTables.setClientMode() it still crashes.

I am sure we are not calling it twice.

BertTurtle 08-02-2017 22:17

Re: Issues with retrieving NetworkTables
 
Just a quick update. On the coprocessor, I ran table.isConnected(), and it returned false.

BertTurtle 09-02-2017 22:53

Re: Issues with retrieving NetworkTables
 
I was able to fix the problem. NetworkTable.setServerMode() is automatically done in the robot code which causes the code to crash if you call NetworkTable.setClientMode().

I removed NetwokTable.setClientMode() from the robot code and put it on the coprocessor instead. I also moved NetworkTable.setIpAddress() to the coprocessor.


All times are GMT -5. The time now is 15:34.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi