Hi all,
        I've seen a couple of people post similar questions re connecting
custom apps to SerialForwarder but I've had no luck finding answers as yet,
so here's yet another question on the use of SF.

My understanding of the SerialForwarder is that it can be used to stream
serial data (i.e. TOS messages) to any client sitting on the end of a TCP
connection. I'm writing a simple Java client that initially just connects to
SF, receives message packets and writes them to the console.

The problem I'm having is that I can connect to SF & initially receive data
(just 2 bytes) but then my client just sits there waiting for more data.
>From what I can see from the example apps (Oscope etc) there doesn't appear
to be anything special going on, so I'm at a loss. When I connect to the SF
through Telnet, I just see a 'T' character displayed. I've checked
SFProtocol.java but maybe I'm missing something.

I'd appreciate hearing from anyone else who's tried to hook-up to SF in
their own apps and any suggestions they might have.

I've included a small excerpt of my client code, together with the program
output.

// Output
Attempting to connect to localhost:9001
< CONNECTED TO SERIALFORWARDER >
< READ returned 2 bytes>

public void run(){
        // read from the stream
        int numBytesReturned =
inputStream.read(packet,numBytesRead,PACKET_SIZE - numBytesRead);
        System.err.println("< READ returned " + numBytesReturned + " >");
                                
        // continue to read until we reach the end of the stream
        while(numBytesReturned != -1){

        // update the number of bytes read from the stream
        numBytesRead += numBytesReturned;
                                        
        // if we've read enough bytes to form a packet, decode its contents
        if(numBytesRead == PACKET_SIZE){
                for(int idx = 0; idx < packet.length; idx++){
                        System.out.print( Integer.toHexString(packet[idx] &
0xFF) + " " );
                }
                                                
                // reset counter
                numBytesRead = 0;
                // leave a gap to display the next packet
                System.out.println();
        }
                                        
        // read another set of bytes
        numBytesReturned = inputStream.read(packet,numBytesRead,PACKET_SIZE
- numBytesRead);
                                        
        }// end while(!EOS)
}// end run

Thanks in advance.


This email and any files attached are intended for the addressee and may
contain information of a confidential nature.  If you are not the intended
recipient, be aware that this email was sent to you in error and you should
not disclose, distribute, print, copy or make other use of this email or its
attachments.  Such actions, in fact, may be unlawful.  In compliance with
the various Regulations and Acts, General Dynamics UK Limited reserves the
right to monitor (and examine for viruses) all emails and email attachments,
both inbound and outbound.  Email communications and their attachments may
not be secure or error- or virus-free and the company does not accept
liability or responsibility for such matters or the consequences thereof.
Registered Office: 100 New Bridge Street, London EC4V 6JA.  Registered in
England and Wales No: 1911653.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to