remade msp init methods
This commit is contained in:
parent
223ded4595
commit
ef6ac855d9
4 changed files with 24 additions and 20 deletions
|
@ -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: ESBMote.java,v 1.1 2008/02/07 14:53:29 fros4943 Exp $
|
* $Id: ESBMote.java,v 1.2 2008/03/17 09:54:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -52,14 +52,14 @@ public class ESBMote extends MspMote {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ESBMote(MoteType moteType, Simulation sim) {
|
public ESBMote(MoteType moteType, Simulation sim) {
|
||||||
super((ESBMoteType) moteType, sim);
|
super((MspMoteType) moteType, sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean initEmulator(File fileELF) {
|
protected boolean initEmulator(File fileELF) {
|
||||||
try {
|
try {
|
||||||
createCPUAndMemory(fileELF);
|
esbNode = new ESBNode();
|
||||||
|
esbNode.setupNodePorts();
|
||||||
esbNode = new ESBNode(getCPU());
|
prepareMote(fileELF, esbNode.getCPU());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.fatal("Error when creating ESB mote: " + e);
|
logger.fatal("Error when creating ESB mote: " + e);
|
||||||
|
@ -70,6 +70,7 @@ public class ESBMote extends MspMote {
|
||||||
|
|
||||||
protected MoteInterfaceHandler createMoteInterfaceHandler() {
|
protected MoteInterfaceHandler createMoteInterfaceHandler() {
|
||||||
MoteInterfaceHandler moteInterfaceHandler = new MoteInterfaceHandler();
|
MoteInterfaceHandler moteInterfaceHandler = new MoteInterfaceHandler();
|
||||||
|
|
||||||
// Add position interface
|
// Add position interface
|
||||||
Position motePosition = new Position(this);
|
Position motePosition = new Position(this);
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
|
@ -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: MspMote.java,v 1.2 2008/02/11 14:07:38 fros4943 Exp $
|
* $Id: MspMote.java,v 1.3 2008/03/17 09:54:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -60,7 +60,6 @@ public abstract class MspMote implements Mote {
|
||||||
private MspMoteType myMoteType = null;
|
private MspMoteType myMoteType = null;
|
||||||
private MspMoteMemory myMemory = null;
|
private MspMoteMemory myMemory = null;
|
||||||
private MoteInterfaceHandler myMoteInterfaceHandler = null;
|
private MoteInterfaceHandler myMoteInterfaceHandler = null;
|
||||||
private ELF myELFModule = null;
|
|
||||||
|
|
||||||
protected TR1001Radio myRadio = null; /* TODO Only used by ESB (TR1001) */
|
protected TR1001Radio myRadio = null; /* TODO Only used by ESB (TR1001) */
|
||||||
|
|
||||||
|
@ -103,6 +102,10 @@ public abstract class MspMote implements Mote {
|
||||||
return myCpu;
|
return myCpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCPU(MSP430 cpu) {
|
||||||
|
myCpu = cpu;
|
||||||
|
}
|
||||||
|
|
||||||
public MoteMemory getMemory() {
|
public MoteMemory getMemory() {
|
||||||
return myMemory;
|
return myMemory;
|
||||||
}
|
}
|
||||||
|
@ -159,19 +162,19 @@ public abstract class MspMote implements Mote {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates MSP430 CPU object and address memory for current object.
|
* Prepares CPU, memory and ELF module.
|
||||||
* This method should normally not be called from outside constructor.
|
|
||||||
*
|
*
|
||||||
* @param fileELF ELF file
|
* @param fileELF ELF file
|
||||||
* @throws IOException File loading failed
|
* @param cpu MSP430 cpu
|
||||||
|
* @throws IOException Preparing mote failed
|
||||||
*/
|
*/
|
||||||
protected void createCPUAndMemory(File fileELF) throws IOException {
|
protected void prepareMote(File fileELF, MSP430 cpu) throws IOException {
|
||||||
myCpu = new MSP430(0);
|
myCpu = cpu;
|
||||||
myCpu.setMonitorExec(true);
|
myCpu.setMonitorExec(true);
|
||||||
|
|
||||||
int[] memory = myCpu.getMemory();
|
int[] memory = myCpu.getMemory();
|
||||||
|
|
||||||
myELFModule = ELF.readELF(fileELF.getPath());
|
ELF myELFModule = ELF.readELF(fileELF.getPath());
|
||||||
myELFModule.loadPrograms(memory);
|
myELFModule.loadPrograms(memory);
|
||||||
MapTable map = myELFModule.getMap();
|
MapTable map = myELFModule.getMap();
|
||||||
myCpu.getDisAsm().setMap(map);
|
myCpu.getDisAsm().setMap(map);
|
||||||
|
@ -180,7 +183,7 @@ public abstract class MspMote implements Mote {
|
||||||
/* TODO Need new memory type including size and type as well */
|
/* TODO Need new memory type including size and type as well */
|
||||||
|
|
||||||
/* Create mote address memory */
|
/* Create mote address memory */
|
||||||
ArrayList<MapEntry> allEntries = map.getAllEntries();
|
MapEntry[] allEntries = map.getAllEntries();
|
||||||
myMemory = new MspMoteMemory(allEntries, myCpu);
|
myMemory = new MspMoteMemory(allEntries, myCpu);
|
||||||
|
|
||||||
myCpu.reset();
|
myCpu.reset();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: MspMoteMemory.java,v 1.2 2008/02/11 14:07:38 fros4943 Exp $
|
* $Id: MspMoteMemory.java,v 1.3 2008/03/17 09:54:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -43,7 +43,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
|
||||||
|
|
||||||
private MSP430 cpu;
|
private MSP430 cpu;
|
||||||
|
|
||||||
public MspMoteMemory(ArrayList<MapEntry> allEntries, MSP430 cpu) {
|
public MspMoteMemory(MapEntry[] allEntries, MSP430 cpu) {
|
||||||
this.mapEntries = new ArrayList<MapEntry>();
|
this.mapEntries = new ArrayList<MapEntry>();
|
||||||
|
|
||||||
for (MapEntry entry: allEntries) {
|
for (MapEntry entry: allEntries) {
|
||||||
|
|
|
@ -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: SkyMote.java,v 1.1 2008/02/11 15:23:10 fros4943 Exp $
|
* $Id: SkyMote.java,v 1.2 2008/03/17 09:54:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -58,9 +58,9 @@ public class SkyMote extends MspMote {
|
||||||
|
|
||||||
protected boolean initEmulator(File fileELF) {
|
protected boolean initEmulator(File fileELF) {
|
||||||
try {
|
try {
|
||||||
createCPUAndMemory(fileELF);
|
skyNode = new SkyNode();
|
||||||
|
skyNode.setupNodePorts();
|
||||||
skyNode = new SkyNode(getCPU(), null);
|
prepareMote(fileELF, skyNode.getCPU());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.fatal("Error when creating Sky mote: " + e);
|
logger.fatal("Error when creating Sky mote: " + e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue