Monday, November 17, 2008

External Jars In Host Application SUNSPOTS

If you want to include host apps in windows under Netbeans, adding it to classpath in properties is not enough, you actually need to go to the build.properties file and add the path there

example:

C:\Program Files\NetBeans 6.1\java2\modules\ext\AbsoluteLayout.jar:C:/jar/pccomm.jar:C:/jar/bluecove.jar

Note that the directory seperators should be "/" instead of "\".

Thursday, November 13, 2008

SunSpots + Lejos

Recently, I have been working on trying to get Lejos (Java For Lego) on Mac.
And I got no where. Lejos do not have mac universal install package so had to swith to windows.
It took me few about an hour to install lejos and eclipse. However eclipse did not do a great job setting Lejos up as an update. So I went back to the basic of uploading my program to NXT via bluetooth on terminal.

Lejos tutorial is good interms of explaining how to use the api's however they dont tell you anything about which libs you need to set up to get the bluetooth working or maybe I just missed
it.

First of you need to set you bluetooth with windows. You need to go to control panel and search for NXT bluetooth. NXT's bluetooth should be on and visible. After it is detected you need to choose the read pass from documentation box and type the passphrase which is 1234.
This should enable the bluetooth connection. Now you can upload your apps via bluetooth rather than USB.

But not yet there:

If you are writing a host application which communicates with the NXT via BlueTooth, there are few things that one has to pay attention to: first of all unlike a regular NXT app you should not use the classes.jar that comes with Lejos. The classes.jar should only be used for apps that runs on NXT. Second you need to add the bluecove.jar file which is in lejos 3rdparty folder.
If all goes well. Bluetooth should work



Lejos did a great job of abstracting the bluetooth stack from the user. All you need to do is to
NXTCommFactory class to create connections. The details are in the Documentation.

Wednesday, November 12, 2008

Reset Button Does not work.

This issue usually arise when user sets one of the Threads with a higher priority.  Interestingly SUN did not create a tool to flush the memory with out asking user to reset the spots by pressing the reset button. 

I found a solution around this problem.

Here is how it goes: 

1. Disconnect the Sun SPOT from the USB cable
2. Kill all the ant and java processes listening on the port
3. Hold the control button in for a few seconds until a double red flash indicates that the Sun SPOT has powered down (NB doing this *after* disconnecting).
4. Type this command at a command prompt:
ant -Dport=xxx upgrade
where xxx is the port name
5. Plug it in as soon as the ant script starts to complain that the port isn't available. *Don't* push the reset button: this isn't necessary and may confuse. 

Wednesday, November 5, 2008

Adding external jars under Netbeans for sunspot settings

Adding external jars in Netbeans under a project created for sonspots are a bit tricky.
Even if you are using a sunspot host application. 

To add a jar file you need to do only do one thing if you are using "blue", which you should anyway.

You need to go to the properties.build file and add extra jar files there.

I am in this example adding restlet jar files.  

user.classpath=/Applications/NetBeans.app/Contents/Resources/NetBeans/platform6/modules/ext/swing-layout-1.0.jar:/Applications/NetBeans.app/Contents/Resources/NetBeans/ide7/modules/ext/AbsoluteLayout.jar:/Users/evrenbingol/SPOTUI/lib/org.restlet.jar:/Users/evrenbingol/SPOTUI/lib/com.noelios.restlet.jar:/Users/evrenbingol/SPOTUI/lib/com.noelios.restlet.ext.servlet_2.4.jar



Last three jar files are external and the first one is netbeans set.

Sunday, October 19, 2008

AODV specific

aodv is not a link state algorithm which means that it would take a while to get the right hop counts since aodv needs to calculate the routes and hop counts on the fly
One way to cheat is to broadcast a message from each spot as your app initializes. This creates the missing routes in you aodv table. Which means that when you query the table entries later on you get the right results. 

Saturday, October 18, 2008

Sun Spot Deep Sleep AODV

Stopping the network threads for deep sleep.
Since the release of the blue API, aodv classes provide methods for putting the treads on hold
You can get to the functions bye calling the routing manager instance.

Friday, September 26, 2008

Debugging Sun Spots

The best way to debug, if you are not connected to your computer via USB, is to use the HTTP protocol and post the errors on line in your try catches.