Hi Brian,
I ran the DistanceTest code with one modification - I commented out the
first line in main, namely
NXTCommand.open();
as there does not seem to be such a method available. Is this a typo or do
you have a new method not present in icommand 0.5?
In any even, running the code without that line gives the results listed
below. As you can see all of the distance measures fail, along with
generating some other error messages.
I also ran the code with the "setVerify" line uncommented, and attach that
output below as well. There was an object about 18 cm from the sonar sensor.
All of this is being done with icommand 0.5, using Eclipse 3.2.1, Java 1.4.2
on a Mac Powerbook, OS X 10.4.6, built-in Bluetooth.
Hope this is helpful,
Myles
------------------
> Can you try this code and paste the results here:
>
> import icommand.nxtcomm.NXTCommand;
> import icommand.platform.nxt.Sensor;
> import icommand.platform.nxt.Ultrasonic;
>
> /**
> * Outputs some data from an Ultrasonic sensor in port 1.
> *
> * @author BB
> *
> */
> public class DistanceTest {
>
> public static void main(String[] args) {
> NXTCommand.open();
>
> //NXTCommand.setVerify(true);
> Ultrasonic us = new Ultrasonic(Sensor.S1);
> System.out.println("Version: " + us.getVersion());
> System.out.println("Product ID: " + us.getProductID());
> System.out.println("Sensor Type: " + us.getSensorType());
> System.out.println("Measurement Interval: "
> + us.getMeasurementInterval());
> for(int i=0;i<10;i++)
> System.out.println("Distance: " + us.getDistance());
> System.out.println("Factory scale factor: "
> + us.getFactoryScaleFactor());
> System.out.println("Factory scale divisor: "
> + us.getFactoryScaleDivisor());
> byte[] distances = us.getDistances();
> for (int i = 0; i < distances.length; i++)
> System.out.println("Distance " + i + " = " + distances[i]);
>
> NXTCommand.close();
> }
> }
>
> - Brian
-------without setVerify ------------
Looking for 'icommand.properties' in working dir:
/Users/myles/Documents/workspace/SonarTest
Looking for 'icommand.properties' in home dir: /Users/myles
NXTCOMM = /dev/tty.NXT_1
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
NXTCommand.LSGetStatus() error: Specified channel connection not configured
or busy
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
NXTCommand.LSGetStatus() error: Communications Bus Error
No bytes to be read in I2CSensor.getData(). Returning 0.
Version:
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
Product ID: LEGO
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
Sensor Type: Sonar
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
Measurement Interval: 1
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance: 0
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
Factory scale factor: 1
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
Factory scale divisor: 14
NXTCommand.LSGetStatus() error: Pending communication transaction in
progress
No bytes to be read in I2CSensor.getData(). Returning 0.
Distance 0 = 0
Experimental: JNI_OnLoad called.
-------with setVerify ------------
Looking for 'icommand.properties' in working dir:
/Users/myles/Documents/workspace/SonarTest
Looking for 'icommand.properties' in home dir: /Users/myles
NXTCOMM = /dev/tty.NXT_1
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
NXTCommand.LSGetStatus() error: Communications Bus Error
No bytes to be read in I2CSensor.getData(). Returning 0.
Version:
Product ID: LEGO
Sensor Type: Sonar
Measurement Interval: 1
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Distance: 18
Factory scale factor: 1
Factory scale divisor: 14
Distance 0 = 64
Distance 1 = -1
Distance 2 = -1
Distance 3 = -1
Distance 4 = -1
Distance 5 = 0
Distance 6 = 0
Distance 7 = 0
Experimental: JNI_OnLoad called.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion