mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
fix: mote id should not return memory value, but rather the configured value.
This commit is contained in:
parent
857c7d5a9d
commit
cd8a407ee1
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: MspMoteID.java,v 1.13 2009/10/28 15:58:42 fros4943 Exp $
|
* $Id: MspMoteID.java,v 1.14 2009/11/25 09:17:16 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
@ -35,8 +35,10 @@ import java.util.Collection;
|
|||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
@ -84,7 +86,7 @@ public class MspMoteID extends MoteID {
|
|||||||
|
|
||||||
private ID_LOCATION location = ID_LOCATION.JAVA_ONLY;
|
private ID_LOCATION location = ID_LOCATION.JAVA_ONLY;
|
||||||
|
|
||||||
private int moteID = -1; /* Only used for location IN_JAVA_ONLY */
|
private int moteID = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an interface to the mote ID at mote.
|
* Creates an interface to the mote ID at mote.
|
||||||
@ -98,23 +100,15 @@ public class MspMoteID extends MoteID {
|
|||||||
this.mote = (MspMote) m;
|
this.mote = (MspMote) m;
|
||||||
this.moteMem = (MspMoteMemory) mote.getMemory();
|
this.moteMem = (MspMoteMemory) mote.getMemory();
|
||||||
|
|
||||||
String[] variables = moteMem.getVariableNames();
|
if (moteMem.variableExists("node_id") &&
|
||||||
|
moteMem.variableExists("TOS_NODE_ID")) {
|
||||||
location = ID_LOCATION.JAVA_ONLY;
|
|
||||||
for (String variable: variables) {
|
|
||||||
if (variable.equals("TOS_NODE_ID")) {
|
|
||||||
if (location == ID_LOCATION.VARIABLE_NODE_ID) {
|
|
||||||
location = ID_LOCATION.VARIABLES_BOTH;
|
location = ID_LOCATION.VARIABLES_BOTH;
|
||||||
} else {
|
} else if (moteMem.variableExists("node_id")) {
|
||||||
location = ID_LOCATION.VARIABLE_TOS_NODE_ID;
|
|
||||||
}
|
|
||||||
} else if (variable.equals("node_id")) {
|
|
||||||
if (location == ID_LOCATION.VARIABLE_TOS_NODE_ID) {
|
|
||||||
location = ID_LOCATION.VARIABLES_BOTH;
|
|
||||||
} else {
|
|
||||||
location = ID_LOCATION.VARIABLE_NODE_ID;
|
location = ID_LOCATION.VARIABLE_NODE_ID;
|
||||||
}
|
} else if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||||
}
|
location = ID_LOCATION.VARIABLE_TOS_NODE_ID;
|
||||||
|
} else {
|
||||||
|
location = ID_LOCATION.JAVA_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*logger.debug("ID location: " + location);*/
|
/*logger.debug("ID location: " + location);*/
|
||||||
@ -147,7 +141,7 @@ public class MspMoteID extends MoteID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getMoteID() {
|
public int getMoteID() {
|
||||||
if (location == ID_LOCATION.VARIABLE_NODE_ID) {
|
/*if (location == ID_LOCATION.VARIABLE_NODE_ID) {
|
||||||
return moteMem.getIntValueOf("node_id");
|
return moteMem.getIntValueOf("node_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,10 +155,9 @@ public class MspMoteID extends MoteID {
|
|||||||
|
|
||||||
if (location == ID_LOCATION.JAVA_ONLY) {
|
if (location == ID_LOCATION.JAVA_ONLY) {
|
||||||
return moteID;
|
return moteID;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
logger.fatal("Unknown node ID location");
|
return moteID;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoteID(int newID) {
|
public void setMoteID(int newID) {
|
||||||
@ -183,6 +176,10 @@ public class MspMoteID extends MoteID {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
moteMem.setIntValueOf("node_id", newID);
|
moteMem.setIntValueOf("node_id", newID);
|
||||||
|
/* Experimental: set Contiki random seed variable if it exists */
|
||||||
|
if (moteMem.variableExists("rseed")) {
|
||||||
|
moteMem.setIntValueOf("rseed", (int) (mote.getSimulation().getRandomSeed() + newID));
|
||||||
|
}
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
return;
|
return;
|
||||||
@ -197,6 +194,10 @@ public class MspMoteID extends MoteID {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
moteMem.setIntValueOf("node_id", newID);
|
moteMem.setIntValueOf("node_id", newID);
|
||||||
|
/* Experimental: set Contiki random seed variable if it exists */
|
||||||
|
if (moteMem.variableExists("rseed")) {
|
||||||
|
moteMem.setIntValueOf("rseed", (int) (mote.getSimulation().getRandomSeed() + newID));
|
||||||
|
}
|
||||||
moteMem.setIntValueOf("TOS_NODE_ID", newID);
|
moteMem.setIntValueOf("TOS_NODE_ID", newID);
|
||||||
moteMem.setIntValueOf("ActiveMessageAddressC$addr", newID);
|
moteMem.setIntValueOf("ActiveMessageAddressC$addr", newID);
|
||||||
setChanged();
|
setChanged();
|
||||||
|
Loading…
Reference in New Issue
Block a user