iCommand and Ultrasonic Sensor

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

iCommand and Ultrasonic Sensor

Postby rikiwarren » Tue Feb 20, 2007 4:39 am

I'm trying to use the ultrasonic sensor from iCommand, but I keep getting errors. Do you need to initialize the sensor before using it?

Here's my code:


import icommand.platform.nxt.*;

public class Test{

public static void main(String[] args){

Ultrasonic sensor = new Ultrasonic(Sensor.S4);
System.out.println(sensor.getSensorType());

while (true)
System.out.println("Distance: " + sensor.getDistance());
}
}

Here's the errors:

Looking for 'icommand.properties' in working dir: /Users/riki/Develop/icommand-0.5/samples
NXTCOMM = /dev/tty.RikiBot-DevB-1
Experimental: JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
RXTX Warning: Removing stale lock file. /var/lock/LK.003.010.000
NXTCommand.LSGetStatus() error: Specified channel connection not configured or busy
NXTCommand.LSGetStatus() error: Pending communication transaction in progress
Sonar
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
...

Thanks,

-Rich-
rikiwarren
New User
 
Posts: 1
Joined: Tue Feb 20, 2007 4:35 am

Postby bbagnall » Sun Feb 25, 2007 8:49 am

You can make it more stable by:
1) Upgrading your firmware to 1.04.
2) Try using NXTCommand.setVerify(true);

I think our current code has this fixed but we haven't done a release in a while.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

cron
more stuff