View Single Post
  #3   Spotlight this post!  
Unread 08-01-2017, 12:40
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 256
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: Error while trying to setup NetworkTables on PC

Quote:
Originally Posted by Darksainor View Post

Program (This is just for testing and learning purposes):
Code:
#include <ntcore.h>
#include <networktables/NetworkTable.h>
using std::shared_ptr;

int main() {
	NetworkTable::SetClientMode();
	NetworkTable::SetIPAddress("10.46.35.2");
	NetworkTable::Initialize();
	shared_ptr<NetworkTable> myTable = NetworkTable::GetTable("SmartDashboard");
	myTable->PutString("ExampleString", "Sample Text");
	NetworkTable::Shutdown();
	return 0;
}
After you fix the build error, you'll find that this program won't actually set a value. All NetworkTables calls are non-blocking, so the program will exit before it has a chance to connect to the server. You'll need to put the PutString in a loop or add a few seconds delay at the end. Note you'll want a loop for image processing anyway.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Reply With Quote