You still don't really say what is not working correctly....
However I can guess that your Light/Temp readings are not
coming across properly. There are two problems in the code
you sent...Basically you have to insure that the conversions
take place sequentially.
First...oops I forget what kind of motes you have so I'm
going to assume mica's...The mica sensorboards share an ADC
for the light and temp sensors so you can only use one at once.
I believe the Light and Temp components deal with switching
the right things on and off, so I think you are calling them
correctly.
Second, the ADC can only do one conversion at a time anyway,
so what you want to do is fire off one, say Light, from the
Timer.fired() and then start the second, Temp, from
Light.dataReady()
The warning you get:
C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc:63:
warning: `result' might be used uninitialized in this function
Is just a warning that whomever wrote the RealMain function forgot
to initialized a return value that is probably never used anyway...
Hopefully that fixes the TOS side of things.
On the Java side I'm also somewhat unclear on the concept. It seems
that you have your nice room graphics program and want to extract
data from a TOSMsg to print in the boxes? If so, Listen is a good
model because of it's straightforward getting of connections and
reading of data, but you will need to parse the message appropriately.
If you wish to torture yourself you can use "mig" to generate a java
class for the OscopeMsg (or they might have done that already).
Otherwise you can just count up the number of bytes (based on the
TOS_Msg and OscopeMsg structs) and grab the data of interest.
I know for instance, again with mica2 motes, that the first byte of
the OscopeMsg is buf[5] from the beginning, and that each field is
two bytes long. The one trick is that the bytes are little-endian
so, to make a java int, you have to swap them something like this:
// convert buffer at byte 'start'
// from a little-*f**king*-endian int into a Java int
protected static int ti( byte[] buf, int start )
{
return ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
}
You can see an extended example of this in my code at:
http://www.etantdonnes.com/Motes/robocode.tar.gz
Converting the int to temp and light quantities is mentioned in the
getting started guides I think, but I would take the conversion
formula with a few grains of salt. I think the sensors are fairly
linear, so if you can figure out a way to calibrate one set of
readings you should be able to extrapolate a range.
MS
Xenia Economidou wrote:
Dear Michael,
I am grateful for your reply. I count a lot on your help since I am
stuck with my final year project and I run the danger of not finishing
it on time. I have sent to the list further questions as I have done
what you advised but still need more help (i.e. on how to use Listen and
get rid of the warnigns). I hereby sent you a copy of the code, if you
could please look at it. I don't know what is wrong with it.
Your help is very important to me.
Thank you,
Xenia
From: /Michael Schippling <[EMAIL PROTECTED]>/
To: /Xenia Economidou <[EMAIL PROTECTED]>/
CC: /[email protected]/
Subject: /Re: [Tinyos-help] Oscope codes - HELP!/
Date: /Sun, 12 Mar 2006 14:34:39 -0700/
MIME-Version: /1.0/
Received: /from sapello.lcwireless.net ([67.131.73.161]) by
bay0-mc1-f10.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830);
Sun, 12 Mar 2006 13:34:39 -0800/
Received: /from sapello.lcwireless.net (localhost [127.0.0.1])by
sapello.lcwireless.net (Postfix) with ESMTPid D3BDC18E62; Sun, 12
Mar 2006 14:34:38 -0700 (MST)/
Received: /from [192.168.1.104] (router.lcwireless.net
[67.131.73.161])by sapello.lcwireless.net (Postfix) with ESMTPid
AE39118E42; Sun, 12 Mar 2006 14:34:38 -0700 (MST)/
>I'm not clear on where you are having problems, TOS or Java or All?
>
>Assuming that you got the Oscope program to work as it stands, then
>you want to modify it to get and send both temp and light readings?
>To do that you should be able to dig down in DemoSensor to see how
>it works, or just toss it out and use PhotoTemp. The latter switches
>on the right sensor and does an ADC reading. You probably want to
>alternate readings and fill the OscopeMsg buffer accordingly.
>
>On the Java side, if you just want to print stuff out to the shell
>window, you could hack up Listen to pretty-print the message buffer
>in any format you like.
>
>Was that the question?
>MS
>
>
>Xenia Economidou wrote:
>>Hello everyone,
>>My name is Xenia Economidou from Queen Mary University (3rd yearer
>>student in Bachelor of Engineering). As part of my final year
>>project, which I have to submit in less than three weeks, I have to
>>link the Oscilloscope application to a Java program in the computer
>>in order to check the values and also print them (e.g. readings for
>>light and temperature). As I am runnig out of time it is very
>>importand for me to get guidance from you as soon as possible.
>>Although I have studied the oscope codes it is still not clear for
>>me where I should start from:
>>a. to print the measurements of the temperature, and
>>b. check the values for light, (i.e. if it is dark or not).
>> Any help from you is greatly appreciated as I am getting closer
>>to the deadline of the project.
>> PLEASE HELP!!
>> Kind Regards,
>>Xenia
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Tinyos-help mailing list
>>[email protected]
>>https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help