Updated for new listener API in MSPSim

This commit is contained in:
Niclas Finne 2012-04-16 04:50:21 +02:00
parent 26e7698d32
commit 7628652a9d
8 changed files with 12 additions and 11 deletions

View file

@ -481,7 +481,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
String name = mapEntry.getName(); String name = mapEntry.getName();
return file + ":?:" + name; return file + ":?:" + name;
} }
return String.format("*%02x", myCpu.reg[MSP430Constants.PC]); return String.format("*%02x", pc);
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }

View file

@ -68,7 +68,7 @@ public class ESBLED extends LED implements PortListener {
/* Listen for port writes */ /* Listen for port writes */
IOUnit unit = this.mote.getCPU().getIOUnit("Port 2"); IOUnit unit = this.mote.getCPU().getIOUnit("Port 2");
if (unit instanceof IOPort) { if (unit instanceof IOPort) {
((IOPort) unit).setPortListener(this); ((IOPort) unit).addPortListener(this);
} }
} }

View file

@ -72,7 +72,7 @@ public class Exp5438LED extends LED {
IOUnit unit = mspMote.getCPU().getIOUnit("P1"); IOUnit unit = mspMote.getCPU().getIOUnit("P1");
if (unit instanceof IOPort) { if (unit instanceof IOPort) {
((IOPort) unit).setPortListener(new PortListener() { ((IOPort) unit).addPortListener(new PortListener() {
public void portWrite(IOPort source, int data) { public void portWrite(IOPort source, int data) {
redOn = (data & Exp5438Node.LEDS_CONF_RED) != 0; redOn = (data & Exp5438Node.LEDS_CONF_RED) != 0;
yellowOn = (data & Exp5438Node.LEDS_CONF_YELLOW) != 0; yellowOn = (data & Exp5438Node.LEDS_CONF_YELLOW) != 0;

View file

@ -73,7 +73,7 @@ public class MspSerial extends SerialUI implements SerialPort {
IOUnit ioUnit = this.mote.getCPU().getIOUnit(ioConfigString()); IOUnit ioUnit = this.mote.getCPU().getIOUnit(ioConfigString());
if (ioUnit instanceof USARTSource) { if (ioUnit instanceof USARTSource) {
usart = (USARTSource) ioUnit; usart = (USARTSource) ioUnit;
usart.setUSARTListener(new USARTListener() { usart.addUSARTListener(new USARTListener() {
public void dataReceived(USARTSource source, int data) { public void dataReceived(USARTSource source, int data) {
MspSerial.this.dataReceived(data); MspSerial.this.dataReceived(data);
} }

View file

@ -46,6 +46,7 @@ import se.sics.cooja.interfaces.Radio;
import se.sics.cooja.mspmote.MspMote; import se.sics.cooja.mspmote.MspMote;
import se.sics.cooja.mspmote.MspMoteTimeEvent; import se.sics.cooja.mspmote.MspMoteTimeEvent;
import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.CC2420;
import se.sics.mspsim.chip.ChannelListener;
import se.sics.mspsim.chip.RFListener; import se.sics.mspsim.chip.RFListener;
import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.Chip;
import se.sics.mspsim.core.OperatingModeListener; import se.sics.mspsim.core.OperatingModeListener;
@ -89,7 +90,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
throw new IllegalStateException("Mote is not equipped with a CC2420"); throw new IllegalStateException("Mote is not equipped with a CC2420");
} }
cc2420.setRFListener(new RFListener() { cc2420.addRFListener(new RFListener() {
int len = 0; int len = 0;
int expLen = 0; int expLen = 0;
byte[] buffer = new byte[127 + 15]; byte[] buffer = new byte[127 + 15];
@ -158,8 +159,8 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
} }
}); });
cc2420.setChannelListener(new CC2420.ChannelListener() { cc2420.addChannelListener(new ChannelListener() {
public void changedChannel(int channel) { public void channelChanged(int channel) {
/* XXX Currently assumes zero channel switch time */ /* XXX Currently assumes zero channel switch time */
lastEvent = RadioEvent.UNKNOWN; lastEvent = RadioEvent.UNKNOWN;
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime(); lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();

View file

@ -69,7 +69,7 @@ public class SkyLED extends LED {
IOUnit unit = mspMote.getCPU().getIOUnit("Port 5"); IOUnit unit = mspMote.getCPU().getIOUnit("Port 5");
if (unit instanceof IOPort) { if (unit instanceof IOPort) {
((IOPort) unit).setPortListener(new PortListener() { ((IOPort) unit).addPortListener(new PortListener() {
public void portWrite(IOPort source, int data) { public void portWrite(IOPort source, int data) {
blueOn = (data & SkyNode.BLUE_LED) == 0; blueOn = (data & SkyNode.BLUE_LED) == 0;
greenOn = (data & SkyNode.GREEN_LED) == 0; greenOn = (data & SkyNode.GREEN_LED) == 0;

View file

@ -108,7 +108,7 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
IOUnit usart = this.mote.getCPU().getIOUnit("USART 0"); IOUnit usart = this.mote.getCPU().getIOUnit("USART 0");
if (usart != null && usart instanceof USART) { if (usart != null && usart instanceof USART) {
radioUSART = (USART) usart; radioUSART = (USART) usart;
radioUSART.setUSARTListener(this); radioUSART.addUSARTListener(this);
} else { } else {
throw new RuntimeException("Bad TR1001 IO: " + usart); throw new RuntimeException("Bad TR1001 IO: " + usart);
} }

View file

@ -73,7 +73,7 @@ public class TyndallLED extends LED {
IOUnit unit = mspMote.getCPU().getIOUnit("P7"); IOUnit unit = mspMote.getCPU().getIOUnit("P7");
if (unit instanceof IOPort) { if (unit instanceof IOPort) {
((IOPort) unit).setPortListener(new PortListener() { ((IOPort) unit).addPortListener(new PortListener() {
public void portWrite(IOPort source, int data) { public void portWrite(IOPort source, int data) {
redOn = (data & TyndallNode.LEDS_CONF_RED) == 0; redOn = (data & TyndallNode.LEDS_CONF_RED) == 0;
setChanged(); setChanged();
@ -83,7 +83,7 @@ public class TyndallLED extends LED {
} }
unit = mspMote.getCPU().getIOUnit("P8"); unit = mspMote.getCPU().getIOUnit("P8");
if (unit instanceof IOPort) { if (unit instanceof IOPort) {
((IOPort) unit).setPortListener(new PortListener() { ((IOPort) unit).addPortListener(new PortListener() {
public void portWrite(IOPort source, int data) { public void portWrite(IOPort source, int data) {
greenOn = (data & TyndallNode.LEDS_CONF_GREEN) == 0; greenOn = (data & TyndallNode.LEDS_CONF_GREEN) == 0;
setChanged(); setChanged();