Nikos, I tried to copy/paste TestSerial java code, the problem is that they use import net.tinyos.message.*; import net.tinyos.packet.*; import net.tinyos.util.*;
to include all the TinyOS related stuff (such as moteIF.send ) But in case I use C, what headers hould I include to have such a functionality? Arik On Thu, Dec 3, 2009 at 09:42, Nikos Batalas <[email protected]> wrote: > Arik Sapojnik wrote: > >> Nikos, >> >> Thanks for the mig command! It looks exactly what I needed. >> Regarding the UART - let's say I have a struct: >> >> typedef nx_struct MyStruct >> { >> nx_uint8_t counter; >> } MyStruct; >> >> And I want to send every second an incremented counter: 1, 2, 3 ... ,and I >> want the BaseStation to forward it to the air. >> So the packet flow should be as follows: >> >> 1. I send it to the BaseSation via SF >> 2. The message arrives at UartReceive.receive() and goes to radioQueue >> 3. radioSendTask sends the message to air. >> >> >> My initial question was: What exactly to send to Sf? If I send JUST >> MyStruct - nothing happens (I added printf in UartReceive.receive() to >> ensure that ). But, if counter == 0xFF, UartReceive.receive() is called. >> > > I don't know why this would happen, but I'd be curious why. > > > (I hope I was clearer this time :) ) >> Now it looks to me that I have to send message_t struct, which will be >> entirely forwarded to the air... >> >> > I think you are right though, you do need to send a message_t struct (has a > header and a footer besides the payload). The way it's done through the sdk > is that you use the mig generated code to configure the payload (MyStruct in > your case) and let the sdk take care of the rest. > I haven't used it in C, but in case it helps, here's how it's done in java > (taken from TestSerial.java) : > > > public void sendMsg(int toMote) { > MyStruct payload = new MyStruct(); > > try { > payload.set_counter( mycounter ); > mycounter++; > moteIF.send(toMote, payload); > catch (IOException exception) { > System.err.println(exception); > } > } > > > toMote should be -1 (equal with AM_BROADCAST_ADDR) for every mote to > receive, otherwise set to the moteid you are sending to. > > where moteif is a mote interface object parametrized with your serial > configuration > and MyStruct is the mig generated class from your header file. > > > > Best Regards, > Nikos >
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
