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


Daniele Ricci wrote:
> thanks uhu!
> This is the output:
> -------------
> run:
> Waiting for the socket
> Socket is ready
> -----------------
> But, can you do something for my situation?
> Even if I write only 2 lines in a message,whitout applet, it isn't sent 
> and no one says nothing to me.
> 
>  > Date: Mon, 17 Aug 2009 08:43:41 +0200
>  > From: [email protected]
>  > To: [email protected]
>  > Subject: Re: comunication client-serialforwarder
>  >
>  > Hi Daniele,
>  >
>  > I think the most likely reason for this to not work is that the browser
>  > refuses the applet to open the network connection.
>  >
>  > To get more details from your code, could you replace the Client class
>  > with the following one (has more debugging output) and show me the 
> output?
>  >
>  >
>  > // ----------------------------------------
>  >
>  > class client implements ActionListener {
>  > public void actionPerformed(ActionEvent e1) {
>  > try {
>  > Socket skt = new Socket("localhost",9002);
>  > BufferedReader in = new BufferedReader(new
>  > InputStreamReader(skt.getInputStream()));
>  >
>  > System.out.println("Waiting for the socket");
>  > 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());
>  > jTextArea1.append("Server: " + message);
>  >
>  > System.out.print(messaggio + "out.print\n");
>  > in.close();
>  > }
>  > catch(Exception e) {
>  > System.out.print("Whoops! It didn't work! \n");
>  > e.printStackTrace();
>  > }
>  > }
>  >
>  > // ----------------------------------------
>  >
>  > If you are using Firefox, the output should appear in the error console
>  > (tools -> error console).
>  >
>  > Cheers,
>  > Urs
>  >
>  >
>  > Daniele Ricci wrote:
>  > > I tried to send a different message from the original.
>  > > Without attachments and very short. This was also ignored and they 
> don't
>  > > say to me that it is stopped (stange).
>  > >
>  > > However I attack my applet to you, is very simple, it runs locally and
>  > > can connect to sf but wait messages (packets sent by the node) that
>  > > never get.
>  > > Look if you can do something.
>  > > thanks.
>  > >
>  > > ps. you can see that the file is small...
>  > >
>  > > > Date: Sun, 16 Aug 2009 20:26:07 +0200
>  > > > From: [email protected]
>  > > > To: [email protected]; [email protected]
>  > > > Subject: Re: comunication client-serialforwarder
>  > > >
>  > > > Hi Daniele,
>  > > >
>  > > > Your message might not have been forwarded if you added an 
> attachment. I
>  > > > regularly have difficulties with attachments when sending a 
> message to
>  > > > this mailing list.
>  > > >
>  > > > How do you know that the applet connects to the SerialForwarder? 
> Did you
>  > > > check for errors on the applet console? (if you don't know how to do
>  > > > this, what browser do you use and which version?)
>  > > >
>  > > > Usually, the applet runs in a special sandbox inside the browser 
> and can
>  > > > only connect to the server hosting the applet. So your 
> SerialForwarder
>  > > > would have to run on the webserver. If you use the local machine 
> for the
>  > > > webserver, the sandbox environment might make a difference between
>  > > > "127.0.0.1" and the IP address of one of your network interfaces. 
> Check
>  > > > that you are using the right IP address (the same for the server 
> and for
>  > > > connecting to the serial forwarder). If you open the applet through a
>  > > > file link, I don't know what happens.
>  > > >
>  > > > Cheers,
>  > > > Urs
> 
> ------------------------------------------------------------------------
> Crea l'Avatar con la tua faccia. Personalizza il tuo Messenger! 
> <http://avatarstudio.it.msn.com/>

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to