Hi, If you decide to use the tinyos.jar and the class created by mig to create a message, check the apps/tests/TestSerial app.
Andris On Mon, May 7, 2012 at 2:30 AM, Behdad aminian <[email protected]> wrote: > > Dear Sergio, > > Thanks for your reply. > I have a Labview program which sends the mentioned hex string > ("00FFFFFFFF02000B0000") directly to the SerialForwarder and data will > received by motes. But I cannot send this string via my java program.Now > some questions: > > 1) Is it needed to use MIG while I want to send my data via SerialForwarder? > because as I could understand from tutorials, MIG will be used to > communicate directly with the serial port of a mote not communicating via > SerialForwarder. (Am I right?) > > 2) I could not understand the 3rd section of your explanation. Do you mean > that, I should run my java code and send this string from my java > application to SF? If so, this is exactly what I did, but it doesn't work. > > Here is part of my code: > > byte[] test=new byte[10]; > test[0]=0x00; > test[1]=(byte)0xff; > test[2]=(byte)0xff; > test[3]=(byte)0xff; > test[4]=(byte)0xff; > test[5]=0x02; > test[4]=0x00; > test[5]=0x0B; > test[6]=0x00; > test[7]=0x00; > > Socket client=new Socket("localhost",902); > DataOutputStream DOS= new DataOutputStream(client.getOutputStream()); > > DOS.write(test, 0, test.length); > DOS.flush(); > > I will be thankful if you can help me about sending this data to a mote via > SF. > > Best, > Behdad > > > On Sun, May 6, 2012 at 2:08 PM, Sergio Valcarcel <[email protected]> > wrote: >> >> I have not used it for almost one year, but the serial communication is >> quite straightforward. >> >> 1) You make and compile a Java program able to communicate through serial >> port. Optionally you could use the classes generated by MIG >> >> 2) Launch SerialForwarder >> java net.tinyos.sf.SerialForwarder -comm serial@/dev/ttyUSB1:intelmote2 >> 3) Launch each of the applications attaching them to serial forwarder (I >> say applications in plural because the possibility of sharing the serial >> port for many threads is the main utility I found for serialforwarder) >> java TinyOSconsole -comm sf@localhost:9002 >> java TinyOS2mote -comm sf@localhost:9002 >> >> And that is all! >> >> Good luck! >> Sergio >> >> >> On Sat, May 5, 2012 at 9:59 PM, Behdad aminian <[email protected]> >> wrote: >>> >>> Hi all, >>> >>> I Need to send a very simple hex data "00FFFFFFFF02000B0000" from a java >>> program via the SerialForwarder to a tinyos mote (Basestation). >>> I have convert this string to its hex value and save it in a byte array >>> and send to the port of serial forwarder via tcp connection, but the >>> serialforwarder does not receive any data and disconnect the connection when >>> I try to send a data. >>> (I wrote a simple tcp server for testing and I ma able to receive data in >>> my server but not in serial forwarder.) >>> >>> Should I do any thing special? >>> I do not know what is wrong and what should I do and I will >>> be appreciated if some one help me or at least give me some hints. >>> >>> >>> Best, >>> Behdad >>> >>> _______________________________________________ >>> Tinyos-help mailing list >>> [email protected] >>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >> >> > > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
