Hi Nicole, In this case, forget about the thread thing and try this instead. I see now the problem: you declare a class variable MoteIF, but you then declare the same variable again in the init() method, thus hiding the class variable. So in your message handler the variable moteIF is null. To solve the problem, just remove the datatype declaration in the init method. The code below also gets you rid of the infinite loop (just replace the init() and the handlerType1() methods in your code with this code).
Cheers, Urs public void init(String source) { PhoenixSource phoenix; if (source == null) { phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); } else { phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); } moteIF = new MoteIF(phoenix); moteIF.registerListener(new UpflowResultMsg(), new MessageListener() { public void messageReceived(int to, Message msg) { handlerType1(to,msg); } }); moteIF.registerListener(new VerificationResultMsg(), new MessageListener() { public void messageReceived(int to, Message msg) { handlerType2(to,msg); } }); } private void handlerType1(int to, Message msg) { if (msg instanceof UpflowResultMsg) { UpflowResultMsg rmsg = (UpflowResultMsg)msg; System.out.println("UpflowResultMessage received. Nonce = " + rmsg.get_rndNonce() + " aggregated data " + rmsg.get_aggregatedData() + " "); moteIF.send(1, msg); System.out.println("Sending UpflowResult starting 2.Phase"); } } Nicole Neureiter wrote: > Hi, > > at that line is moteIF.send(1,msg). Actually it is always at that point no > matter what I do. I didn't intend any infinite loop. All I wanted to do is to > send the received message, that is 1 message, back to my motes, after I have > received it. Haven't tried your suggestion yet. > Thanks > _______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help