Added serial interface that looks up default serial usart from MSPSim
This commit is contained in:
parent
9251692eed
commit
8a7f572e87
@ -41,9 +41,9 @@ import se.sics.cooja.mspmote.interfaces.Msp802154Radio;
|
||||
import se.sics.cooja.mspmote.interfaces.MspButton;
|
||||
import se.sics.cooja.mspmote.interfaces.MspClock;
|
||||
import se.sics.cooja.mspmote.interfaces.MspDebugOutput;
|
||||
import se.sics.cooja.mspmote.interfaces.MspDefaultSerial;
|
||||
import se.sics.cooja.mspmote.interfaces.MspLED;
|
||||
import se.sics.cooja.mspmote.interfaces.MspMoteID;
|
||||
import se.sics.cooja.mspmote.interfaces.UsciA1Serial;
|
||||
|
||||
@ClassDescription("Wismote Mote Type")
|
||||
@AbstractionLevelDescription("Emulated level")
|
||||
@ -84,8 +84,7 @@ public class WismoteMoteType extends AbstractMspMoteType {
|
||||
// SkyFlash.class,
|
||||
// SkyCoffeeFilesystem.class,
|
||||
Msp802154Radio.class,
|
||||
// MspSerial.class,
|
||||
UsciA1Serial.class,
|
||||
MspDefaultSerial.class,
|
||||
MspLED.class,
|
||||
MspDebugOutput.class /* EXPERIMENTAL: Enable me for COOJA_DEBUG(..) */
|
||||
);
|
||||
|
@ -41,9 +41,9 @@ import se.sics.cooja.interfaces.RimeAddress;
|
||||
import se.sics.cooja.mspmote.interfaces.Msp802154Radio;
|
||||
import se.sics.cooja.mspmote.interfaces.MspClock;
|
||||
import se.sics.cooja.mspmote.interfaces.MspDebugOutput;
|
||||
import se.sics.cooja.mspmote.interfaces.MspDefaultSerial;
|
||||
import se.sics.cooja.mspmote.interfaces.MspLED;
|
||||
import se.sics.cooja.mspmote.interfaces.MspMoteID;
|
||||
import se.sics.cooja.mspmote.interfaces.UsciA0Serial;
|
||||
|
||||
@ClassDescription("Z1 Mote Type")
|
||||
@AbstractionLevelDescription("Emulated level")
|
||||
@ -82,7 +82,7 @@ public class Z1MoteType extends AbstractMspMoteType {
|
||||
MspMoteID.class,
|
||||
// SkyFlash.class,
|
||||
Msp802154Radio.class,
|
||||
UsciA0Serial.class,
|
||||
MspDefaultSerial.class,
|
||||
MspLED.class,
|
||||
MspDebugOutput.class /* EXPERIMENTAL: Enable me for COOJA_DEBUG(..) */
|
||||
);
|
||||
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) 2012, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of COOJA.
|
||||
*
|
||||
*/
|
||||
package se.sics.cooja.mspmote.interfaces;
|
||||
|
||||
import se.sics.cooja.Mote;
|
||||
import se.sics.cooja.mspmote.MspMote;
|
||||
import se.sics.mspsim.core.USARTSource;
|
||||
|
||||
/**
|
||||
* @author Niclas Finne
|
||||
*
|
||||
*/
|
||||
public class MspDefaultSerial extends MspSerial {
|
||||
|
||||
public MspDefaultSerial(Mote mote) {
|
||||
super(mote);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected USARTSource getUSARTSource(MspMote mote) {
|
||||
USARTSource usart = mote.getCPU().getRegistry().getComponent(USARTSource.class, "serialio");
|
||||
if (usart != null) {
|
||||
return usart;
|
||||
}
|
||||
return super.getUSARTSource(mote);
|
||||
}
|
||||
|
||||
}
|
@ -41,7 +41,6 @@ import se.sics.cooja.dialogs.SerialUI;
|
||||
import se.sics.cooja.interfaces.SerialPort;
|
||||
import se.sics.cooja.mspmote.MspMote;
|
||||
import se.sics.cooja.mspmote.MspMoteTimeEvent;
|
||||
import se.sics.mspsim.core.IOUnit;
|
||||
import se.sics.mspsim.core.USARTListener;
|
||||
import se.sics.mspsim.core.USARTSource;
|
||||
|
||||
@ -68,11 +67,9 @@ public class MspSerial extends SerialUI implements SerialPort {
|
||||
public MspSerial(Mote mote) {
|
||||
this.mote = (MspMote) mote;
|
||||
this.simulation = mote.getSimulation();
|
||||
|
||||
/* Listen to port writes */
|
||||
IOUnit ioUnit = this.mote.getCPU().getIOUnit(ioConfigString());
|
||||
if (ioUnit instanceof USARTSource) {
|
||||
usart = (USARTSource) ioUnit;
|
||||
usart = getUSARTSource(this.mote);
|
||||
if (usart != null) {
|
||||
usart.addUSARTListener(new USARTListener() {
|
||||
public void dataReceived(USARTSource source, int data) {
|
||||
MspSerial.this.dataReceived(data);
|
||||
@ -93,6 +90,10 @@ public class MspSerial extends SerialUI implements SerialPort {
|
||||
|
||||
}
|
||||
|
||||
protected USARTSource getUSARTSource(MspMote mote) {
|
||||
return mote.getCPU().getIOUnit(USARTSource.class, ioConfigString());
|
||||
}
|
||||
|
||||
public void writeByte(byte b) {
|
||||
incomingData.add(b);
|
||||
if (writeDataEvent.isScheduled()) {
|
||||
|
Loading…
Reference in New Issue
Block a user