This is the "serial forwarder" protocol, which I also discovered the
same way you did.  

First, the client should write write those two characters to the socket.
Then, it should 2 bytes back (they should be the "T " string).
Thereafter, it can read 1 byte of length, followed by the packet, in a loop.

Below is a perl program that I believe works the same as Listen.

Hope this helps,

-Kim.

-------

#!/usr/bin/perl

require "flush.pl";

use IO::Socket;

$host = shift(@ARGV) || "localhost";
$port = shift(@ARGV) || 9001;

$remote = IO::Socket::INET->new(Proto    => "tcp",
                                PeerAddr => $host,
                                PeerPort => $port,
                               )
  or die "cannot connect to port $port at $host";

# Initialize protocol to serialforwarder
print $remote "T ";
$len = read($remote, $foo, 2); # read the "T " back
# print "read $len bytes: |$foo|\n";

my $length;
my $packet;

while (read($remote, $length, 1) == 1) {
    $len = ord($length);
    if (read($remote, $packet, $len) == $len) {
        @data = split(/ */,$packet); # splits each character (byte)
        for ($i = 0; $i <= $#data; $i++) {
            printf("%02x ", ord($data[$i]));
        }
        print "\n";
        flush(stdout);
    }
}



On Wed, Nov 17, 2004 at 04:01:57PM +0100, Libor Roubal wrote:
> Hi All,
> I am using SerialForwarder to serve the data from MIB510 and MICA2s
> on
> a port 9001. I tried to connect to it with my own and other clients
> to
> read the data, but all I get is this two bytes: 84 and 23 (T and
> space
> in Ascii). However, the motes are sending correct values. Has anyone
> encountered any similar problem?
> 
> Thanks. 
> 
> LabR
> 

> _______________________________________________
> Tinyos-help mailing list
> [EMAIL PROTECTED]
> http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-help

_______________________________________________
Tinyos-users mailing list
[EMAIL PROTECTED]
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-users

Reply via email to