Subject:
|
iCommand 0.5: Bluetooth API problem
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Wed, 18 Apr 2007 08:38:41 GMT
|
Original-From:
|
davis_nxt <le.m.duc@gmail{Spamcake}.com>
|
Viewed:
|
4913 times
|
| |
| |
Hi,
We are in the process of evaluating different NXT programming tools for our
project and currently
having some problems with the reliability of the the iCommand 0.5 Java
library.
We wrote a simple Java app that
connects to the NXT and reads some basic device information and a text file
to demonstrate the API's capability (see below for the code).
The app is configured to run on a TabletPC: Windows XP TabletPC Edition
2005, SP2 +
Bluetooth. The NXT fiirmware was upgraded to the latest version 1.04.
The problem we are having is that the app does not work consistently! It
seems to work once (i.e. device name and file content are displayed
correctly) but failed to read any information off the device in subsequent
runs.
I have searched the net for information related to the iCommand API as well
as looking at the code and found some people having similar problem which
appears to be related to the way NXTCommand.close*() methods work.
A common suggestion to get arround this problem which we found seems to be:
turning off/on the NXT and sometimes even unparing/re-paring the PC with it.
Has anyone experienced this problem and found a programming solution?
The strange thing is that the nexttool command line seems to work everytime
so I suspect that the problem would lie in the way iCommand implements the
NXT Bluetooth protocol or in a bug in the underlying rxtx comm api itself.
The NXT Bluetooth protocol spec does not mention any additional system
commands that should be sent to the NXT when closing the connection. The
source code of the NXTCommand.close() method is rather simple: it instructs
the underlying rxtx comm api to close its in and out streams as well as the
commPort.
Any pointers would be greatly appreciated.
Thanks,
Davis
<<< Java app >>
public static void main(String[] args) {
DeviceInfo devInfo = NXTCommand.getDeviceInfo();
System.out.println("Name is " + devInfo.NXTname);
System.out.println("Device status: " + devInfo.status);
System.out.println("Bluetooth address: " +
devInfo.bluetoothAddress);
System.out.println("Free flash memory: " + devInfo.freeFlash);
byte reply = 0;
FileInfo fileinfo = NXTCommand.openRead("csvtest.csv");
System.out.println("File size is " + fileinfo.getFileSize());
if (fileinfo.getFileSize() == 0) {
System.out.println("Could not read file " + fileName);
} else {
byte[] cont = NXTCommand.readFile(fileinfo.fileHandle,
fileinfo.getFileSize());
System.out.println("File: "+ fileinfo.fileName + ": " + new
String(cont));
// wait after read
sleep(2000);
}
reply = NXTCommand.closeFile(fileinfo.fileHandle);
System.out.println("Close file cmd status: " + reply);
// wait
sleep(2000);
NXTCommand.close();
//wait
sleep(5000);
}
private static void sleep (int millisecs) {
try {
Thread.sleep(millisecs);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
--
View this message in context: http://www.nabble.com/iCommand-0.5%3A-Bluetooth-API-problem-tf3599630.html#a10054524
Sent from the LEGO Robotics mailing list archive at Nabble.com.
|
|
Message has 1 Reply: | | Re: iCommand 0.5: Bluetooth API problem [Solved]
|
| Hi, Although I have not been able to work out the cause of the Bluetooth communication problem with the iCommand API mentioned in my last post, I have managed to code a 'bridge' DLL for my Java application to use the Lego's Fantom.DLL. The bridge (...) (18 years ago, 20-Apr-07, to lugnet.robotics)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|