I use this to get the Source. It opens the right kind of
channel based on the setting of the MOTECOM envvar:

        // get the TOS connection
        PacketSource ps = BuildSource.makePacketSource();
        if (ps == null)
        {
                System.err.println(
                    "Invalid packet source \
                     (check your MOTECOM environment variable)");
                System.exit(2);
        }
        ps.open(PrintStreamMessenger.err);

and then to write a message:

        byte[] data = // get message buffer //
        ps.writePacket( data );

or read a message

        byte[] data = ps.readPacket();
        

Where "data" is the raw message buffer and must be a byte[] array
of exactly the length specified in the message (plus the header
etal) with the header formatted correctly. The Packetizer.java
code is what does the real work of sending and receiving, and
it will deal with framing, escaping, and CRC's. You can look
for uses of these methods in the existing code for pointers
as to what and how.

MS

ashkan ekhtiari wrote:
> Hello,
>  
> I need to communicate with mote connected to USB in windows XP within a 
> java application, tinyos jar file is available in javahome and also 
> getenv.dll and tosscomm.dll are available in bin folder.
> I use netbeans and can see all net.tinyos library available. In this 
> java application two way was tried to communicate with my mote, first 
> with Outputstream that is instantiated by serialport.getOutputstream() , 
> by this outputstream it sends nothing to mote when attempting out.write 
> method by passing byte[] or int.
>  
> whoever the second way also was tried by constructing packetSource pks = 
> BuilsSource.makePacketSource().
> and on the second line I use : pks.open(PrintStreamMessenger.err);
>  
>  
>  1-                              pks= 
> net.tinyos.packet.BuildSource.makePacketSource("COM6 
> <mailto:ser...@com6>"); // here I tried ser...@com6:57600 
> <mailto:ser...@com6:57600> or even nothing but the result was the same
>   2-                             pks.open(PrintStreamMessenger.err);
>  
> on code line 2 it gives exception NullPointerException which I do not 
> understand.
>  
> So what can I do to actually communicate with my mote in windows via 
> serial port(USB)?
> -- 
> Best Regards
> Ashkan Ekhtiari
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to