Hi my code at the moment is as follows:
import java.io.IOException;
import java.util.*;
import net.tinyos.message.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;
public class ConvCast {
private MoteIF moteIF;
private static void usage() {
System.err.println("usage: TestSerial [-comm <source>]");
}
public void init(String source) {
PhoenixSource phoenix;
if (source == null) {
phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err);
}
else {
phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err);
}
MoteIF mif = new MoteIF(phoenix);
mif.registerListener(new UpflowResultMsg(), new MessageListener()
{ public void messageReceived(int to, Message msg)
{handlerType1(to,msg);
try
{
while (true) {
moteIF.send(1,msg);
System.out.println("Sending UpflowResult starting 2.Phase");
try {Thread.sleep(1000);}
catch (InterruptedException exception){}
}
}
catch (IOException exception) {
System.err.println("Exception thrown when sending packets. Exiting.");
System.err.println(exception);
}
}});
mif.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;
// UpflowResultMsg smsg = (UpflowResultMsg)msg;
// UpflowResultMsg smsg = new UpflowResultMsg();
System.out.println("UpflowResultMessage received. Nonce = " +
rmsg.get_rndNonce() + " aggregated data " + rmsg.get_aggregatedData() + " ");
//sendResult(rmsg);
}
}
private void handlerType2(int to, Message msg)
{
if (msg instanceof VerificationResultMsg)
{
VerificationResultMsg rmsg = (VerificationResultMsg)msg;
System.out.println("VerificationMessage received. " + rmsg.get_verifySuccess()
+ " MAC: " + rmsg.get_mac() + " ");
}
}
public static void main(String[] args)
{ String source = null;
if (args.length == 2) {
if (!args[0].equals("-comm")) {
usage();
System.exit(1);
}
source = args[1];
ConvCast me = new ConvCast();
me.init(source);
}
else if (args.length != 0) {
usage();
System.exit(1);
}
}
}
what I get out is:
UpflowResultMessage received. Nonce = 14190152 aggregated data 1629520098
Exception in thread "Thread-1" java.lang.NullPointerException
at ConvCast$1.messageReceived(ConvCast.java:109)
at net.tinyos.message.Receiver.packetReceived(Receiver.java:210)
at net.tinyos.packet.PhoenixSource.dispatch(PhoenixSource.java:160)
at
net.tinyos.packet.PhoenixSource.packetDipatchLoop(PhoenixSource.java:152)
at net.tinyos.packet.PhoenixSource.run(PhoenixSource.java:169)
> can you send the trace of the exception and the code that you use to send it?
>
> 2008/4/9, Nicole Neureiter <[EMAIL PROTECTED]>:
> > Hi,
> >
> > I have the problem, that for verification I have to send the same message
I
> > have received via Java from the motes back to the motes. This means I use
the
> > same message type. Problem is I can't forward the original message because
I
> > get a NullPointerException (This problem was send by someone else in the
past
> > and not answered). So I tried to save the data values I received and
create a
> > new message to send, but I still get the Nullpointeexception when using
> > moteIF.send.
> > Can anyone help?
> >
> > Thanks in advance
> >
> > Nicole Neureiter
> >
> > --
> > _______________________________________________
> > 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