|
Re: Error while trying to setup NetworkTables on PC
Quote:
Originally Posted by Darksainor
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)
|