I am using LeJOS NXJ 0.7 and NetBeans 6.5 on Vista with Bluetooth. All my environment variables and classpath variables are fine.
About 50% of the time when I am uploading files to the brick, it freezes up and I get the clicking sound. I'm not sure where to begin looking for a reason why.
Here's the program (super simple first iteration):
- Code: Select all
import lejos.nxt.*;
/**
* A program that operates on the Lego NXT Brick
*
* @author Christopher
*/
public class MainClass {
private final TouchSensor touch;
public MainClass() {
touch = new TouchSensor(SensorPort.S1);
SensorPort.S1.addSensorPortListener(new TouchListener());
}
public void run() {
Motor.A.forward();
while (Motor.A.isMoving()) {
}
}
public static void main (String[] args) {
MainClass test;
// System.out.println("Press the Orange button to begin");
// Button.waitForPress();
test = new MainClass();
Motor.A.getTachoCount();
test.run();
}
private class TouchListener implements SensorPortListener {
public void stateChanged(final SensorPort arg0,
final int oldValue,
final int newValue) {
if (newValue < 900) {
System.out.println("Press the Orange button to continue");
Button.waitForPress();
Motor.A.stop();
}
}
}
}
And here's my build file:
- Code: Select all
<project name="LeJOS_Brick_1" default="uploadandrun">
<description>
LeJOS Project build file for Project 001
</description>
<!-- set properties for this build -->
<property environment = "env"/>
<property file="template.properties"/>
<property name="src" location="."/>
<property name="program" value="MainClass"/>
<property name="class" value="MainClass" />
<property name="binary" value="${program}.nxj" />
<!-- deletes class files -->
<target name="clean" description="clean up all generated files">
<delete>
<fileset dir=".">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="compile" depends="clean"
description="compile the source " >
<!-- Compile the java code from ${src} -->
<javac srcdir="${src}" destdir="${src}">
<bootclasspath>
<pathelement location="${nxj.classes.home}/lib/classes.jar"/>
</bootclasspath>
</javac>
</target>
<target name="link" depends="compile"
description="link the binary " >
<!-- Link the binary and create a signature file -->
<java classname="js.tinyvm.TinyVM">
<arg value="--classpath"/>
<arg path="${nxj.classes.home}/lib/classes.jar:." />
<arg value="--writeorder" />
<arg value="LE" />
<arg value="${class}"/>
<arg value="-o"/>
<arg value="${binary}"/>
<arg value="-v"/>
<classpath>
<pathelement location="${nxj.jtools.home}/lib/jtools.jar"/>
<pathelement location="${nxj.jtools.home}/3rdparty/lib/commons-cli-1.0.jar"/>
<pathelement location="${nxj.jtools.home}/3rdparty/lib/bcel-5.1.jar"/>
</classpath>
</java>
</target>
<target name="upload" depends="link"
description="upload the binary " >
<java classname="lejos.pc.tools.NXJUpload" fork="true">
<jvmarg value="-Djava.library.path=${nxj.library.path}"/>
<arg value="${binary}"/>
<classpath>
<pathelement location="${nxj.jtools.home}/lib/jtools.jar"/>
<pathelement location="${nxj.pctools.home}/lib/pctools.jar"/>
<pathelement location="${nxj.pccomm.home}/lib/pccomm.jar"/>
<pathelement location="${nxj.jtools.home}/3rdparty/lib/commons-cli-1.0.jar"/>
<pathelement location="${nxj.jtools.home}/3rdparty/lib/bcel-5.1.jar"/>
<pathelement location="${nxj.pccomm.home}/3rdparty/lib/bluecove.jar"/>
</classpath>
</java>
</target>
<target name="uploadandrun" depends="link"
description="upload and run the binary " >
<java classname="lejos.pc.tools.NXJUpload" fork="true">
<jvmarg value="-Djava.library.path=${nxj.library.path}"/>
<arg value="${binary}"/>
<arg value="-r"/>
<classpath>
<pathelement location="${nxj.jtools.home}/lib/jtools.jar"/>
<pathelement location="${nxj.pctools.home}/lib/pctools.jar"/>
<pathelement location="${nxj.pccomm.home}/lib/pccomm.jar"/>
<pathelement location="${nxj.jtools.home}/3rdparty/lib/commons-cli-1.0.jar"/>
<pathelement location="${nxj.jtools.home}/3rdparty/lib/bcel-5.1.jar"/>
<pathelement location="${nxj.pccomm.home}/3rdparty/lib/bluecove.jar"/>
</classpath>
</java>
</target>
</project>
My template.properties file:
- Code: Select all
nxj.classes.home=${env.NXJ_HOME}
nxj.jtools.home=${env.NXJ_HOME}
nxj.pctools.home=${env.NXJ_HOME}
nxj.pccomm.home=${env.NXJ_HOME}
nxj.library.path=${env.NXJ_HOME}/bi
Does anyone have any suggestions? Thanks in advance,
Chris

