Go to Post I learned that I don't have a clone, there are only 24 hours in a day, and I can't do everything I want to do (even though I tried) and I learned that I have to say "no" once in a while. - KathieK [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 16-01-2017, 20:41
Henry Loh Henry Loh is offline
Registered User
FRC #5104
 
Join Date: Jan 2017
Location: Pacific Grove, Ca.
Posts: 7
Henry Loh is an unknown quantity at this point
Basic Network Table Test Fails

Hello,
So my team is planning on using Vision Processing this year to help with the shooter, and a precursory step to this is manipulating Network Tables. Today I was working on a basic example between the RoboRIO (C++) and a Java Client on a Mac (Java). The basic scenario is that the roboRio creates a network table (Net) and posts to it the variable Test with the value of 10. The client program then connects to the RoboRIO, and attempts to read the Net/Test value from the RoboRIO. However, the client fails to read the value from the network table and I am not sure why as both programs have repeatedly been dumbed down until there is hardly anything left. Any advice/suggestions would be much appreciated.

Thanks a bunch,
Henry

Here are the logistics:

Setup:
- C++ Iterative Robot Code
- Java Client Program on Mac
- Links to the jar discussed in the screensteps tutorial


Result:
- Server (RoboRIO Code) seems to run fine. The Network Table (Net) and it's value for Test are displayed in the variables tab of the SmartDashboard.
- Client (Java - Mac) does not run as hoped. The code cannot find the Net/Test value and thus returns -1. Meanwhile, the SmartDashboard Console is spammed with NT: server: client CONNECTED: 10.51.4.198 port 5**** with ever-increasing port numbers.
- On the Client Side, the lines of "Test: -1" are split up by alternate outputs of...
edu.wpi.first.wpilibj.networktables2.client.Client ConnectionAdapter@b4c966a entered connection state: DISCONNECTED_FROM_SERVER

and

edu.wpi.first.wpilibj.networktables2.client.Client ConnectionAdapter@b4c966a entered connection state: CONNECTED_TO_SERVER


- Disabling the robot continues these console outputs until the client program is terminated.

Below, I have stripped the programs down to the basics, eliminating extraneous print statements and empty functions. As there is so little code, I can't imagine what is going wrong?

--------------------------------------------------------------------------------------------------------------------------

Server Code: (The Relevant Stuff)

#include "WPILib.h"
#include "NetworkTables/NetworkTable.h"


class Robot: public IterativeRobot {

public:
// Network Table Test
std::shared_ptr<NetworkTable> table;

Robot():
{
table = NetworkTable::GetTable("Net");
}

private:

void TeleopPeriodic(){
table->PutNumber("Test",10);
}

};

START_ROBOT_CLASS(Robot)


Client Code: (The Relevant Stuff)

import edu.wpi.first.wpilibj.networktables.NetworkTable;

public class Client {

public static void main(String[] arg){

NetworkTable.setClientMode();
NetworkTable.setIPAddress("10.51.4.105");

NetworkTable table = NetworkTable.getTable("Net");

while (true){

double test = table.getNumber("Test", -1);

System.out.printf("Test: %f\n",test);

}
}
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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