remade msp init methods
This commit is contained in:
parent
223ded4595
commit
ef6ac855d9
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -52,14 +52,14 @@ public class ESBMote extends MspMote {
|
|||
}
|
||||
|
||||
public ESBMote(MoteType moteType, Simulation sim) {
|
||||
super((ESBMoteType) moteType, sim);
|
||||
super((MspMoteType) moteType, sim);
|
||||
}
|
||||
|
||||
protected boolean initEmulator(File fileELF) {
|
||||
try {
|
||||
createCPUAndMemory(fileELF);
|
||||
|
||||
esbNode = new ESBNode(getCPU());
|
||||
esbNode = new ESBNode();
|
||||
esbNode.setupNodePorts();
|
||||
prepareMote(fileELF, esbNode.getCPU());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.fatal("Error when creating ESB mote: " + e);
|
||||
|
@ -70,6 +70,7 @@ public class ESBMote extends MspMote {
|
|||
|
||||
protected MoteInterfaceHandler createMoteInterfaceHandler() {
|
||||
MoteInterfaceHandler moteInterfaceHandler = new MoteInterfaceHandler();
|
||||
|
||||
// Add position interface
|
||||
Position motePosition = new Position(this);
|
||||
Random random = new Random();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -60,7 +60,6 @@ public abstract class MspMote implements Mote {
|
|||
private MspMoteType myMoteType = null;
|
||||
private MspMoteMemory myMemory = null;
|
||||
private MoteInterfaceHandler myMoteInterfaceHandler = null;
|
||||
private ELF myELFModule = null;
|
||||
|
||||
protected TR1001Radio myRadio = null; /* TODO Only used by ESB (TR1001) */
|
||||
|
||||
|
@ -103,6 +102,10 @@ public abstract class MspMote implements Mote {
|
|||
return myCpu;
|
||||
}
|
||||
|
||||
public void setCPU(MSP430 cpu) {
|
||||
myCpu = cpu;
|
||||
}
|
||||
|
||||
public MoteMemory getMemory() {
|
||||
return myMemory;
|
||||
}
|
||||
|
@ -159,19 +162,19 @@ public abstract class MspMote implements Mote {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates MSP430 CPU object and address memory for current object.
|
||||
* This method should normally not be called from outside constructor.
|
||||
* Prepares CPU, memory and ELF module.
|
||||
*
|
||||
* @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 {
|
||||
myCpu = new MSP430(0);
|
||||
protected void prepareMote(File fileELF, MSP430 cpu) throws IOException {
|
||||
myCpu = cpu;
|
||||
myCpu.setMonitorExec(true);
|
||||
|
||||
int[] memory = myCpu.getMemory();
|
||||
|
||||
myELFModule = ELF.readELF(fileELF.getPath());
|
||||
ELF myELFModule = ELF.readELF(fileELF.getPath());
|
||||
myELFModule.loadPrograms(memory);
|
||||
MapTable map = myELFModule.getMap();
|
||||
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 */
|
||||
|
||||
/* Create mote address memory */
|
||||
ArrayList<MapEntry> allEntries = map.getAllEntries();
|
||||
MapEntry[] allEntries = map.getAllEntries();
|
||||
myMemory = new MspMoteMemory(allEntries, myCpu);
|
||||
|
||||
myCpu.reset();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* 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;
|
||||
|
@ -43,7 +43,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
|
|||
|
||||
private MSP430 cpu;
|
||||
|
||||
public MspMoteMemory(ArrayList<MapEntry> allEntries, MSP430 cpu) {
|
||||
public MspMoteMemory(MapEntry[] allEntries, MSP430 cpu) {
|
||||
this.mapEntries = new ArrayList<MapEntry>();
|
||||
|
||||
for (MapEntry entry: allEntries) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -58,9 +58,9 @@ public class SkyMote extends MspMote {
|
|||
|
||||
protected boolean initEmulator(File fileELF) {
|
||||
try {
|
||||
createCPUAndMemory(fileELF);
|
||||
|
||||
skyNode = new SkyNode(getCPU(), null);
|
||||
skyNode = new SkyNode();
|
||||
skyNode.setupNodePorts();
|
||||
prepareMote(fileELF, skyNode.getCPU());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.fatal("Error when creating Sky mote: " + e);
|
||||
|
|
Loading…
Reference in a new issue