Hi to all,
I'm doing the TinyOS tutorial Collection section (
http://docs.tinyos.net/index.php/Network_Protocols), and all works. But how
I try to add a java class that prints received messages does not work
anymore.
The java class is:
import net.tinyos.message.Message;
import net.tinyos.message.MessageListener;
import net.tinyos.message.MoteIF;
public class EasyCollection implements MessageListener {
MoteIF mote;
public static void main(String[] args) {
EasyCollection me = new EasyCollection();
me.run();
}
void run(){
mote = new MoteIF();
mote.registerListener(new EasyCollectionMsg(), this);
}
public synchronized void messageReceived(int to, Message m) {
if(m instanceof EasyCollectionMsg){
EasyCollectionMsg msg = (EasyCollectionMsg)m;
System.out.println("Received packet sequence number " + msg.get_counter() +
" from node number " + msg.get_nodeid());
}
}
}
in the Makefile, I add:
BUILD_EXTRA_DEPS += EasyCollection.class
CLEAN_EXTRA = *.class EasyCollectionMsg.java
CFLAGS += -I$(TOSDIR)/lib/net -I$(TOSDIR)/lib/net/4bitle
-I$(TOSDIR)/lib/net/ctp
EasyCollection.class: $(wildcard *.java) EasyCollectionMsg.java
javac -target 1.6 -source 1.6 *.java
EasyCollectionMsg.java:
mig java -target=null $(CFLAGS) -java-classname=EasyCollectionMsg
EasyCollection.h EasyCollectionMsg -o $@
How to run the class never enters the MessageReceived public synchronized
void method (int to, Message m) and begins receiving bad packets, after a
while I get this exception by SerialForwarder:
Exception in thread "Thread-31" java.lang.Exception: TOSComm JNI library
runtime error: read: Resource temporarily unavailable
at net.tinyos.comm.TOSCommJNI.NativeSerial_read__SWIG_1(Native Method)
at net.tinyos.comm.NativeSerial.read(NativeSerial.java:195)
at net.tinyos.comm.TOSSerial$SerialInputStream.gather(TOSSerial.java:163)
at net.tinyos.comm.TOSSerial$SerialInputStream.available(TOSSerial.java:183)
at net.tinyos.packet.SerialByteSource.readByte(SerialByteSource.java:111)
at net.tinyos.packet.Packetizer.readFramedPacket(Packetizer.java:271)
at net.tinyos.packet.Packetizer.run(Packetizer.java:227)
at java.lang.Thread.run(Thread.java:636)
Best regards,
Tommaso
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help