hi everyone,
I am new to this forum, I have a problem in using ultrasonic sensor over bluetooth(icommand-0.7).
whenever iam trying to create an object of ultrasonic sensor it givs the following error:-
-----------------------------------------------------------------------------------------------
### command prompt OUTPUT ###
C:\icommand\samples\AMIT>java dtest
Properties location: C:\Documents and Settings\srl-amit\icommand.properties
BlueCove version 2.0.0 on winsock
Lets Start =====
Exception in thread "main" java.lang.NegativeArraySizeException
at icommand.nxt.comm.NXTCommand.LSRead(Unknown Source)
at icommand.nxt.I2CSensor.<init>(Unknown Source)
at icommand.nxt.UltrasonicSensor.<init>(Unknown Source)
at dtest.main(dtest.java:12)
BlueCove stack shutdown completed
-----------------------------------------------------------------------------------------------
the code for the above program is as shown below:-
import icommand.nxt.*;
import icommand.nxt.comm.NXTCommand;
public class dtest
{
private static final short[] note = { 2349, 115, 0, 5 };
public static void main(String[] args) throws Exception
{
NXTCommand.open();
NXTCommand.setVerify(true);
System.out.println("Lets Start ===== ");
TouchSensor t = new TouchSensor(SensorPort.S4);
UltrasonicSensor u = new UltrasonicSensor(SensorPort.S2);
LightSensor l = new LightSensor(SensorPort.S3);
SoundSensor s = new SoundSensor(SensorPort.S1);
System.out.println("Light Value = "+l.getLightValue());
System.out.println("Sound Value = "+s.getdB());
System.out.println("\nNow press the touch sensor for a sec sec.\n");
try {
Thread.sleep(2000);
} catch(InterruptedException ie) {}
if(t.isPressed())
{
System.out.println("touch sensor is pressed\n");
}
else
System.out.println("touch sensor is not pressed\n");
System.out.println("working!!\n\n");
NXTCommand.close();
}
}
and if i remove the line which creates object of ultrasonic sensor then it working, and the output of the above code after removing the line which creates object of ultrasonic sensor is :-
-----------------------------------------------------------------------------------------------
### command prompt OUTPUT ###
C:\icommand\samples\AMIT>java dtest
Properties location: C:\Documents and Settings\srl-amit\icommand.properties
BlueCove version 2.0.0 on winsock
Lets Start =====
Light Value = 378
Sound Value = 35
Now press the touch sensor for a sec sec.
touch sensor is pressed
working!!
BlueCove stack shutdown completed
-----------------------------------------------------------------------------------------------
i have changed the ultrasonic sensor by anther one and trying with the different sensor ports but the error is same (as shown above), more importantly the ultrasonic sensor and the nxt brick are working fine when i am running same type of program using nxj [lejos NXJ8.5](which displays the results on the NXT bricks screen), i also tested the above program in another nxt brick but the same problem occurs.
So please help me.............
AMIT KR MANDAL
[email - amit.dgp12@gmail.com]
Surface Robotics Laboretrary
Central Mechanical Engineering Research Institute
Durgapur, India[/code]
