I am not sure what you mean by "put my applet into the package sf", but
you probably should not do that.
At the beginning, you'll have to import the packages that you will need.
E.g.:
import net.tinyos.comm.*;
import net.tinyos.packet.*;
...
Then you will have to replace the whole networking stuff (this will be
done by the TinyOS libraries).
The first line in the code below defines the access string to the serial
forwarder (check the mote-pc communications tutorial for details). The
second line creates a PhoenixSource (not sure what it is exactly, but I
think it is a low-level communication object that will then communicate
with the serial forwarder). The third line will then create the actual
mote interface where you will be able to register the appropriate
listener for your packet format.
If you haven't implemented a standalone application, I strongly suggest
that you do this first and then port this application later to an
applet. It is much easier to debug a standalone application, plus you
get step-by-step instructions from the TinyOS tutorials (really, read
the mote-pc communications chapter!) and sample code.
Cheers,
Urs
Daniele Ricci wrote:
> ok.
> I have put my applet into the package sf.
> So it can seen the libreries.
>
> what do exactly this code?
> ------------------------------
> String comm = "s...@localhost:9002";
> PhoenixSource ps = BuildSource.makePhoenix(comm, PrintStreamMessenger.err);
> MoteIF mif = new MoteIF(ps);
> ------------------------------
>
> I have jast add this to print the commands?
>
> Or should I change this?
> --------------------
> while (!in.ready()) {}
> System.out.println("Socket is ready");
> String message = in.readLine();
> System.out.print("Received string1: " + message + "\n");
> System.out.println(in.readLine());
> --------------------------------
> thanks!
>
> > Date: Mon, 17 Aug 2009 10:59:16 +0200
> > From: [email protected]
> > To: [email protected]; [email protected]
> > Subject: Re: comunication client-serialforwarder
> >
> > Hi Daniele,
> >
> > The network connection is indeed established (I thought this might be
> > the problem)! I guess that the serial forwarder protocol is a binary
> > protocol and that it does not send Strings or carriage returns, so your
> > code will not be able to read lines (though it could read bytes).
> >
> > The best way to interact with the serial forwarder is probably to use
> > the TinyOS Java libraries. You would have to include the packages that I
> > recommended to you in a previous mail (also on the TinyOS help mailing
> > list): comm, message, packet, and utils (maybe sf and/or tools are
> > needed as well, but I don't think so).
> >
> > In your applet, you could establish the connection to the serial
> > forwarder with code like this:
> >
> > // ------------------------------
> >
> > String comm = "s...@localhost:9002";
> > PhoenixSource ps = BuildSource.makePhoenix(comm,
> PrintStreamMessenger.err);
> > MoteIF mif = new MoteIF(ps);
> >
> > // ------------------------------
> >
> > of course you'll have to import the appropriate packages and you need to
> > include the TinyOS Java library classes into the jar file of your
> > applet. If you get an error about not being able to load the native
> > libraries, you'll have to modify the appropriate TinyOS library files
> > and remove the corresponding "System.load(..)" lines, they are not
> > really needed for this purpose.
> >
> > Cheers,
> > Urs
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help