I use the same thin , as I told before I tried a couple of ways since I thought maybe it is not possible to communicate directly from windows to mote.
this code mentioned by you works pretty well on my Linux version of application, but on Windows version it doesn't open PrintStreamMessanger.err and exactly on the line : ps.open(PrintStreamMessenger.err); I get the NullPointer Exception. However I tried just sending bytes directly into serial port, the fact is that it doesn't send even a bit to mote, my mote is sensetive to input array of bytes and responds according to the input, but it doesn't happen on XP version of application meaning that sending to mote is not possible or needs more details maybe. Note that I get the InputStream by the code : InputStream in = serialport.getInputStream(); and I get data coming from mote into this input stream , if I try OutputStream out = serialport.getOutputStream(); and then use out.write(byteaaray); it also doesn't work. Am i missing something ? I have no idea for this streng problem. Regards On Thu, Jul 15, 2010 at 7:11 PM, Michael Schippling <[email protected]>wrote: > 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 >> [email protected] >> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >> > -- Best Regards Ashkan Ekhtiari
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
