OCCRA
Go to Post I owe these forums a lot more than $15 for all of the help and friends they have given me. - Karibou [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-11-2018, 08:32 PM
0x54796C6572's Avatar
0x54796C6572 0x54796C6572 is offline
Registered User
AKA: Tyler Tian
FRC #6135 (Arctos)
Team Role: Programmer
 
Join Date: Apr 2018
Rookie Year: 2017
Location: Toronto, Ontario, Canada
Posts: 12
0x54796C6572 is an unknown quantity at this point
Question How to redirect NetworkTables error output to file?

I have a Java program that runs on a computer which sends data over NetworkTables to the robot. Because I am testing without the robot, NetworkTables cannot connect, so it keeps on giving me the error message
Code:
NT: ERROR: could not resolve roboRIO-6135-FRC.lan address (TCPConnector.cpp:99)
NT: ERROR: could not resolve roboRIO-6135-FRC.frc-field.local address (TCPConnector.cpp:99)
I know that these error messages would go away as soon as the robot is connected, but they're super annoying during testing. So I tried redirecting stderr to a log file:
Code:
PrintStream pw = new PrintStream(new FileOutputStream("bridge.log"));
System.setErr(pw);
However, even though this redirected all my other error messages to the file, the NetworkTables message still shows up. Can anyone tell me how to get rid of the messages?

(The NetworkTables messages show up in red in Eclipse, so I thought they were from the error stream.)
Reply With Quote
  #2   Spotlight this post!  
Unread 06-11-2018, 10:16 PM
auscompgeek's Avatar
auscompgeek auscompgeek is offline
Registered User
AKA: David Vo
FRC #4774 (The Drop Bears)
Team Role: Mentor
 
Join Date: Jan 2018
Rookie Year: 2016
Location: Sydney, Australia
Posts: 24
auscompgeek is an unknown quantity at this point
Re: How to redirect NetworkTables error output to file?

Those messages are sent to stderr, but they are logged from the ntcore native libraries rather than the Java API.

Now, I don't know how to dup a raw file descriptor in Java, but you could probably redirect stderr before starting your program.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-12-2018, 02:38 PM
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,229
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: How to redirect NetworkTables error output to file?

NetworkTableInstance has a addLogger function. This takes a callback that will redirect those errors from the built in logger into your user code. I think if you use 0 for minValue and 100 for maxValue you will get all the log results redirected to your code.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-14-2018, 12:31 PM
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,229
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: How to redirect NetworkTables error output to file?

https://github.com/wpilibsuite/allwp...ogMessage.java

The actual min an max values to passed in are located here.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-14-2018, 03:04 PM
0x54796C6572's Avatar
0x54796C6572 0x54796C6572 is offline
Registered User
AKA: Tyler Tian
FRC #6135 (Arctos)
Team Role: Programmer
 
Join Date: Apr 2018
Rookie Year: 2017
Location: Toronto, Ontario, Canada
Posts: 12
0x54796C6572 is an unknown quantity at this point
Re: How to redirect NetworkTables error output to file?

I tried using the method, and it successfully directed all the error messages to the file. Thank you so much for the help!
Reply With Quote
Reply


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 05:26 AM.

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


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