![]() |
Deploying a FRC Java project via command line interface?
Hi,
I was wondering if anyone were aware of how one could deploy code to a robot through another application. I'm essentially looking for being able to run the following in command prompt, and have compilation and deployment done for me: > "pathToExecutable" maybe something "pathToRobotCodeNetbeansProject" anything else Thanks, |
Re: Deploying a FRC Java project via command line interface?
So yesterday I had my last final. This morning I started working on this stuff again, and apparently, it's not so complicated.
I used API Monitor to look at the CreateProcessA/CreateProcessW calls Netbeans was making. The maximum captured string size isn't big enough, so you'll have to write another program to read whatever's being printed (or replace the executable with one that just prints out the arguments). I've copy and pasted one at the bottom of this post. It's in C++. But anyways, the command line arguments for building a project were as follows: $JAVA_PATH $JAVAC_PATH $NB_PROJ_DIR $NB_PROJ_NAME $WPILIBJ_DIR $SUNSPOTFRCSDK_DIR $ENTRYPOINTJAVAFILE_PATH If you plan to run any of these commands, ensure your current directory is set to $NB_PROJ_DIR, or the last 2 steps fail. These calls will probably change whenever "FRC Java" is updated. I didn't include anything on the process of verification... I'm going to look for that stuff now, and update this post accordingly. I'm not sure how badly you can brick the cRIO by screwing up here - I'd advise for people to leave the job of replacing jvm and squawk.out files to Netbeans, which is actually well tested. Delete $NB_PROJ_DIR\build Delete $NB_PROJ_DIR\suite Delete $NB_PROJ_DIR\j2meclasses Create $NB_PROJ_DIR\build Create $NB_PROJ_DIR\suite Create $NB_PROJ_DIR\j2meclasses Code:
$JAVAC_PATH -d "$NB_PROJ_DIR\build" -classpath "$NB_PROJ_DIR\build;$WPILIBJ_DIR\src" -target 1.2 -bootclasspath $SUNSPOTFRCSDK_DIR\lib\squawk_device.jar -g -source 1.3 $ENTRYPOINTJAVAFILE_PATHCode:
$SUNSPOTFRCSDK_DIR\bin\preverify -d j2meclasses -classpath $SUNSPOTFRCSDK_DIR/lib/squawk_device.jar;$SUNSPOTFRCSDK_DIR/lib/WPILibJ/src;;;j2meclasses buildI actually have no clue what this does - I'm a C# person, and I sort of don't know the internals of Java, much. Code:
$JAVA_PATH -XX:CompileCommand=exclude,com/sun/squawk/Method.getParameterTypes -XX:CompileCommand=exclude,com/sun/squawk/SymbolParser.getSignatureTypeAt -XX:CompileCommand=exclude,com/sun/squawk/SymbolParser.stripMethods -Xmx256M -classpath $SUNSPOTFRCSDK_DIR\bin\romizer_classes.jar;$SUNSPOTFRCSDK_DIR\bin\squawk.jar;$SUNSPOTFRCSDK_DIR\bin\squawk_device_classes.jar;$SUNSPOTFRCSDK_DIR\bin\translator_classes.jar com.sun.squawk.Romizer -nobuildproperties -nobuildproperties -suitepath:$SUNSPOTFRCSDK_DIR/cRIO -boot:squawk -metadata -lnt -strip:d -cp:suite\$NB_PROJ_NAME_1.0.0.jar -endian:big -o:image "$NB_PROJ_DIR\suite\$NB_PROJ_NAME_1.0.0.jar"Netbeans connects to the robot through FTP. The authentication is anonymous ("USER .." "PASS ..") Code:
RETR /FRC_ImageVersion.iniCode:
RETR /ni-rt/system/FRC_JavaVM.outCode:
RETR /ni-rt/system/squawk.outCode:
RETR /ni-rt/system/squawk.suitePretty sure this is just another verification step Code:
STOR /ni-rt/system/robot.suiteNB then connects to the robot and sends something (i forget the exact string) like "!RUN!", which, I assume, restarts the robot? The following program was injected into Netbeans to capture whatever CreateProcessA's parameters were. You'll have to use Microsoft Detours http://research.microsoft.com/en-us/projects/detours/ The program was compiled with Visual Studio 11. Code:
#define DETOURS_X86Code:
Thu Jun 07 14:29:34 2012| NOTICE| Dargon.Maestro injected with hModule 0FCC0000 |
Re: Deploying a FRC Java project via command line interface?
I think what you're looking for is ant. Netbeans uses the ant build system to build and deploy the code to the robot. Netbeans just uses ant commands, which are already defined to do the tasks you mentioned above.
To build and deploy the code from my vim setup, I used ant. I don't remember exactly what shell commands I used because I deleted my setup, but you might be able to figure it out by typing "ant help". I remember that Netbeans' build window prints the ant shell command it's using before executing it. Also see the project.xml file in the nbproject folder (sample from my team's repo). (There should also be something similar displayed as a GUI in the project settings in Netbeans). It defines the build action as "jar-app" and the run action as "deploy" then "run". So building and deploying the code and watching it run should be as simple as: Code:
ant jar-appI'm impressed that you went to the trouble of injecting code into Netbeans to reverse-engineer the build/deploy process. It's interesting. Did you figure out what it does on FTP via Wireshark? |
Re: Deploying a FRC Java project via command line interface?
Quote:
|
Re: Deploying a FRC Java project via command line interface?
This looks pretty awesome. Does anyone have anything like this for C++?
|
| All times are GMT -5. The time now is 08:52. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi