Log in

View Full Version : Reading input from NetConsole


chadbarbe1
06-02-2011, 15:29
I was reading this link:

http://firstforge.wpi.edu/sf/wiki/do/viewPage/projects.wpilib/wiki/FAQ#section-FAQ-NetConsole

And it says that NetConsole provides a bi-directional link between some external client program and the cRIO. It also says that the NetConsole client is built into the NetBeans plugins. This implies that you could create a simple command line menu in your NetBeans console to intereact with the application running on your robot.

I can see that System.out is directed to the NetBeans console but how do you read input typed into that console with your Java code? System.in does not seem to even be a valid symbol.

Thanks!

CHAD

kinganu123
06-02-2011, 23:09
Not sure how you'd send it to the cRIO, but in order to read input from the keyboard, you'd do the following
import java.util.Scanner;
main{
Scanner scn = new Scanner(System.in);
System.out.println("Enter command:");
string command = scn.nextLine();//or it might be scn.nextString()
//Send command to cRIO
}

chadbarbe1
07-02-2011, 08:18
Thanks for the reply kinganu123!

Unfortunately, the Scanner and System.in approach was the first thing i tried. Have you gotten that code to compile for the robot? It would seem we are relegated to java 1.4 in which the Scannner class does not exist.

I think the real question I have is, is there any documentation on the NetConsole server and how to interact with it from user robot code running on the cRIO?

Joe Ross
07-02-2011, 09:41
One thing to realize is that the port that netconsole uses is blocked by the field, so anything you develop could be for home use only.

chadbarbe1
07-02-2011, 09:47
Joe- understood. I want to implement a command line menu to help me tune my pid controllers without recompiling every 5 seconds. This is for development purposes only of course.

Patrickwhite
07-02-2011, 15:11
It seems that the NetConsole was developed primarily for C/C++ users wanting to see output directly from the robot, with the sending function added as an unfinished afterthought. The documentation, as you've discovered, is almost nonexistent. A search on CD turns up nothing regarding sending through NetConsole.
You may wish to try using old-fashioned methods, like the Analog Inputs on the driver station. While tuning our PID loops, we used unused buttons on the gamepad we were using to increment and decrement the values and having the DriverStationLCD read the values itself.

jhersh
08-02-2011, 02:29
NetConsole is bidirectional and is implemented fully in both directions. The documentation does leave a bit to be desired at this point, but when I implemented it, there was very little to it and no options to speak of.

That being said, I'm not sure that this applies well to Java since there are (probably) two pieces missing in that part of the world. The NetConsole client code that's built into NetBeans plugin is (probably) not bidirectional (I haven't tried it, but I'm not aware of that being a use-case that was considered). I'm also not sure that the JVM implements the methods needed to read from the terminal. Perhaps Derek can chime in.

In C++, scanf or getc can be used to read from the terminal (serial or NetConsole, it doesn't know the difference) and the standalone NetConsole client sends and receives (I use this regularly to reboot the robot with ctrl-x and to run VxWorks commands on the console). You may be able to simply call the C functions for reading from the console through the JNA interfaces and then use the standalone NetConsole client. One complication that you may run into is how to start your application such that the console is bound to your task and is not bound to the shell. I haven't tried that aspect of it in the context of a robot program.

-Joe

omalleyj
08-02-2011, 07:48
Joe- understood. I want to implement a command line menu to help me tune my pid controllers without recompiling every 5 seconds. This is for development purposes only of course.

This doesn't help reading from the console but does address what you are trying to do: add a potentiometer to an analog in and scale the value to the P, I, or D range you are trying. Its fast and no typing.