You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ni...@us...> - 2010-07-19 12:26:06
|
Revision: 737 http://mspsim.svn.sourceforge.net/mspsim/?rev=737&view=rev Author: nifi Date: 2010-07-19 12:26:00 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Updated Beeper to be a chip in ESBNode Modified Paths: -------------- mspsim/se/sics/mspsim/chip/Beeper.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java Modified: mspsim/se/sics/mspsim/chip/Beeper.java =================================================================== --- mspsim/se/sics/mspsim/chip/Beeper.java 2010-07-19 12:19:28 UTC (rev 736) +++ mspsim/se/sics/mspsim/chip/Beeper.java 2010-07-19 12:26:00 UTC (rev 737) @@ -1,5 +1,5 @@ /** - * Copyright (c) 2007, Swedish Institute of Computer Science. + * Copyright (c) 2007-2010, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,105 +40,162 @@ */ package se.sics.mspsim.chip; -import javax.sound.sampled.*; -import se.sics.mspsim.core.*; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.FloatControl; +import javax.sound.sampled.SourceDataLine; +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.TimeEvent; + /** - * Beeper for the esb... + * Beeper for the ESB... */ -public class Beeper extends IOUnit { +public class Beeper extends Chip { - private SourceDataLine dataLine; - private FloatControl volume; + public static final int MODE_OFF = 0; + public static final int MODE_ON = 1; + public static final int MODE_MAX = MODE_ON; - public static final int SAMPLE_RATE = 44000; + public static final int SAMPLE_RATE = 44000; + public static final int FRQ_1 = 2200; + public static final int WAVE_LEN = (SAMPLE_RATE / FRQ_1); - public static final int FRQ_1 = 2200; + // One second of the sound in buffer + private static byte[] buffer; + private static byte[] quiet; - public static final int WAVE_LEN = (SAMPLE_RATE / FRQ_1); + private boolean beepOn = false; + private int beepCtrl; + private boolean isSoundEnabled = false; - // One second of the sound in buffer - byte[] buffer = new byte[WAVE_LEN]; - byte[] quiet = new byte[WAVE_LEN]; + private SourceDataLine dataLine; + private FloatControl volume; - int beepCtr = 0; + private TimeEvent soundEvent; - public Beeper() { - super("Beeper", null, 0); - AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, false); - DataLine.Info dli = - new DataLine.Info(SourceDataLine.class, af, 16384); - try { - dataLine = (SourceDataLine) AudioSystem.getLine(dli); - if (dataLine == null) { - logw("DataLine: not existing..."); - } else { - dataLine.open(dataLine.getFormat(), 16384); - volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN); - } - } catch (Exception e) { - logw("Problem while getting data line " + e); - } - double f1 = 0; - for (int i = 0, n = WAVE_LEN; i < n; i++) { - f1 = Math.sin(i * 3.141592 * 2 / WAVE_LEN) * 40; - f1 += Math.sin(i * 3.141592 * 4 / WAVE_LEN) * 30; - buffer[i] = (byte) (f1); + public Beeper(MSP430Core cpu) { + super("Beeper", cpu); + setMode(MODE_OFF); } - if (dataLine != null) { - dataLine.start(); + private void initSound() { + if (quiet == null) { + quiet = new byte[WAVE_LEN]; + } + if (buffer == null) { + byte[] buf = new byte[WAVE_LEN]; + double f1 = 0; + for (int i = 0, n = WAVE_LEN; i < n; i++) { + f1 = Math.sin(i * 3.141592 * 2 / WAVE_LEN) * 40; + f1 += Math.sin(i * 3.141592 * 4 / WAVE_LEN) * 30; + buf[i] = (byte) (f1); + } + buffer = buf; + } + if (soundEvent == null) { + soundEvent = new TimeEvent(0, "Beeper") { + public void execute(long t) { + if (isSoundEnabled) { + ioTick(t); + cpu.scheduleCycleEvent(this, cpu.cycles + 1000); + } + } + }; + } + AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, false); + DataLine.Info dli = new DataLine.Info(SourceDataLine.class, af, 16384); + try { + dataLine = (SourceDataLine) AudioSystem.getLine(dli); + if (dataLine == null) { + logw("No audio data line available"); + } else { + dataLine.open(dataLine.getFormat(), 16384); + volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN); + } + } catch (Exception e) { + logw("Could not get audio data line: " + e); + } + if (dataLine != null) { + isSoundEnabled = true; + dataLine.start(); + } } - } - public void setVolue(int vol) { - volume.setValue(vol); - } + private void shutdownSound() { + isSoundEnabled = false; + if (dataLine != null) { + dataLine.close(); + dataLine = null; + volume = null; + } + } - public void beepOn(boolean beep) { - if (beep) { - beepCtr = 7; + public boolean isSoundEnabled() { + return isSoundEnabled; } - } - public long ioTick(long cycles) { - // Avoid blocking using timer... - if (dataLine != null) { - if (dataLine.available() > WAVE_LEN * 2) { - if (beepCtr > 0) { - dataLine.write(buffer, 0, WAVE_LEN); - beepCtr--; - } else { - dataLine.write(quiet, 0, WAVE_LEN); - } - } - } - return cycles + 1000; - } + public void setSoundEnabled(boolean sound) { + if (this.isSoundEnabled != sound) { + if (sound) { + initSound(); + } else { + shutdownSound(); + } + } + } + public int getVolume() { + return volume == null ? 0 : (int) volume.getValue(); + } - public int read(int address, boolean word, long cycler) { - return 0; - } + public void setVolume(int vol) { + if (volume != null) { + volume.setValue(vol); + } + } - public void write(int address, int data, boolean word, long cycler) { - } + public void beepOn(boolean beep) { + if (beepOn != beep) { + beepOn = beep; + setMode(beepOn ? MODE_ON : MODE_OFF); + if (DEBUG) log(beepOn ? "BEEPING" : "SILENT"); + if (beepOn && isSoundEnabled) { + beepCtrl = 7; + if (!soundEvent.isScheduled()) { + cpu.scheduleTimeEvent(soundEvent, cpu.getTime() + 2); + } + } + } + } - // Nothing for interrupts... - public void interruptServiced(int vector) { - } + private void ioTick(long time) { + // Avoid blocking using timer... + if (isSoundEnabled && dataLine != null) { + if (dataLine.available() > WAVE_LEN * 2) { + if (beepCtrl > 0) { + dataLine.write(buffer, 0, WAVE_LEN); + if (!beepOn) { + beepCtrl--; + } + } else { + dataLine.write(quiet, 0, WAVE_LEN); + } + } + } + } - public static void main(String[] args) { - Beeper beep = new Beeper(); - while (true) { - beep.beepOn(true); - for (int i = 0, n = 1000; i < n; i++) { - beep.ioTick(0); - } - beep.beepOn(false); - for (int i = 0, n = 10000; i < n; i++) { - beep.ioTick(0); - } - } - } + @Override + public int getModeMax() { + return MODE_MAX; + } + + @Override + public String info() { + return "Volume: " + getVolume() + " Beep: " + (beepOn ? "on" : "off") + + " Sound Enabled: " + isSoundEnabled; + } + } Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2010-07-19 12:19:28 UTC (rev 736) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2010-07-19 12:26:00 UTC (rev 737) @@ -52,7 +52,6 @@ import javax.sound.sampled.DataLine; import javax.sound.sampled.TargetDataLine; -import se.sics.mspsim.chip.Beeper; import se.sics.mspsim.core.ADC12; import se.sics.mspsim.core.ADCInput; import se.sics.mspsim.core.IOUnit; @@ -83,8 +82,6 @@ private MouseMotionAdapter mouseMotionListener; private MouseAdapter mouseListener; - Beeper beeper; - private final ESBNode node; private final StateChangeListener ledsListener = new StateChangeListener() { public void stateChanged(Object source, int oldState, int newState) { @@ -167,8 +164,6 @@ ((ADC12) adc).setADCInput(0, this); } - beeper = new Beeper(); - // Just a test... TODO: remove!!! try { AudioFormat af = new AudioFormat(SAMPLE_RATE, 16, 1, true, false); Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-19 12:19:28 UTC (rev 736) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-19 12:26:00 UTC (rev 737) @@ -42,6 +42,7 @@ package se.sics.mspsim.platform.esb; import java.io.IOException; +import se.sics.mspsim.chip.Beeper; import se.sics.mspsim.chip.Leds; import se.sics.mspsim.chip.TR1001; import se.sics.mspsim.core.IOPort; @@ -81,6 +82,7 @@ public boolean yellowLed; private TR1001 radio; + private Beeper beeper; private ESBGui gui; /** @@ -95,6 +97,10 @@ return leds; } + public Beeper getBeeper() { + return beeper; + } + public void setPIR(boolean hi) { port1.setPinState(PIR_PIN, hi ? IOPort.PIN_HI : IOPort.PIN_LOW); } @@ -122,9 +128,7 @@ greenLed = (data & GREEN_LED) == 0; yellowLed = (data & YELLOW_LED) == 0; leds.setLeds((greenLed ? 4 : 0) + (yellowLed ? 2 : 0) + (redLed ? 1 : 0)); - if (gui != null) { - gui.beeper.beepOn((data & BEEPER) != 0); - } + beeper.beepOn((data & BEEPER) != 0); } else if (source == port5) { if ((data & 0xc0) == 0xc0) { @@ -160,6 +164,7 @@ radio = new TR1001(cpu, (USART) usart0); } leds = new Leds(cpu, LEDS); + beeper = new Beeper(cpu); } public void setupNode() { @@ -174,6 +179,8 @@ if (!config.getPropertyAsBoolean("nogui", true)) { setupGUI(); + beeper.setSoundEnabled(true); + // Add some windows for listening to serial output IOUnit usart = cpu.getIOUnit("USART 1"); if (usart instanceof USART) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 12:19:38
|
Revision: 736 http://mspsim.svn.sourceforge.net/mspsim/?rev=736&view=rev Author: nifi Date: 2010-07-19 12:19:28 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Updated FileTarget to be based on Target Modified Paths: -------------- mspsim/se/sics/mspsim/cli/FileCommands.java mspsim/se/sics/mspsim/cli/FileTarget.java mspsim/se/sics/mspsim/cli/FileTargetCommand.java Modified: mspsim/se/sics/mspsim/cli/FileCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileCommands.java 2010-07-19 11:59:45 UTC (rev 735) +++ mspsim/se/sics/mspsim/cli/FileCommands.java 2010-07-19 12:19:28 UTC (rev 736) @@ -6,7 +6,7 @@ public class FileCommands implements CommandBundle { - private final Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); + private final Hashtable <String,Target> fileTargets = new Hashtable<String,Target>(); public void setupCommands(final ComponentRegistry registry, CommandHandler handler) { // TODO: this should also be "registered" as a "sink". @@ -23,7 +23,7 @@ handler.registerCommand("fclose", new BasicCommand("close the specified file", "<filename>") { public int executeCommand(CommandContext context) { String name = context.getArgument(0); - FileTarget ft = fileTargets.get(name); + Target ft = fileTargets.get(name); if (ft != null) { context.out.println("Closing file " + name); ft.close(); Modified: mspsim/se/sics/mspsim/cli/FileTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileTarget.java 2010-07-19 11:59:45 UTC (rev 735) +++ mspsim/se/sics/mspsim/cli/FileTarget.java 2010-07-19 12:19:28 UTC (rev 736) @@ -42,136 +42,31 @@ import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; import java.util.Hashtable; /** * @author joakim */ -public class FileTarget { +public class FileTarget extends Target { - private static final boolean DEBUG = false; - - private final Hashtable<String,FileTarget> fileTargets; - private final String name; private final FileWriter out; - private ArrayList<CommandContext> contexts = new ArrayList<CommandContext>(); - public FileTarget(Hashtable<String,FileTarget> fileTargets, String name, - boolean append) throws IOException { - this.fileTargets = fileTargets; - this.out = new FileWriter(name, append); - this.name = name; - fileTargets.put(name, this); + public FileTarget(Hashtable<String,Target> targets, String name, FileWriter out) { + super(targets, name, true); + this.out = out; } - public String getName() { - return name; - } - - public String getStatus() { - StringBuilder sb = new StringBuilder(); - sb.append(name); - synchronized (fileTargets) { - if (contexts != null) { - sb.append(" \tPIDs: ["); - for (int i = 0, n = contexts.size(); i < n; i++) { - int pid = contexts.get(i).getPID(); - if (i > 0) { - sb.append(','); - } - if (pid < 0) { - sb.append('?'); - } else { - sb.append(pid); - } - } - sb.append(']'); - } + protected void handleLine(CommandContext context, String line) { + try { + out.write(line); + out.write('\n'); + out.flush(); + } catch (IOException e) { + e.printStackTrace(context.err); } - return sb.toString(); } - public void lineRead(CommandContext context, String line) { - if (line == null) { - removeContext(context); - } else { - try { - out.write(line); - out.write('\n'); - out.flush(); - } catch (IOException e) { - e.printStackTrace(context.err); - } - } - } - - public void addContext(CommandContext context) { - boolean added = false; - synchronized (fileTargets) { - if (contexts != null) { - contexts.add(context); - added = true; - if (DEBUG) { - System.out.println("FileTarget: new writer to " + name - + " (" + contexts.size() + ')'); - } - } - } - if (!added) { - context.kill(); - } - } - - public void removeContext(CommandContext context) { - boolean close = false; - synchronized (fileTargets) { - if (contexts != null && contexts.remove(context)) { - if (DEBUG) { - System.out.println("FileTarget: removed writer from " - + name + " (" + contexts.size() + ')'); - } - if (contexts.size() == 0) { - close = true; - } - } - } - if (close) { - close(false); - } - } - - public void close() { - close(true); - } - - private void close(boolean forceClose) { - ArrayList<CommandContext> list; - synchronized (fileTargets) { - if (contexts == null) { - // Already closed - return; - } - if (contexts.size() > 0 && !forceClose) { - // File still has connected writers. - return; - } - list = contexts; - contexts = null; - if (fileTargets.get(name) == this) { - fileTargets.remove(name); - if (DEBUG) { - System.out.println("FileTarget: closed file " + name); - } - } - } - - if (list != null) { - // Close any connected writers - for (CommandContext context : list) { - context.kill(); - } - } + protected void closeTarget() { try { out.close(); } catch (IOException e) { Modified: mspsim/se/sics/mspsim/cli/FileTargetCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileTargetCommand.java 2010-07-19 11:59:45 UTC (rev 735) +++ mspsim/se/sics/mspsim/cli/FileTargetCommand.java 2010-07-19 12:19:28 UTC (rev 736) @@ -1,17 +1,18 @@ package se.sics.mspsim.cli; +import java.io.FileWriter; import java.io.IOException; import java.util.Hashtable; public class FileTargetCommand extends BasicLineCommand { - private final Hashtable<String, FileTarget> fileTargets; + private final Hashtable<String,Target> fileTargets; private final boolean print; private final boolean append; - private FileTarget ft; + private Target ft; private CommandContext context; - public FileTargetCommand(Hashtable<String,FileTarget> fileTargets, + public FileTargetCommand(Hashtable<String,Target> fileTargets, String name, String desc, boolean print, boolean append) { super(name, desc); this.fileTargets = fileTargets; @@ -22,19 +23,32 @@ public int executeCommand(CommandContext context) { this.context = context; String fileName = context.getArgument(0); + IOException error = null; + boolean alreadyOpened = false; + synchronized (fileTargets) { ft = fileTargets.get(fileName); if (ft == null) { try { - ft = new FileTarget(fileTargets, fileName, append); + FileWriter writer = new FileWriter(fileName, append); + ft = new FileTarget(fileTargets, fileName, writer); } catch (IOException e) { - e.printStackTrace(context.err); - return -1; + error = e; } } else if (!append) { - context.err.println("File already opened: can not overwrite"); - return -1; + alreadyOpened = true; } + } + + if (error != null) { + error.printStackTrace(context.err); + return -1; + } + if (alreadyOpened) { + context.err.println("File already opened: can not overwrite"); + return -1; + } + if (context.getPID() >= 0) { ft.addContext(context); } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 11:59:51
|
Revision: 735 http://mspsim.svn.sourceforge.net/mspsim/?rev=735&view=rev Author: nifi Date: 2010-07-19 11:59:45 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Updated WindowTarget to use ManagedWindow instead of JFrame Modified Paths: -------------- mspsim/se/sics/mspsim/cli/WindowCommands.java mspsim/se/sics/mspsim/cli/WindowTarget.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/Target.java Added: mspsim/se/sics/mspsim/cli/Target.java =================================================================== --- mspsim/se/sics/mspsim/cli/Target.java (rev 0) +++ mspsim/se/sics/mspsim/cli/Target.java 2010-07-19 11:59:45 UTC (rev 735) @@ -0,0 +1,170 @@ +/** + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * Target + * + * Author : Joakim Eriksson, Niclas Finne + * Created : 14 mar 2010 + * Updated : $Date$ + * $Revision$ + */ +package se.sics.mspsim.cli; + +import java.util.ArrayList; +import java.util.Hashtable; + +public abstract class Target { + + protected static final boolean DEBUG = false; + + private final Hashtable<String,Target> targets; + private final String name; + private final boolean autoclose; + private ArrayList<CommandContext> contexts = new ArrayList<CommandContext>(); + + public Target(Hashtable<String,Target> targets, String name, boolean autoclose) { + this.targets = targets; + this.name = name; + this.autoclose = autoclose; + targets.put(name, this); + } + + public String getName() { + return name; + } + + public String getStatus() { + StringBuilder sb = new StringBuilder(); + sb.append(name); + synchronized (targets) { + if (contexts != null) { + sb.append(" \tPIDs: ["); + for (int i = 0, n = contexts.size(); i < n; i++) { + int pid = contexts.get(i).getPID(); + if (i > 0) { + sb.append(','); + } + if (pid < 0) { + sb.append('?'); + } else { + sb.append(pid); + } + } + sb.append(']'); + } + } + return sb.toString(); + } + + public final void lineRead(CommandContext context, String line) { + if (line == null) { + removeContext(context); + } else { + handleLine(context, line); + } + } + + protected abstract void handleLine(CommandContext context, String line); + + public void addContext(CommandContext context) { + boolean added = false; + synchronized (targets) { + if (contexts != null) { + contexts.add(context); + added = true; + if (DEBUG) { + System.out.println("Target: new writer to " + name + + " (" + contexts.size() + ')'); + } + } + } + if (!added) { + context.kill(); + } + } + + public void removeContext(CommandContext context) { + boolean close = false; + synchronized (targets) { + if (contexts != null && contexts.remove(context)) { + if (DEBUG) { + System.out.println("Target: removed writer from " + + name + " (" + contexts.size() + ')'); + } + if (contexts.size() == 0) { + close = true; + } + } + } + if (close && autoclose) { + close(false); + } + } + + public void close() { + close(true); + } + + private void close(boolean forceClose) { + ArrayList<CommandContext> list; + synchronized (targets) { + if (contexts == null) { + // Already closed + return; + } + if (contexts.size() > 0 && !forceClose) { + // Target still has connected writers. + return; + } + list = contexts; + contexts = null; + if (targets.get(name) == this) { + targets.remove(name); + if (DEBUG) { + System.out.println("Target: closed file " + name); + } + } + } + + if (list != null) { + // Close any connected writers + for (CommandContext context : list) { + context.kill(); + } + } + closeTarget(); + } + + protected abstract void closeTarget(); + +} Property changes on: mspsim/se/sics/mspsim/cli/Target.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Modified: mspsim/se/sics/mspsim/cli/WindowCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowCommands.java 2010-07-19 11:47:28 UTC (rev 734) +++ mspsim/se/sics/mspsim/cli/WindowCommands.java 2010-07-19 11:59:45 UTC (rev 735) @@ -33,7 +33,7 @@ * * WindowCommands - * - * Author : Joakim Eriksson + * Author : Joakim Eriksson, Niclas Finne * Created : 9 april 2008 * Updated : $Date: 2008-03-17 20:34:12 +0100 (Mon, 17 Mar 2008) $ * $Revision: 187 $ @@ -42,82 +42,82 @@ import java.util.Hashtable; +import se.sics.mspsim.ui.WindowManager; import se.sics.mspsim.ui.WindowUtils; import se.sics.mspsim.util.ComponentRegistry; public class WindowCommands implements CommandBundle { - private Hashtable <String, WindowTarget> windowTargets = new Hashtable<String, WindowTarget>(); + private ComponentRegistry registry; + private final Hashtable<String,Target> windowTargets = new Hashtable<String,Target>(); public void setupCommands(ComponentRegistry registry, CommandHandler handler) { - handler.registerCommand("window", new BasicLineCommand("redirect input to a window", "[-close|-clear|-list] <windowname>") { - WindowTarget wt; + this.registry = registry; + handler.registerCommand("window", new BasicLineCommand("redirect input to a window", "[-close|-clear|-list] [windowname]") { + Target wt; CommandContext context; public int executeCommand(CommandContext context) { boolean close = false; boolean clear = false; - boolean exit = false; + boolean list = false; + String windowName = null; this.context = context; for (int i = 0; i < context.getArgumentCount(); i++) { String name = context.getArgument(i); if ("-close".equals(name)) { - exit = close = true; + close = true; } else if ("-clear".equals(name)) { clear = true; } else if ("-list".equals(name)) { - WindowTarget tgts[] = windowTargets.values().toArray(new WindowTarget[windowTargets.size()]); - if (tgts != null && tgts.length > 0) { - context.out.println("Window Name PIDs"); + list = true; + } else if (windowName != null) { + context.err.println("illegal arguments"); + context.exit(1); + return 1; + } else { + windowName = name; + } + } + if (list || windowName == null) { + Target tgts[]; + synchronized (windowTargets) { + tgts = windowTargets.values().toArray(new Target[windowTargets.size()]); + } + if (tgts.length == 0) { + context.out.println("There are no open windows."); + } else { + context.out.println("Window Name PIDs"); + for (Target target : tgts) { + context.out.println(target.getStatus()); } - for (int j = 0; j < tgts.length; j++) { - tgts[j].print(context.out); - } - exit = true; - } else if (i == context.getArgumentCount() - 1) { - if (clear || close) { - wt = windowTargets.get(name); - if (wt != null) { - if (close) { - context.out.println("Closing window " + name); - removeTarget(wt); - wt.close(); - } else if (clear) { - wt.clear(); - } - /* command is no longer running */ - if (exit) context.exit(0); - return 0; - } else { - context.err.println("Could not find the window " + name); - /* command is no longer running */ - context.exit(1); - return 1; - } - } else { - wt = addTarget(context, name); - } } - } - if (exit) { context.exit(0); + return 0; } + if (close) { + Target target = windowTargets.get(windowName); + if (target != null) { + context.out.println("Closing window " + windowName); + target.close(); + context.exit(0); + return 0; + } + context.err.println("Could not find the window " + windowName); + context.exit(1); + return 1; + } + wt = addTarget(context, windowName, clear); return 0; } public void lineRead(String line) { - if (line != null) { - wt.lineRead(line); - } else { - wt.removeContext(context); - context.exit(0); - } + wt.lineRead(context, line); } public void stopCommand(CommandContext context) { - // Should this do anything? - // Probably depending on the wt's config - System.out.println("Stopping window target: " + wt.getName()); - wt.removeContext(context); + if (wt != null) { + wt.removeContext(context); + } } }); @@ -129,18 +129,25 @@ }); } - protected WindowTarget addTarget(CommandContext context, String name) { - WindowTarget wt = windowTargets.get(name); - if (wt == null) { - wt = new WindowTarget(name); - windowTargets.put(name, wt); + protected Target addTarget(CommandContext context, String name, boolean clear) { + Target target; + WindowTarget wt = null; + synchronized (windowTargets) { + target = windowTargets.get(name); + if (target == null) { + target = wt = new WindowTarget(windowTargets, name); + } } - wt.addContext(context); - return wt; + if (wt != null) { + wt.init((WindowManager) registry.getComponent("windowManager")); + } + if (context.getPID() >= 0) { + target.addContext(context); + } + if (clear) { + target.lineRead(context, "#!clear"); + } + return target; } - protected void removeTarget(WindowTarget target) { - /* needs to close down PIDs that are currently writing to the target too !!!??? */ - windowTargets.remove(target.getName()); - } -} \ No newline at end of file +} Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2010-07-19 11:47:28 UTC (rev 734) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2010-07-19 11:59:45 UTC (rev 735) @@ -1,57 +1,48 @@ package se.sics.mspsim.cli; import java.awt.Font; -import java.io.PrintStream; -import java.util.ArrayList; +import java.util.Hashtable; -import javax.swing.JFrame; +import javax.swing.JComponent; import javax.swing.JScrollPane; import javax.swing.JTextArea; -import javax.swing.SwingUtilities; import se.sics.mspsim.extutil.jfreechart.LineChart; import se.sics.mspsim.extutil.jfreechart.LineSampleChart; +import se.sics.mspsim.ui.ManagedWindow; +import se.sics.mspsim.ui.WindowManager; -public class WindowTarget implements LineListener { +public class WindowTarget extends Target { - private JFrame window; - private String targetName; + private ManagedWindow window; // Default in the current version - TODO: replace with better private JTextArea jta = new JTextArea(40,80); private WindowDataHandler dataHandler = null; - private ArrayList<CommandContext> pids = new ArrayList<CommandContext>(); - public WindowTarget(String name) { + public WindowTarget(Hashtable<String,Target> targets, String name) { + super(targets, name, false); + } + + final void init(WindowManager windowManager) { jta.setFont(Font.decode("Courier")); jta.setEditable(false); - window = new JFrame(name); - window.getContentPane().add(new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)); - window.pack(); + + window = windowManager.createWindow(getName()); + window.add(new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)); window.setVisible(true); - targetName = name; } - public void addContext(CommandContext c) { - if (c.getPID() != -1) { - pids.add(c); - } - } - - public void removeContext(CommandContext c) { - pids.remove(c); - } - - public void lineRead(final String line) { + protected void handleLine(final CommandContext context, final String line) { if (line != null && window != null) { - SwingUtilities.invokeLater(new Runnable() { + java.awt.EventQueue.invokeLater(new Runnable() { public void run() { - handleLine(line); + processLine(context, line); } }); } } - private void handleLine(String line) { + private void processLine(CommandContext context, String line) { if (line.startsWith("#!")) { line = line.substring(2); String[] parts = CommandParser.parseLine(line); @@ -61,7 +52,7 @@ window.setBounds(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]), Integer.parseInt(parts[4])); } catch (Exception e) { - System.err.println("Could not set bounds: " + line); + context.err.println("Could not set bounds: " + line); } } else if ("title".equals(cmd)) { String args = CommandParser.toString(parts, 1, parts.length); @@ -75,18 +66,19 @@ } else if ("line".equals(parts[1])) { dataHandler = new LineChart(); } else { - System.err.println("Unknown window data handler type: " + parts[1]); + context.err.println("Unknown window data handler type: " + parts[1]); } if (dataHandler != null) { System.out.println("Replacing window data handler! " + parts[1] + " " + dataHandler); - window.getContentPane().removeAll(); - window.getContentPane().add(dataHandler.getComponent()); + JComponent dataComponent = dataHandler.getComponent(); + window.removeAll(); + window.add(dataComponent); String title = window.getTitle(); if (title != null) { // Set title for the new data handler dataHandler.setProperty("title", new String[] { title }); } - window.repaint(); + dataComponent.repaint(); } } else if (dataHandler != null) { dataHandler.handleCommand(parts); @@ -96,7 +88,7 @@ try { jta.setTabSize(Integer.parseInt(parts[1])); } catch (Exception e) { - System.err.println("Could not set tab size: " + line); + context.err.println("Could not set tab size: " + line); } } else if ("font".equals(cmd)) { jta.setFont(Font.decode(parts[1])); @@ -110,29 +102,11 @@ } } - public void close() { - // TODO Notify all the currently active "streams" of lines to this windows data-handlers - window.setVisible(false); - window.dispose(); - window.removeAll(); - window = null; - } - - public void clear() { - jta.setText(""); - } - - public String getName() { - return targetName; - } - - public void print(PrintStream out) { - out.print("Window: " + targetName + " PIDs: ["); - CommandContext[] ctx = pids.toArray(new CommandContext[pids.size()]); - for (int i = 0; i < ctx.length; i++) { - if (i > 0) out.print(" ,"); - out.print(ctx[i].getPID()); + protected void closeTarget() { + if (window != null) { + window.setVisible(false); + window = null; } - out.println("]"); } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 11:47:34
|
Revision: 734 http://mspsim.svn.sourceforge.net/mspsim/?rev=734&view=rev Author: nifi Date: 2010-07-19 11:47:28 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Extended the ManagedWindow API Modified Paths: -------------- mspsim/se/sics/mspsim/ui/JFrameWindowManager.java mspsim/se/sics/mspsim/ui/ManagedWindow.java Modified: mspsim/se/sics/mspsim/ui/JFrameWindowManager.java =================================================================== --- mspsim/se/sics/mspsim/ui/JFrameWindowManager.java 2010-07-18 08:36:04 UTC (rev 733) +++ mspsim/se/sics/mspsim/ui/JFrameWindowManager.java 2010-07-19 11:47:28 UTC (rev 734) @@ -10,18 +10,43 @@ ManagedWindow w = new ManagedWindow() { private JFrame window = new JFrame(name); private boolean restored = false; - + + public void setBounds(int x, int y, int width, int height) { + window.setBounds(x, y, width, height); + } + public void add(Component component) { + window.add(component); if (!restored) { + restored = true; WindowUtils.restoreWindowBounds(name, window); - WindowUtils.addSaveOnShutdown(name, window); } - window.add(component); - window.pack(); } + + public void removeAll() { + window.removeAll(); + } + + public boolean isVisible() { + return window.isVisible(); + } + public void setVisible(boolean b) { + if (b != window.isVisible()) { + if (b) { + WindowUtils.addSaveOnShutdown(name, window); + } else { + WindowUtils.saveWindowBounds(name, window); + WindowUtils.removeSaveOnShutdown(window); + } + } window.setVisible(b); } + + public String getTitle() { + return window.getTitle(); + } + public void setTitle(String name) { window.setTitle(name); } Modified: mspsim/se/sics/mspsim/ui/ManagedWindow.java =================================================================== --- mspsim/se/sics/mspsim/ui/ManagedWindow.java 2010-07-18 08:36:04 UTC (rev 733) +++ mspsim/se/sics/mspsim/ui/ManagedWindow.java 2010-07-19 11:47:28 UTC (rev 734) @@ -4,10 +4,17 @@ public interface ManagedWindow { + public void setBounds(int x, int y, int width, int height); + public void add(Component component); + public void removeAll(); + public boolean isVisible(); + public void setVisible(boolean b); + public String getTitle(); + public void setTitle(String string); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-18 08:36:10
|
Revision: 733 http://mspsim.svn.sourceforge.net/mspsim/?rev=733&view=rev Author: nifi Date: 2010-07-18 08:36:04 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Changed service command to not start/stop if service is already started/stopped Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2010-07-18 08:05:41 UTC (rev 732) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2010-07-18 08:36:04 UTC (rev 733) @@ -46,7 +46,6 @@ import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Hashtable; -import java.util.Iterator; import java.util.regex.Pattern; import se.sics.mspsim.chip.RFListener; @@ -55,7 +54,6 @@ import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.MSP430Constants; import se.sics.mspsim.core.TimeEvent; -import se.sics.mspsim.util.ActiveComponent; import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.ConfigManager; @@ -288,10 +286,10 @@ name = context.getArgument(1); } if (registry.getComponent(name) != null) { - context.err.println("Another component with name " + name + " is already installed"); + context.err.println("Another component with name '" + name + "' is already installed"); return 1; } - Class pluginClass = null; + Class<?> pluginClass = null; PluginRepository plugins = (PluginRepository) registry.getComponent("pluginRepository"); try { try { @@ -319,38 +317,41 @@ if (context.getArgumentCount() == 0) { ServiceComponent[] sc = (ServiceComponent[]) registry.getAllComponents(ServiceComponent.class); for (int i = 0; i < sc.length; i++) { - context.out.printf(" %-20s %s\n",sc[i].getName(),sc[i].getStatus()); + context.out.printf(" %-20s %s\n", sc[i].getName(), sc[i].getStatus()); } - } else if (context.getArgumentCount() == 1){ - String name = context.getArgument(0); - ServiceComponent sc = getServiceForName(registry, name); - if (sc != null) { - context.out.printf(" %-20s %s\n",sc.getName(),sc.getStatus()); + return 0; + } + String name = context.getArgument(0); + ServiceComponent sc = getServiceForName(registry, name); + if (sc == null) { + context.err.println("could not find service '" + name + "'"); + return 1; + } + if (context.getArgumentCount() == 1) { + context.out.printf(" %-20s %s\n", sc.getName(), sc.getStatus()); + return 0; + } + String operation = context.getArgument(1); + if ("start".equals(operation)) { + if (sc.getStatus() == ServiceComponent.Status.STARTED) { + context.out.println("service " + sc.getName() + " already started"); } else { - context.out.println("can not find service" + name); + sc.start(); + context.out.println("service " + sc.getName() + " started"); } - } else { - String name = context.getArgument(0); - String operation = context.getArgument(1); - if ("start".equals(operation)) { - ServiceComponent sc = getServiceForName(registry, name); - if (sc != null) { - sc.start(); - context.out.println("service " + sc.getName() + " started"); - } else { - context.out.println("can not find service" + name); - } - } else if ("stop".equals(operation)) { - ServiceComponent sc = getServiceForName(registry, name); - if (sc != null) { - sc.stop(); - context.out.println("service " + sc.getName() + " stopped"); - } else { - context.out.println("can not find service" + name); - } + return 0; + } + if ("stop".equals(operation)) { + if (sc.getStatus() == ServiceComponent.Status.STOPPED) { + context.out.println("service " + sc.getName() + " already stopped"); + } else { + sc.stop(); + context.out.println("service " + sc.getName() + " stopped"); } + return 0; } - return 0; + context.err.println("unknown operation '" + operation + "'"); + return 1; } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-18 08:05:50
|
Revision: 732 http://mspsim.svn.sourceforge.net/mspsim/?rev=732&view=rev Author: nifi Date: 2010-07-18 08:05:41 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Close window when stopping service Modified Paths: -------------- mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java Modified: mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java =================================================================== --- mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java 2010-07-18 07:37:45 UTC (rev 731) +++ mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java 2010-07-18 08:05:41 UTC (rev 732) @@ -144,6 +144,10 @@ public final void stop() { status = Status.STOPPED; stopGUI(); + if (window != null) { + window.setVisible(false); + window = null; + } } protected abstract void startGUI(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-18 07:37:51
|
Revision: 731 http://mspsim.svn.sourceforge.net/mspsim/?rev=731&view=rev Author: nifi Date: 2010-07-18 07:37:45 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Updated platforms to use Leds API Modified Paths: -------------- mspsim/se/sics/mspsim/platform/esb/ESBGui.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java mspsim/se/sics/mspsim/platform/sky/SkyGui.java Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2010-07-18 07:37:45 UTC (rev 731) @@ -56,6 +56,7 @@ import se.sics.mspsim.core.ADC12; import se.sics.mspsim.core.ADCInput; import se.sics.mspsim.core.IOUnit; +import se.sics.mspsim.core.StateChangeListener; import se.sics.mspsim.platform.AbstractNodeGUI; public class ESBGui extends AbstractNodeGUI implements ADCInput { @@ -66,7 +67,7 @@ public static final int YELLOW_X = 9; public static final int RED_X = 16; public static final int LED_Y = 4; - private static final Rectangle LED_BOUNDS = new Rectangle(GREEN_X - 2, LED_Y - 4, RED_X + 6, LED_Y + 10); + private static final Rectangle LED_BOUNDS = new Rectangle(GREEN_X - 1, LED_Y - 3, RED_X - GREEN_X + 6, 9); public static final Color RED_TRANS = new Color(0xff,0x40,0x40,0xa0); public static final Color YELLOW_TRANS = new Color(0xff, 0xff, 0x00, 0xa0); @@ -84,7 +85,12 @@ Beeper beeper; - private ESBNode node; + private final ESBNode node; + private final StateChangeListener ledsListener = new StateChangeListener() { + public void stateChanged(Object source, int oldState, int newState) { + repaint(LED_BOUNDS); + } + }; private boolean buttonDown = false; private boolean resetDown = false; @@ -154,6 +160,8 @@ }; addMouseListener(mouseListener); + node.getLeds().addStateChangeListener(ledsListener); + IOUnit adc = node.getCPU().getIOUnit("ADC12"); if (adc instanceof ADC12) { ((ADC12) adc).setADCInput(0, this); @@ -184,14 +192,11 @@ protected void stopGUI() { removeMouseMotionListener(mouseMotionListener); removeMouseListener(mouseListener); + node.getLeds().removeStateChangeListener(ledsListener); // TODO cleanup } - public void ledsChanged() { - repaint(LED_BOUNDS); - } - private byte[] data = new byte[4]; public int nextData() { if (inDataLine != null) { Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-18 07:37:45 UTC (rev 731) @@ -41,6 +41,8 @@ package se.sics.mspsim.platform.esb; import java.io.IOException; + +import se.sics.mspsim.chip.Leds; import se.sics.mspsim.chip.TR1001; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; @@ -67,11 +69,13 @@ private IOPort port2; private IOPort port5; + private static final int[] LEDS = { 0xff6060, 0xffff00, 0x40ff40 }; public static final int RED_LED = 0x01; public static final int GREEN_LED = 0x02; public static final int YELLOW_LED = 0x04; public static final int BEEPER = 0x08; + private Leds leds; public boolean redLed; public boolean greenLed; public boolean yellowLed; @@ -87,6 +91,10 @@ super("ESB"); } + public Leds getLeds() { + return leds; + } + public void setPIR(boolean hi) { port1.setPinState(PIR_PIN, hi ? IOPort.PIN_HI : IOPort.PIN_LOW); } @@ -113,8 +121,8 @@ redLed = (data & RED_LED) == 0; greenLed = (data & GREEN_LED) == 0; yellowLed = (data & YELLOW_LED) == 0; + leds.setLeds((greenLed ? 4 : 0) + (yellowLed ? 2 : 0) + (redLed ? 1 : 0)); if (gui != null) { - gui.ledsChanged(); gui.beeper.beepOn((data & BEEPER) != 0); } @@ -151,6 +159,7 @@ if (usart0 instanceof USART) { radio = new TR1001(cpu, (USART) usart0); } + leds = new Leds(cpu, LEDS); } public void setupNode() { Modified: mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java 2010-07-18 07:37:45 UTC (rev 731) @@ -46,6 +46,7 @@ import java.awt.Rectangle; import java.awt.RenderingHints; +import se.sics.mspsim.core.StateChangeListener; import se.sics.mspsim.platform.AbstractNodeGUI; public class JCreateGui extends AbstractNodeGUI { @@ -63,6 +64,11 @@ LEDS_X[LEDS_X.length - 1] + 10 - LEDS_X[0], 10); private final JCreateNode node; + private final StateChangeListener ledsListener = new StateChangeListener() { + public void stateChanged(Object source, int oldState, int newState) { + repaint(LEDS_CLIP); + } + }; public JCreateGui(JCreateNode node) { super("JCreateGui", "images/jcreate.jpg"); @@ -71,10 +77,12 @@ @Override protected void startGUI() { + node.getLeds().addStateChangeListener(ledsListener); } @Override protected void stopGUI() { + node.getLeds().removeStateChangeListener(ledsListener); } @Override @@ -85,7 +93,7 @@ // Display all active leds ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - int leds = node.getLeds(); + int leds = node.getLeds().getLeds(); for (int i = 0; i < 8; i++) { if ((leds & (0x80 >> i)) != 0) { paintLed(g, i); @@ -106,8 +114,4 @@ g.fillRect(x + 3, LEDS_Y + 3, 2, 2); } - void updateLeds() { - repaint(LEDS_CLIP); - } - } Modified: mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java 2010-07-18 07:37:45 UTC (rev 731) @@ -43,6 +43,7 @@ import java.io.IOException; import se.sics.mspsim.chip.FileM25P80; +import se.sics.mspsim.chip.Leds; import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.chip.MMA7260QT; import se.sics.mspsim.core.ADC12; @@ -61,18 +62,23 @@ public static final int MODE_LEDS_OFF = 0; public static final int MODE_MAX = 9; + private static final int[] LEDS = { + 0xff6060, 0xff6060, 0xff6060, 0xff6060, + 0xff6060, 0xff6060, 0xff6060, 0xff6060 + }; + + private Leds leds; private MMA7260QT accelerometer; private M25P80 flash; private JCreateGui gui; - private int leds; public JCreateNode() { super("Sentilla JCreate"); setMode(MODE_LEDS_OFF); } - public int getLeds() { + public Leds getLeds() { return leds; } @@ -108,6 +114,7 @@ @Override public void setupNodePorts() { super.setupNodePorts(); + leds = new Leds(cpu, LEDS); accelerometer = new MMA7260QT(cpu); IOUnit io = cpu.getIOUnit("ADC12"); if (io instanceof ADC12) { @@ -146,8 +153,8 @@ super.portWrite(source, data); if (source == port5) { - if (leds != ~(data & 0xff)) { - leds = ~(data & 0xff); + if (leds.getLeds() != (~data & 0xff)) { + leds.setLeds(~data & 0xff); int newMode = 0; for (int i = 0; i < 8; i++) { @@ -156,10 +163,6 @@ } } setMode(newMode); - - if (gui != null) { - gui.updateLeds(); - } } } else if (source == port2) { int out = source.getOut() & source.getDirection(); Modified: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java 2010-07-18 07:37:45 UTC (rev 731) @@ -46,6 +46,7 @@ import java.awt.Rectangle; import java.awt.RenderingHints; +import se.sics.mspsim.core.StateChangeListener; import se.sics.mspsim.platform.AbstractNodeGUI; public class SentillaUSBGui extends AbstractNodeGUI { @@ -73,6 +74,11 @@ new Rectangle(LEDS_GREEN_X, LEDS_Y, LEDS_RED_X + 10 - LEDS_GREEN_X, 13); private final SentillaUSBNode node; + private final StateChangeListener ledsListener = new StateChangeListener() { + public void stateChanged(Object source, int oldState, int newState) { + repaint(LEDS_CLIP); + } + }; public SentillaUSBGui(SentillaUSBNode node) { super("SentillaUSBGui", "images/sentilla-usb.jpg"); @@ -81,10 +87,12 @@ @Override protected void startGUI() { + node.getLeds().addStateChangeListener(ledsListener); } @Override protected void stopGUI() { + node.getLeds().removeStateChangeListener(ledsListener); } @Override @@ -114,8 +122,4 @@ g.fillRect(x + 3, LEDS_Y + 3, 2, 2); } - void updateLeds() { - repaint(LEDS_CLIP); - } - } Modified: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java 2010-07-18 07:37:45 UTC (rev 731) @@ -43,6 +43,7 @@ import java.io.IOException; import se.sics.mspsim.chip.FileM25P80; +import se.sics.mspsim.chip.Leds; import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.USART; @@ -59,12 +60,14 @@ public static final int MODE_LEDS_2 = 2; public static final int MODE_MAX = MODE_LEDS_2; + private static final int[] LEDS = { 0xff6060, 0x40ff40 }; public static final int GREEN_LED = 0x20; public static final int RED_LED = 0x10; private M25P80 flash; private SentillaUSBGui gui; + private Leds leds; boolean redLed; boolean greenLed; @@ -73,6 +76,10 @@ setMode(MODE_LEDS_OFF); } + public Leds getLeds() { + return leds; + } + public M25P80 getFlash() { return flash; } @@ -101,6 +108,7 @@ @Override public void setupNodePorts() { super.setupNodePorts(); + leds = new Leds(cpu, LEDS); if (flashFile != null) { setFlash(new FileM25P80(cpu, flashFile)); } @@ -120,12 +128,9 @@ if (source == port5) { redLed = (data & RED_LED) == 0; greenLed = (data & GREEN_LED) == 0; + leds.setLeds((redLed ? 1 : 0) + (greenLed ? 2 : 0)); int newMode = (redLed ? 1 : 0) + (greenLed ? 1 : 0); setMode(newMode); - - if (gui != null) { - gui.updateLeds(); - } } } Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-07-18 07:37:45 UTC (rev 731) @@ -1,4 +1,5 @@ package se.sics.mspsim.platform.sky; +import se.sics.mspsim.chip.Leds; import se.sics.mspsim.chip.SHT11; import se.sics.mspsim.core.IOPort; @@ -18,6 +19,7 @@ public static final int SHT11_CLK = 1 << SHT11_CLK_PIN; public static final int SHT11_DATA = 1 << SHT11_DATA_PIN; + private static final int[] LEDS = { 0xff8000, 0x60ff60, 0xa0a0ff }; public static final int BLUE_LED = 0x40; public static final int GREEN_LED = 0x20; public static final int RED_LED = 0x10; @@ -25,7 +27,8 @@ public boolean redLed; public boolean blueLed; public boolean greenLed; - + + private Leds leds; public SHT11 sht11; public SkyGui gui; @@ -35,6 +38,10 @@ setMode(MODE_LEDS_OFF); } + public Leds getLeds() { + return leds; + } + public void setButton(boolean hi) { port2.setPinState(BUTTON_PIN, hi ? IOPort.PIN_HI : IOPort.PIN_LOW); } @@ -42,6 +49,7 @@ public void setupNodePorts() { super.setupNodePorts(); + leds = new Leds(cpu, LEDS); sht11 = new SHT11(cpu); if (port1 != null) { sht11.setDataPort(port1, SHT11_DATA_PIN); @@ -62,12 +70,9 @@ redLed = (data & RED_LED) == 0; blueLed = (data & BLUE_LED) == 0; greenLed = (data & GREEN_LED) == 0; + leds.setLeds((redLed ? 1 : 0) + (greenLed ? 2 : 0) + (blueLed ? 4 : 0)); int newMode = (redLed ? 1 : 0) + (greenLed ? 1 : 0) + (blueLed ? 1 : 0); setMode(newMode); - - if (gui != null) { - gui.repaint(); - } } else if (source == port1) { sht11.clockPin((data & SHT11_CLK) != 0); sht11.dataPin((data & SHT11_DATA) != 0); Modified: mspsim/se/sics/mspsim/platform/sky/SkyGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2010-07-18 07:13:59 UTC (rev 730) +++ mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2010-07-18 07:37:45 UTC (rev 731) @@ -42,9 +42,11 @@ package se.sics.mspsim.platform.sky; import java.awt.Color; import java.awt.Graphics; +import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import se.sics.mspsim.core.StateChangeListener; import se.sics.mspsim.platform.AbstractNodeGUI; public class SkyGui extends AbstractNodeGUI { @@ -64,8 +66,15 @@ public static final Color GREEN_C = new Color(0xff60ff60); public static final Color RED_C = new Color(0xffff8000); - private MoteIVNode node; + private static final Rectangle LEDS_BOUNDS = new Rectangle(LED_X, RED_Y, 9, BLUE_Y - RED_Y + 5); + private final MoteIVNode node; + private final StateChangeListener ledsListener = new StateChangeListener() { + public void stateChanged(Object source, int oldState, int newState) { + repaint(LEDS_BOUNDS); + } + }; + public SkyGui(MoteIVNode node) { super("SkyGui", "images/sky.jpg"); this.node = node; @@ -108,6 +117,7 @@ }; this.addMouseListener(mouseHandler); + node.getLeds().addStateChangeListener(ledsListener); } protected void paintComponent(Graphics g) { @@ -138,6 +148,7 @@ } protected void stopGUI() { + node.getLeds().removeStateChangeListener(ledsListener); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-18 07:14:05
|
Revision: 730 http://mspsim.svn.sourceforge.net/mspsim/?rev=730&view=rev Author: nifi Date: 2010-07-18 07:13:59 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Added generic Leds Added Paths: ----------- mspsim/se/sics/mspsim/chip/Leds.java Added: mspsim/se/sics/mspsim/chip/Leds.java =================================================================== --- mspsim/se/sics/mspsim/chip/Leds.java (rev 0) +++ mspsim/se/sics/mspsim/chip/Leds.java 2010-07-18 07:13:59 UTC (rev 730) @@ -0,0 +1,117 @@ + /* + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * Leds + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : 17 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.chip; + +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.StateChangeListener; +import se.sics.mspsim.util.ArrayUtils; +import se.sics.mspsim.util.Utils; + +public class Leds extends Chip { + + private final int[] ledColors; + + private int leds; + private StateChangeListener[] stateListeners; + + public Leds(MSP430Core cpu, int[] ledColors) { + super("Leds", cpu); + if (ledColors == null) { + throw new NullPointerException("ledColors"); + } + this.ledColors = ledColors; + } + + public int getLeds() { + return leds; + } + + public void setLeds(int leds) { + if (this.leds != leds) { + int oldLeds = this.leds; + this.leds = leds; + fireStateChanged(oldLeds, leds); + } + } + + public boolean isLedOn(int led) { + return (leds & (1 << led)) != 0; + } + + public int getLedsColor(int led) { + return ledColors[led]; + } + + public int getLedsCount() { + return ledColors.length; + } + + private void fireStateChanged(int oldState, int newState) { + StateChangeListener[] listeners = this.stateListeners; + if (listeners != null) { + for(StateChangeListener listener : listeners) { + listener.stateChanged(this, oldState, newState); + } + } + } + + public synchronized void addStateChangeListener(StateChangeListener l) { + this.stateListeners = (StateChangeListener[]) ArrayUtils.add(StateChangeListener.class, this.stateListeners, l); + } + + public synchronized void removeStateChangeListener(StateChangeListener l) { + this.stateListeners = (StateChangeListener[]) ArrayUtils.remove(this.stateListeners, l); + } + + @Override + public int getModeMax() { + return 0; + } + + @Override + public String info() { + return "Leds: " + (ledColors.length <= 8 ? Utils.binary8(leds) : Utils.binary16(leds)); + } + +} Property changes on: mspsim/se/sics/mspsim/chip/Leds.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-18 07:00:35
|
Revision: 729 http://mspsim.svn.sourceforge.net/mspsim/?rev=729&view=rev Author: nifi Date: 2010-07-18 07:00:28 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Added listener for state changes Added Paths: ----------- mspsim/se/sics/mspsim/core/StateChangeListener.java Added: mspsim/se/sics/mspsim/core/StateChangeListener.java =================================================================== --- mspsim/se/sics/mspsim/core/StateChangeListener.java (rev 0) +++ mspsim/se/sics/mspsim/core/StateChangeListener.java 2010-07-18 07:00:28 UTC (rev 729) @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * StateChangeListener + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : 17 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.core; + +/** + * + */ +public interface StateChangeListener { + + public void stateChanged(Object source, int oldState, int newState); + +} Property changes on: mspsim/se/sics/mspsim/core/StateChangeListener.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-18 06:22:32
|
Revision: 728 http://mspsim.svn.sourceforge.net/mspsim/?rev=728&view=rev Author: nifi Date: 2010-07-18 06:22:25 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Added run rules for Sentilla JCreate and USB Modified Paths: -------------- mspsim/build.xml Modified: mspsim/build.xml =================================================================== --- mspsim/build.xml 2010-07-09 23:17:40 UTC (rev 727) +++ mspsim/build.xml 2010-07-18 06:22:25 UTC (rev 728) @@ -23,7 +23,8 @@ </target> <target name="compile" depends="init" description="compile the source"> - <javac srcdir="${src}" destdir="${build}" classpathref="classpath" debug="${javac.debug}"/> + <javac srcdir="${src}" destdir="${build}" classpathref="classpath" debug="${javac.debug}" + includeantruntime="false"/> </target> <target name="jar" depends="compile" description="generate MSPSim jar file" > @@ -66,6 +67,20 @@ </java> </target> + <target name="runjcreate" depends="jar" description="run MSPSim with platform Sentilla JCreate"> + <property name="FIRMWAREFILE" value="firmware/sky/blink.firmware"/> + <java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.jcreate.JCreateNode"> + <arg value="${FIRMWAREFILE}"/> + </java> + </target> + + <target name="runsentillausb" depends="jar" description="run MSPSim with platform Sentilla Gateway USB"> + <property name="FIRMWAREFILE" value="firmware/sky/blink.firmware"/> + <java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.sentillausb.SentillaUSBNode"> + <arg value="${FIRMWAREFILE}"/> + </java> + </target> + <target name="run" depends="runsky"/> <target name="cputest" depends="jar" description="run MSPSim CPU test"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 23:17:47
|
Revision: 727 http://mspsim.svn.sourceforge.net/mspsim/?rev=727&view=rev Author: nifi Date: 2010-07-09 23:17:40 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added support for platforms Sentilla JCreate and Sentilla Gateway USB Modified Paths: -------------- mspsim/se/sics/mspsim/Main.java Added Paths: ----------- mspsim/images/jcreate.jpg mspsim/images/sentilla-usb.jpg mspsim/se/sics/mspsim/chip/MMA7260QT.java mspsim/se/sics/mspsim/platform/jcreate/ mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java mspsim/se/sics/mspsim/platform/sentillausb/ mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java Added: mspsim/images/jcreate.jpg =================================================================== (Binary files differ) Property changes on: mspsim/images/jcreate.jpg ___________________________________________________________________ Added: svn:mime-type + image/jpeg Added: mspsim/images/sentilla-usb.jpg =================================================================== (Binary files differ) Property changes on: mspsim/images/sentilla-usb.jpg ___________________________________________________________________ Added: svn:mime-type + image/jpeg Modified: mspsim/se/sics/mspsim/Main.java =================================================================== --- mspsim/se/sics/mspsim/Main.java 2010-07-09 23:09:50 UTC (rev 726) +++ mspsim/se/sics/mspsim/Main.java 2010-07-09 23:17:40 UTC (rev 727) @@ -66,6 +66,22 @@ return null; } + private static String getNodeTypeByPlatform(String platform) { + if ("jcreate".equals(platform)) { + return "se.sics.mspsim.platform.jcreate.JCreateNode"; + } + if ("sentilla-usb".equals(platform)) { + return "se.sics.mspsim.platform.sentillausb.SentillaUSBNode"; + } + if ("esb".equals(platform)) { + return "se.sics.mspsim.platform.esb.ESBNode"; + } + // Try to guess the node type. + return "se.sics.mspsim.platform." + platform + '.' + + Character.toUpperCase(platform.charAt(0)) + + platform.substring(1).toLowerCase() + "Node"; + } + public static void main(String[] args) throws IOException { ArgumentManager config = new ArgumentManager(); config.handleArguments(args); @@ -77,13 +93,8 @@ node = createNode(nodeType); } else { platform = config.getProperty("platform", "sky"); - nodeType = "se.sics.mspsim.platform." + platform + '.' + - Character.toUpperCase(platform.charAt(0)) + platform.substring(1).toLowerCase() + "Node"; + nodeType = getNodeTypeByPlatform(platform); node = createNode(nodeType); - if (node == null) { - nodeType = "se.sics.mspsim.platform." + platform + '.' + platform.toUpperCase() + "Node"; - node = createNode(nodeType); - } } if (node == null) { System.err.println("MSPSim does not currently support the platform '" + platform + "'."); Added: mspsim/se/sics/mspsim/chip/MMA7260QT.java =================================================================== --- mspsim/se/sics/mspsim/chip/MMA7260QT.java (rev 0) +++ mspsim/se/sics/mspsim/chip/MMA7260QT.java 2010-07-09 23:17:40 UTC (rev 727) @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2010, 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 MSPSim. + * + * ----------------------------------------------------------------- + * + * MMA7260QT + * + * Authors : Niclas Finne + * Created : 7 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.chip; +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.MSP430Core; + +/** + * MMA7260QT - 1.5g-6g Three Axis Low-g Micromachined Accelerometer + */ +public class MMA7260QT extends Chip { + + public static final int MODE_SLEEP = 0x00; + public static final int MODE_ACTIVE = 0x01; + private static final String[] MODE_NAMES = new String[] { + "sleep", "active" + }; + private static final float[] GSELECT = new float[] { + 1.5f, 2, 4, 6 + }; + + private int x = 4095, y = 2715, z = 2715; + private int gSelect = 0; + + public MMA7260QT(MSP430Core cpu) { + super("MMA7260QT", "Accelerometer", cpu); + setModeNames(MODE_NAMES); + setMode(MODE_SLEEP); + } + + public int getADCX() { + int v = getX(); + return v > 4095 ? 4095 : v; + } + + public int getADCY() { + int v = getY(); + return v > 4095 ? 4095 : v; + } + + public int getADCZ() { + int v = getZ(); + return v > 4095 ? 4095 : v; + } + + public void setX(int x) { + this.x = x; + } + + public int getX() { + return x; + } + + public void setY(int y) { + this.y = y; + } + + public int getY() { + return y; + } + + public void setZ(int z) { + this.z = z; + } + + public int getZ() { + return z; + } + + public int getSensitivity() { + return gSelect; + } + + public String getSensitivityAsString() { + return GSELECT[gSelect] + "g (" + (int)(1200/GSELECT[gSelect]) + "mV/g)"; + } + + public void setSensitivity(int gSelect) { + this.gSelect = gSelect & 0x03; + } + + public void setMode(int mode) { + super.setMode(mode); + } + + @Override + public int getModeMax() { + return MODE_NAMES.length; + } + + public String info() { + return "Mode: " + getModeName(getMode()) + + " Sensitivity: " + getSensitivityAsString() + + " [x=" + getADCX() + ",y=" + getADCY() + ",z=" + getADCZ() + ']'; + } + +} Property changes on: mspsim/se/sics/mspsim/chip/MMA7260QT.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Added: mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java (rev 0) +++ mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java 2010-07-09 23:17:40 UTC (rev 727) @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * JCreateGui + * + * Author : Joakim Eriksson, Niclas Finne + * Created : 7 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.platform.jcreate; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; + +import se.sics.mspsim.platform.AbstractNodeGUI; + +public class JCreateGui extends AbstractNodeGUI { + + private static final long serialVersionUID = -1377998375300964966L; + + private static final Color RED_TRANS = new Color(0xff, 0x40, 0x40, 0xa0); + private static final Color RED_O = new Color(0xff,0x40,0x40,0xff); + private static final Color RED_I = new Color(0xff,0x60,0x60,0xff); + private static final Color RED_CORE = new Color(0xff,0xa0,0xa0,0xff); + + private static final int LEDS_Y = 66; + private static final int LEDS_X[] = {29, 49, 67, 86, 103, 122, 142, 162}; + private static final Rectangle LEDS_CLIP = new Rectangle(LEDS_X[0], LEDS_Y, + LEDS_X[LEDS_X.length - 1] + 10 - LEDS_X[0], 10); + + private final JCreateNode node; + + public JCreateGui(JCreateNode node) { + super("JCreateGui", "images/jcreate.jpg"); + this.node = node; + } + + @Override + protected void startGUI() { + } + + @Override + protected void stopGUI() { + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + Color old = g.getColor(); + // Display all active leds + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + int leds = node.getLeds(); + for (int i = 0; i < 8; i++) { + if ((leds & (0x80 >> i)) != 0) { + paintLed(g, i); + } + } + g.setColor(old); + } + + protected void paintLed(Graphics g, int led) { + int x = LEDS_X[led]; + g.setColor(RED_TRANS); + g.fillOval(x, LEDS_Y, 10, 10); + g.setColor(RED_O); + g.fillOval(x + 2, LEDS_Y + 2, 6, 6); + g.setColor(RED_I); + g.fillOval(x + 3, LEDS_Y + 3, 4, 4); + g.setColor(RED_CORE); + g.fillRect(x + 3, LEDS_Y + 3, 2, 2); + } + + void updateLeds() { + repaint(LEDS_CLIP); + } + +} Property changes on: mspsim/se/sics/mspsim/platform/jcreate/JCreateGui.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Added: mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java (rev 0) +++ mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java 2010-07-09 23:17:40 UTC (rev 727) @@ -0,0 +1,187 @@ +/** + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * JCreateNode + * + * Author : Joakim Eriksson, Niclas Finne + * Created : 7 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.platform.jcreate; +import java.io.IOException; + +import se.sics.mspsim.chip.FileM25P80; +import se.sics.mspsim.chip.M25P80; +import se.sics.mspsim.chip.MMA7260QT; +import se.sics.mspsim.core.ADC12; +import se.sics.mspsim.core.ADCInput; +import se.sics.mspsim.core.IOPort; +import se.sics.mspsim.core.IOUnit; +import se.sics.mspsim.core.USART; +import se.sics.mspsim.platform.sky.CC2420Node; +import se.sics.mspsim.util.ArgumentManager; + +/** + * Emulation of Sentilla JCreate Mote + */ +public class JCreateNode extends CC2420Node { + + public static final int MODE_LEDS_OFF = 0; + public static final int MODE_MAX = 9; + + private MMA7260QT accelerometer; + private M25P80 flash; + + private JCreateGui gui; + private int leds; + + public JCreateNode() { + super("Sentilla JCreate"); + setMode(MODE_LEDS_OFF); + } + + public int getLeds() { + return leds; + } + + public MMA7260QT getAccelerometer() { + return accelerometer; + } + + public M25P80 getFlash() { + return flash; + } + + public void setFlash(M25P80 flash) { + this.flash = flash; + registry.registerComponent("xmem", flash); + } + + // USART Listener + @Override + public void dataReceived(USART source, int data) { + radio.dataReceived(source, data); + flash.dataReceived(source, data); + /* if nothing selected, just write back a random byte to this device */ + if (!radio.getChipSelect() && !flash.getChipSelect()) { + source.byteReceived(0); + } + } + + @Override + protected void flashWrite(IOPort source, int data) { + flash.portWrite(source, data); + } + + @Override + public void setupNodePorts() { + super.setupNodePorts(); + accelerometer = new MMA7260QT(cpu); + IOUnit io = cpu.getIOUnit("ADC12"); + if (io instanceof ADC12) { + ADC12 adc = (ADC12) io; + adc.setADCInput(4, new ADCInput() { + public int nextData() { + return accelerometer.getADCX(); + } + }); + adc.setADCInput(5, new ADCInput() { + public int nextData() { + return accelerometer.getADCY(); + } + }); + adc.setADCInput(6, new ADCInput() { + public int nextData() { + return accelerometer.getADCZ(); + } + }); + } + + if (flashFile != null) { + setFlash(new FileM25P80(cpu, flashFile)); + } + } + + public void setupGUI() { + if (gui == null) { + gui = new JCreateGui(this); + registry.registerComponent("nodegui", gui); + } + } + + @Override + public void portWrite(IOPort source, int data) { + super.portWrite(source, data); + + if (source == port5) { + if (leds != ~(data & 0xff)) { + leds = ~(data & 0xff); + + int newMode = 0; + for (int i = 0; i < 8; i++) { + if ((data & (1 << i)) != 0) { + newMode++; + } + } + setMode(newMode); + + if (gui != null) { + gui.updateLeds(); + } + } + } else if (source == port2) { + int out = source.getOut() & source.getDirection(); + if ((out & 0x08) == 0x08) { + accelerometer.setMode(MMA7260QT.MODE_ACTIVE); + } else { + accelerometer.setMode(MMA7260QT.MODE_SLEEP); + } + accelerometer.setSensitivity(out & 0x03); + } + } + + @Override + public int getModeMax() { + return MODE_MAX; + } + + public static void main(String[] args) throws IOException { + JCreateNode node = new JCreateNode(); + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + node.setupArgs(config); + } + +} Property changes on: mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Added: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java (rev 0) +++ mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java 2010-07-09 23:17:40 UTC (rev 727) @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * SentillaUSBGui + * + * Author : Joakim Eriksson, Niclas Finne + * Created : 7 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.platform.sentillausb; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; + +import se.sics.mspsim.platform.AbstractNodeGUI; + +public class SentillaUSBGui extends AbstractNodeGUI { + + private static final long serialVersionUID = -692114865639672141L; + + private static final Color[] RED = new Color[] { + new Color(0xff, 0x40, 0x40, 0xa0), + new Color(0xff,0x40,0x40,0xff), + new Color(0xff,0x60,0x60,0xff), + new Color(0xff,0xa0,0xa0,0xff) + }; + private static final Color[] GREEN = new Color[] { + new Color(0x40, 0xff, 0x40, 0xa0), + new Color(0x40,0xff,0x40,0xff), + new Color(0x60,0xff,0x60,0xff), + new Color(0xa0,0xff,0xa0,0xff) + }; + + private static final int LEDS_GREEN_X = 8; + private static final int LEDS_RED_X = 126; + private static final int LEDS_Y = 89; + + private static final Rectangle LEDS_CLIP = + new Rectangle(LEDS_GREEN_X, LEDS_Y, LEDS_RED_X + 10 - LEDS_GREEN_X, 13); + + private final SentillaUSBNode node; + + public SentillaUSBGui(SentillaUSBNode node) { + super("SentillaUSBGui", "images/sentilla-usb.jpg"); + this.node = node; + } + + @Override + protected void startGUI() { + } + + @Override + protected void stopGUI() { + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + Color old = g.getColor(); + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + if (node.greenLed) { + paintLed(g, LEDS_GREEN_X, GREEN); + } + if (node.redLed) { + paintLed(g, LEDS_RED_X, RED); + } + g.setColor(old); + } + + protected void paintLed(Graphics g, int x, Color[] colors) { + g.setColor(colors[0]); + g.fillOval(x, LEDS_Y, 10, 13); + g.setColor(colors[1]); + g.fillOval(x + 2, LEDS_Y + 2, 6, 7); + g.setColor(colors[2]); + g.fillOval(x + 3, LEDS_Y + 3, 4, 5); + g.setColor(colors[3]); + g.fillRect(x + 3, LEDS_Y + 3, 2, 2); + } + + void updateLeds() { + repaint(LEDS_CLIP); + } + +} Property changes on: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBGui.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Added: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java (rev 0) +++ mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java 2010-07-09 23:17:40 UTC (rev 727) @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2010, 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 MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * JCreateNode + * + * Author : Joakim Eriksson, Niclas Finne + * Created : 7 jul 2010 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.platform.sentillausb; +import java.io.IOException; + +import se.sics.mspsim.chip.FileM25P80; +import se.sics.mspsim.chip.M25P80; +import se.sics.mspsim.core.IOPort; +import se.sics.mspsim.core.USART; +import se.sics.mspsim.platform.sky.CC2420Node; +import se.sics.mspsim.util.ArgumentManager; + +/** + * Emulation of Sentilla Gateway USB Mote + */ +public class SentillaUSBNode extends CC2420Node { + + public static final int MODE_LEDS_OFF = 0; + public static final int MODE_LEDS_1 = 1; + public static final int MODE_LEDS_2 = 2; + public static final int MODE_MAX = MODE_LEDS_2; + + public static final int GREEN_LED = 0x20; + public static final int RED_LED = 0x10; + + private M25P80 flash; + private SentillaUSBGui gui; + + boolean redLed; + boolean greenLed; + + public SentillaUSBNode() { + super("Sentilla USB"); + setMode(MODE_LEDS_OFF); + } + + public M25P80 getFlash() { + return flash; + } + + public void setFlash(M25P80 flash) { + this.flash = flash; + registry.registerComponent("xmem", flash); + } + + // USART Listener + @Override + public void dataReceived(USART source, int data) { + radio.dataReceived(source, data); + flash.dataReceived(source, data); + /* if nothing selected, just write back a random byte to this device */ + if (!radio.getChipSelect() && !flash.getChipSelect()) { + source.byteReceived(0); + } + } + + @Override + protected void flashWrite(IOPort source, int data) { + flash.portWrite(source, data); + } + + @Override + public void setupNodePorts() { + super.setupNodePorts(); + if (flashFile != null) { + setFlash(new FileM25P80(cpu, flashFile)); + } + } + + public void setupGUI() { + if (gui == null) { + gui = new SentillaUSBGui(this); + registry.registerComponent("nodegui", gui); + } + } + + @Override + public void portWrite(IOPort source, int data) { + super.portWrite(source, data); + + if (source == port5) { + redLed = (data & RED_LED) == 0; + greenLed = (data & GREEN_LED) == 0; + int newMode = (redLed ? 1 : 0) + (greenLed ? 1 : 0); + setMode(newMode); + + if (gui != null) { + gui.updateLeds(); + } + } + } + + @Override + public int getModeMax() { + return MODE_MAX; + } + + public static void main(String[] args) throws IOException { + SentillaUSBNode node = new SentillaUSBNode(); + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + node.setupArgs(config); + } + +} Property changes on: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 23:09:56
|
Revision: 726 http://mspsim.svn.sourceforge.net/mspsim/?rev=726&view=rev Author: nifi Date: 2010-07-09 23:09:50 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added serial monitoring UI (moved from node gui) Modified Paths: -------------- mspsim/se/sics/mspsim/platform/esb/ESBNode.java Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-09 22:43:54 UTC (rev 725) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-09 23:09:50 UTC (rev 726) @@ -50,6 +50,7 @@ import se.sics.mspsim.extutil.jfreechart.DataChart; import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.ui.SerialMon; import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.OperatingModeStatistics; @@ -155,22 +156,39 @@ public void setupNode() { setupNodePorts(); - stats.addMonitor(this); - stats.addMonitor(radio); - stats.addMonitor(cpu); + if (stats != null) { + stats.addMonitor(this); + stats.addMonitor(radio); + stats.addMonitor(cpu); + } if (!config.getPropertyAsBoolean("nogui", true)) { + setupGUI(); + + // Add some windows for listening to serial output + IOUnit usart = cpu.getIOUnit("USART 1"); + if (usart instanceof USART) { + SerialMon serial = new SerialMon((USART)usart, "RS232 Port Output"); + ((USART) usart).setUSARTListener(serial); + } + + if (stats != null) { + // A HACK for some "graphs"!!! + DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle"); + registry.registerComponent("dutychart", dataChart); + DataSourceSampler dss = dataChart.setupChipFrame(cpu); + dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getID(), 0, OperatingModeStatistics.OP_INVERT)); + dataChart.addDataSource(dss, "Listen", stats.getDataSource(radio.getID(), TR1001.MODE_RX_ON)); + dataChart.addDataSource(dss, "Transmit", stats.getDataSource(radio.getID(), TR1001.MODE_TXRX_ON)); + dataChart.addDataSource(dss, "CPU", stats.getDataSource(cpu.getID(), MSP430.MODE_ACTIVE)); + } + } + } + + public void setupGUI() { + if (gui == null) { gui = new ESBGui(this); registry.registerComponent("nodegui", gui); - - // A HACK for some "graphs"!!! - DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle"); - registry.registerComponent("dutychart", dataChart); - DataSourceSampler dss = dataChart.setupChipFrame(cpu); - dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getID(), 0, OperatingModeStatistics.OP_INVERT)); - dataChart.addDataSource(dss, "Listen", stats.getDataSource("TR1001", TR1001.MODE_RX_ON)); - dataChart.addDataSource(dss, "Transmit", stats.getDataSource("TR1001", TR1001.MODE_TXRX_ON)); - dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430", MSP430.MODE_ACTIVE)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 22:44:00
|
Revision: 725 http://mspsim.svn.sourceforge.net/mspsim/?rev=725&view=rev Author: nifi Date: 2010-07-09 22:43:54 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Updated to use Loggable instead of printing to system out Modified Paths: -------------- mspsim/se/sics/mspsim/chip/AT45DB.java mspsim/se/sics/mspsim/chip/Beeper.java mspsim/se/sics/mspsim/chip/DS2411.java mspsim/se/sics/mspsim/chip/FileAT45DB.java mspsim/se/sics/mspsim/chip/FileM25P80.java mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/chip/SHT11.java Modified: mspsim/se/sics/mspsim/chip/AT45DB.java =================================================================== --- mspsim/se/sics/mspsim/chip/AT45DB.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/AT45DB.java 2010-07-09 22:43:54 UTC (rev 725) @@ -45,8 +45,6 @@ public abstract class AT45DB extends Chip implements USARTListener { - public static final boolean DEBUG = false; - public static final int PAGE_SIZE = 264; public static final int NUM_PAGES = 2048; public static final int SIZE_BYTES = PAGE_SIZE * NUM_PAGES; @@ -148,7 +146,7 @@ if (chipSelect) { //if (DEBUG) { - // System.out.println("AT45DB: byte received: " + data); + // log("byte received: " + data); //} switch(state) { @@ -164,15 +162,15 @@ bufferAddress |= data; if(DEBUG) - System.out.println("AT45DB: Address - PA[10-0]: " + pageAddress + " BA[8-0]: " + bufferAddress); + log("Address - PA[10-0]: " + pageAddress + " BA[8-0]: " + bufferAddress); if(dummy == 0) { - if(DEBUG) System.out.println("AT45DB: State " + state + " -> " + next_state); + if(DEBUG) log("State " + state + " -> " + next_state); state = next_state; } }else{ if(--dummy == 0) { - if(DEBUG) System.out.println("AT45DB: State " + state + " -> " + next_state); + if(DEBUG) log("State " + state + " -> " + next_state); state = next_state; } } @@ -185,7 +183,7 @@ buf_num = (state == BUFFER1_READ ? 1 : 2); source.byteReceived(readBuffer(buf_num, bufferAddress++)); if(bufferAddress >= PAGE_SIZE) - System.out.println("AT45DB: ERROR: Buffer Read past buffer size: " + bufferAddress); + logw("ERROR: Buffer Read past buffer size: " + bufferAddress); break; case BUFFER1_WRITE: @@ -193,7 +191,7 @@ buf_num = (state == BUFFER1_WRITE ? 1 : 2); writeBuffer(buf_num, bufferAddress++, data); if(bufferAddress >= PAGE_SIZE) - System.out.println("AT45DB: ERROR: Buffer Write past buffer size: " + bufferAddress); + logw("ERROR: Buffer Write past buffer size: " + bufferAddress); source.byteReceived(0); break; @@ -211,7 +209,7 @@ case BUFFER1_TO_PAGE_ERASE: case BUFFER2_TO_PAGE_ERASE: if(DEBUG) - System.out.println("AT45DB: Buffer" + (data == BUFFER1_TO_PAGE_ERASE ? "1" : "2") + " to Page with Erase Command"); + log("Buffer" + (data == BUFFER1_TO_PAGE_ERASE ? "1" : "2") + " to Page with Erase Command"); pos = 0; state = READ_ADDRESS; next_state = data; @@ -223,7 +221,7 @@ case BUFFER1_READ: case BUFFER2_READ: if(DEBUG) - System.out.println("AT45DB: Read Buffer Command " + (data == BUFFER1_READ ? "Buffer1" : "Buffer2")); + log("Read Buffer Command " + (data == BUFFER1_READ ? "Buffer1" : "Buffer2")); pos = 0; state = READ_ADDRESS; next_state = data; @@ -235,7 +233,7 @@ case BUFFER1_WRITE: case BUFFER2_WRITE: if(DEBUG) - System.out.println("AT45DB: Write Buffer Command " + (data == BUFFER1_WRITE ? "Buffer1" : "Buffer2")); + log("Write Buffer Command " + (data == BUFFER1_WRITE ? "Buffer1" : "Buffer2")); pos = 0; state = READ_ADDRESS; next_state = data; @@ -247,7 +245,7 @@ case PAGE_TO_BUFFER1: case PAGE_TO_BUFFER2: if(DEBUG) - System.out.println("AT45DB: Page To Buffer " + (data == PAGE_TO_BUFFER1 ? "1" : "2") + " Command"); + log("Page To Buffer " + (data == PAGE_TO_BUFFER1 ? "1" : "2") + " Command"); pos = 0; state = READ_ADDRESS; next_state = data; @@ -257,12 +255,12 @@ break; case STATUS_REGISTER_READ: - if(DEBUG) System.out.println("AT45DB: Read status register command. status: " + status); + if(DEBUG) log("Read status register command. status: " + status); state = STATUS_REGISTER_READ; source.byteReceived(0); break; default: - System.out.println("AT45DB: WARNING: Command not implemented: " + data); + logw("WARNING: Command not implemented: " + data); source.byteReceived(0); break; } @@ -276,7 +274,7 @@ private int readBuffer(int num, int address) { //if(DEBUG) { - // System.out.println("AT45DB: Reading RAM Buffer" + num + " Address: " + Integer.toHexString(address)); + // log("Reading RAM Buffer" + num + " Address: " + Integer.toHexString(address)); //} if(num == 1) return buffer1[address & 0x1ff]; @@ -286,7 +284,7 @@ private void writeBuffer(int num, int address, int data) { //if(DEBUG) { - // System.out.println("AT45DB: Writing RAM Buffer" + num + " Address: " + Integer.toHexString(address) + " Data: " + data); + // log("Writing RAM Buffer" + num + " Address: " + Integer.toHexString(address) + " Data: " + data); //} if(num == 1) buffer1[address & 0x1ff] = (byte)data; @@ -299,7 +297,7 @@ if(Reset == true) state = STATE_RESET; if(DEBUG) { - System.out.println("AT45DB: Reset: " + Reset); + log("Reset: " + Reset); } } public void setChipSelect(boolean select) { @@ -328,7 +326,7 @@ } if(DEBUG) { - System.out.println("AT45DB: Chip Select: " + chipSelect); + log("Chip Select: " + chipSelect); } } Modified: mspsim/se/sics/mspsim/chip/Beeper.java =================================================================== --- mspsim/se/sics/mspsim/chip/Beeper.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/Beeper.java 2010-07-09 22:43:54 UTC (rev 725) @@ -71,13 +71,13 @@ try { dataLine = (SourceDataLine) AudioSystem.getLine(dli); if (dataLine == null) { - System.out.println("DataLine: not existing..."); + logw("DataLine: not existing..."); } else { dataLine.open(dataLine.getFormat(), 16384); volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN); } } catch (Exception e) { - System.out.println("Problem while getting data line " + e); + logw("Problem while getting data line " + e); } double f1 = 0; for (int i = 0, n = WAVE_LEN; i < n; i++) { Modified: mspsim/se/sics/mspsim/chip/DS2411.java =================================================================== --- mspsim/se/sics/mspsim/chip/DS2411.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/DS2411.java 2010-07-09 22:43:54 UTC (rev 725) @@ -49,7 +49,7 @@ public class DS2411 extends Chip { - private static final boolean DEBUG = false; + private static final boolean DEBUG_DS2411 = false; private enum STATE { IDLE, WAIT_FOR_RESET, RESETTING, SIGNAL_READY, READY, WAIT_SENDING, SENDING @@ -78,23 +78,23 @@ case WAIT_FOR_RESET: if (!lastPin) { state = STATE.RESETTING; - log("Reseting..."); + if (DEBUG) log("Reseting..."); } break; case SIGNAL_READY: /* ready! release bus */ sdataPort.setPinState(sdataPin, IOPort.PIN_HI); state = STATE.READY; - log("Ready!"); + if (DEBUG) log("Ready!"); readByte = 0; pos = 0; break; case READY: - log("Reading: " + (lastPin ? 1 : 0)); + if (DEBUG) log("Reading: " + (lastPin ? 1 : 0)); readByte = readByte + (lastPin ? (1 << pos) : 0); pos++; if (pos == 8) { - log("Command: " + Utils.hex8(readByte)); + if (DEBUG) log("Command: " + Utils.hex8(readByte)); handleCommand(readByte); state = STATE.WAIT_SENDING; pos = 0; @@ -108,7 +108,7 @@ public DS2411(MSP430Core cpu) { super("DS2411", "Silicon Serial Number", cpu); - if (DEBUG) { + if (DEBUG_DS2411) { setLogStream(System.out); } } @@ -162,7 +162,7 @@ * cause a reset in any state... */ public void dataPin(boolean high) { - log(" Data pin high: " + high + " " + cpu.cycles); + if (DEBUG) log("Data pin high: " + high + " " + cpu.cycles); if (lastPin == high) return; lastPin = high; switch(state) { @@ -172,14 +172,14 @@ state = STATE.WAIT_FOR_RESET; /* reset if low for at least 480uS - we check after 400uS and resets * then */ - log("Wait for reset..."); + if (DEBUG) log("Wait for reset..."); cpu.scheduleTimeEventMillis(stateEvent, 0.400); } break; case RESETTING: if (high) { state = STATE.SIGNAL_READY; - log("Signal ready"); + if (DEBUG) log("Signal ready"); /* reset done - signal with LOW for a while! */ sdataPort.setPinState(sdataPin, IOPort.PIN_LOW); cpu.scheduleTimeEventMillis(stateEvent, 0.480); @@ -200,17 +200,17 @@ break; case SENDING: if (high) { - if (pos == 0) log("should write next byte: " + writeByte); + if (pos == 0 && DEBUG) log("should write next byte: " + writeByte); /* went high => we should send another bit */ sdataPort.setPinState(sdataPin, ((writeByte & (1 << pos)) > 0) ? IOPort.PIN_HI : IOPort.PIN_LOW); - log(" wrote bit: " + (((writeByte & (1 << pos)) > 0) ? 1 : 0)); + if (DEBUG) log("wrote bit: " + (((writeByte & (1 << pos)) > 0) ? 1 : 0)); pos++; if (pos == 8) { writePos++; if (writePos == writeLen) { - log("write is over => IDLE!!!!"); + if (DEBUG) log("write is over => IDLE!!!!"); state = STATE.IDLE; } else { pos = 0; Modified: mspsim/se/sics/mspsim/chip/FileAT45DB.java =================================================================== --- mspsim/se/sics/mspsim/chip/FileAT45DB.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/FileAT45DB.java 2010-07-09 22:43:54 UTC (rev 725) @@ -50,8 +50,6 @@ public class FileAT45DB extends AT45DB { - private static final boolean DEBUG = true; - // PAGE_SIZE and NUM_PAGES defined in AT45DB private static final int FLASH_SIZE = PAGE_SIZE * NUM_PAGES; @@ -100,7 +98,7 @@ fileLock = fileChannel.tryLock(); if (fileLock != null) { // The file is now locked for use - if (DEBUG) System.out.println("FileAT45DB: using flash file '" + filename + '\''); + if (DEBUG) log("using flash file '" + filename + '\''); return true; } else { fileChannel.close(); Modified: mspsim/se/sics/mspsim/chip/FileM25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/FileM25P80.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/FileM25P80.java 2010-07-09 22:43:54 UTC (rev 725) @@ -52,8 +52,6 @@ public class FileM25P80 extends M25P80 { - private static final boolean DEBUG = true; - private String filename; private RandomAccessFile file; private FileChannel fileChannel; @@ -98,7 +96,7 @@ if (fileLock == null) { // Failed to open flash file if (write) { - System.err.println(getName() + ": failed to open flash file '" + filename + '\''); + logw("failed to open flash file '" + filename + '\''); } return false; } @@ -123,12 +121,11 @@ fileLock = fileChannel.tryLock(); if (fileLock != null) { // The file is now locked for use - if (DEBUG) System.out.println("FileM25P80: using flash file '" + filename + '\''); + if (DEBUG) log("using flash file '" + filename + '\''); return true; - } else { - fileChannel.close(); - return false; } + fileChannel.close(); + return false; } catch (IOException e) { e.printStackTrace(); closeFile(); Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2010-07-09 22:43:54 UTC (rev 725) @@ -45,8 +45,6 @@ public abstract class M25P80 extends Chip implements USARTListener, PortListener, Memory { - public static final boolean DEBUG = false; - public static final int WRITE_STATUS = 0x01; public static final int PAGE_PROGRAM = 0x02; public static final int READ_DATA = 0x03; @@ -102,7 +100,7 @@ public void dataReceived(USART source, int data) { if (chipSelect) { if (DEBUG) { - System.out.println("M25P80: byte received: " + data); + log("byte received: " + data); } switch(state) { case READ_STATUS: @@ -125,7 +123,7 @@ source.byteReceived(0); pos++; if (DEBUG && pos == 3) { - System.out.println("M25P80: reading from " + Integer.toHexString(readAddress)); + log("reading from " + Integer.toHexString(readAddress)); } } else { source.byteReceived(readMemory(readAddress++)); @@ -157,7 +155,7 @@ } blockWriteAddress = readAddress & 0xfff00; if (DEBUG) { - System.out.println("M25P80: programming at " + Integer.toHexString(readAddress)); + log("programming at " + Integer.toHexString(readAddress)); } } } else { @@ -168,24 +166,24 @@ return; } if (DEBUG) { - System.out.println("M25P80: new command: " + data); + log("new command: " + data); } switch (data) { case WRITE_ENABLE: if (DEBUG) { - System.out.println("M25P80: Write Enable"); + log("Write Enable"); } writeEnable = true; break; case WRITE_DISABLE: if (DEBUG) { - System.out.println("M25P80: Write Disable"); + log("Write Disable"); } writeEnable = false; break; case READ_IDENT: if (DEBUG) { - System.out.println("M25P80: Read ident."); + log("Read ident."); } state = READ_IDENT; pos = 0; @@ -197,38 +195,38 @@ state = READ_STATUS; source.byteReceived(0); if (DEBUG) { - System.out.println("M25P80: Read status => " + status + " " + cpu.getPC()); + log("Read status => " + status + " " + cpu.getPC()); } return; case WRITE_STATUS: if (DEBUG) { - System.out.println("M25P80: Write status"); + log("Write status"); } state = WRITE_STATUS; break; case READ_DATA: if (DEBUG) { - System.out.println("M25P80: Read Data"); + log("Read Data"); } state = READ_DATA; pos = readAddress = 0; break; case PAGE_PROGRAM: if (DEBUG) { - System.out.println("M25P80: Page Program"); + log("Page Program"); } state = PAGE_PROGRAM; pos = readAddress = 0; break; case SECTOR_ERASE: if (DEBUG) { - System.out.println("M25P80: Sector Erase"); + log("Sector Erase"); } state = SECTOR_ERASE; pos = 0; break; case BULK_ERASE: - System.out.println("M25P80: Bulk Erase"); + log("Bulk Erase"); break; } source.byteReceived(0); @@ -270,7 +268,7 @@ // Should return correct data! private int readMemory(int address) { if (DEBUG) { - System.out.println("M25P80: Reading memory address: " + Integer.toHexString(address)); + log("Reading memory address: " + Integer.toHexString(address)); } ensureLoaded(address); return readMemory[address & 0xff]; @@ -285,7 +283,7 @@ || ((loadedAddress & 0xfff00) != (address & 0xfff00))) { try { if (DEBUG) { - System.out.println("M25P80: Loading memory: " + (address & 0xfff00)); + log("Loading memory: " + (address & 0xfff00)); } loadMemory(address, readMemory); } catch (IOException e) { @@ -318,7 +316,7 @@ } } chipSelect = (data & CHIP_SELECT) == 0; -// System.out.println("M25P80: write to Port4: " + +// if (DEBUG) log("write to Port4: " + // Integer.toString(data, 16) // + " CS:" + chipSelect); state = 0; @@ -330,7 +328,7 @@ } private void programPage() { - if (writing) System.out.println("Can not set program page while already writing... " + cpu.getPC()); + if (writing) logw("Can not set program page while already writing... " + cpu.getPC()); writeStatus(PROGRAM_PAGE_MILLIS); ensureLoaded(blockWriteAddress); for (int i = 0; i < readMemory.length; i++) { @@ -350,7 +348,7 @@ blockWriteAddress = sectorAddress; for (int i = 0; i < 0x100; i++) { if (DEBUG) { - System.out.println("M25P80: erasing at " + Integer.toHexString(blockWriteAddress)); + log("erasing at " + Integer.toHexString(blockWriteAddress)); } writeBack(blockWriteAddress, buffer); blockWriteAddress += 0x100; @@ -362,7 +360,7 @@ try { byte[] tmp = new byte[data.length]; if (DEBUG) { - System.out.println("M25P80: Writing data to disk at " + Integer.toHexString(address)); + log("Writing data to disk at " + Integer.toHexString(address)); } seek(address & 0xfff00); for (int i = 0; i < data.length; i++) { Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2010-07-09 22:40:22 UTC (rev 724) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2010-07-09 22:43:54 UTC (rev 725) @@ -58,8 +58,6 @@ private final int CMD_MEASURE_TEMP = 0x03; private final int CMD_MEASURE_HUM = 0x05; - - private final boolean DEBUG = false; private final static char[] INIT_COMMAND = "CdcCDc".toCharArray(); private int initPos = 0; @@ -128,8 +126,8 @@ crc = crc8Add(crc, readData); crc = crc8Add(crc, output[0]); crc = crc8Add(crc, output[1]); - if (DEBUG) System.out.println("CRC: " + - Utils.hex8(crc) + " rcrc: " + Utils.hex8(rev8bits(crc))); + if (DEBUG) log("CRC: " + Utils.hex8(crc) + + " rcrc: " + Utils.hex8(rev8bits(crc))); output[2] = rev8bits(crc); /* finished measuring - signal with LOW! */ @@ -175,7 +173,7 @@ if (clockHi == high) return; char c = high ? 'C' : 'c'; - if (DEBUG) System.out.println(getName() + ": clock pin " + c); + if (DEBUG) log("clock pin " + c); switch (state) { case IDLE: if (checkInit(c)) { @@ -187,7 +185,7 @@ readData = (readData << 1) | (dataHi ? 1 : 0); bitCnt++; if (bitCnt == 8) { - if (DEBUG) System.out.println("SHT11: read: " + Utils.hex8(readData)); + if (DEBUG) log("read: " + Utils.hex8(readData)); bitCnt = 0; state = ACK_CMD; sdataPort.setPinState(sdataPin, IOPort.PIN_LOW); @@ -215,14 +213,14 @@ if (bitCnt == 8) { // All bits are written! state = ACK_WRITE; - if (DEBUG) System.out.println("Wrote byte: " + output[writePos]); + if (DEBUG) log("Wrote byte: " + output[writePos]); writePos++; } } break; case ACK_WRITE: if (c == 'C' && dataHi) { - if (DEBUG) System.out.println("*** NO ACK???"); + if (DEBUG) log("*** NO ACK???"); reset(0); } break; @@ -233,7 +231,7 @@ public void dataPin(boolean high) { if (dataHi == high) return; char c = high ? 'D' : 'd'; - if (DEBUG) System.out.println(getName() + ": data pin " + c); + if (DEBUG) log("data pin " + c); switch (state) { case IDLE: if (checkInit(c)) { @@ -242,7 +240,7 @@ break; case ACK_WRITE: if (c == 'D') { // if D goes back high - then we are done here!!! - if (DEBUG) System.out.println("ACK for byte complete..."); + if (DEBUG) log("ACK for byte complete..."); if (writePos < writeLen) { state = WRITE_BYTE; writeData = output[writePos]; @@ -262,7 +260,7 @@ if (initPos == INIT_COMMAND.length) { initPos = 0; if (DEBUG) { - System.out.println("SHT11: COMMAND signature detected!!!"); + log("COMMAND signature detected!!!"); } return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 22:40:28
|
Revision: 724 http://mspsim.svn.sourceforge.net/mspsim/?rev=724&view=rev Author: nifi Date: 2010-07-09 22:40:22 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added radio state as chip info Modified Paths: -------------- mspsim/se/sics/mspsim/chip/TR1001.java Modified: mspsim/se/sics/mspsim/chip/TR1001.java =================================================================== --- mspsim/se/sics/mspsim/chip/TR1001.java 2010-07-09 22:21:07 UTC (rev 723) +++ mspsim/se/sics/mspsim/chip/TR1001.java 2010-07-09 22:40:22 UTC (rev 724) @@ -91,6 +91,10 @@ return MODE_MAX; } + public String info() { + return "Radio State: " + getModeName(getMode()); + } + public void setRFListener(RFListener rfListener) { this.rfListener = rfListener; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 22:21:15
|
Revision: 723 http://mspsim.svn.sourceforge.net/mspsim/?rev=723&view=rev Author: nifi Date: 2010-07-09 22:21:07 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added logw() for logging warnings Modified Paths: -------------- mspsim/se/sics/mspsim/core/Chip.java Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2010-07-09 22:13:20 UTC (rev 722) +++ mspsim/se/sics/mspsim/core/Chip.java 2010-07-09 22:21:07 UTC (rev 723) @@ -176,12 +176,21 @@ DEBUG = true; } - public void log(String msg) { + protected void log(String msg) { if (log != null) { log.println(getID() + ": " + msg); } } + protected void logw(String msg) { + String logMessage = getID() + ": " + msg; + PrintStream log = this.log; + if (log != null) { + log.println(logMessage); + } + System.err.println(logMessage); + } + public void setEmulationLogger(EmulationLogger logger) { this.logger = logger; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 22:13:26
|
Revision: 722 http://mspsim.svn.sourceforge.net/mspsim/?rev=722&view=rev Author: nifi Date: 2010-07-09 22:13:20 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Changed to use id instead of name when logging Modified Paths: -------------- mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/IOUnit.java Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2010-07-09 22:09:16 UTC (rev 721) +++ mspsim/se/sics/mspsim/core/Chip.java 2010-07-09 22:13:20 UTC (rev 722) @@ -178,7 +178,7 @@ public void log(String msg) { if (log != null) { - log.println(getName() + ": " + msg); + log.println(getID() + ": " + msg); } } Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2010-07-09 22:09:16 UTC (rev 721) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2010-07-09 22:13:20 UTC (rev 722) @@ -114,12 +114,12 @@ protected void log(String msg) { PrintStream log = this.log; if (log != null) { - log.println(getName() + ": " + msg); + log.println(getID() + ": " + msg); } } protected void logw(String msg) { - String logMessage = getName() + ": " + msg; + String logMessage = getID() + ": " + msg; PrintStream log = this.log; if (log != null) { log.println(logMessage); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 22:09:23
|
Revision: 721 http://mspsim.svn.sourceforge.net/mspsim/?rev=721&view=rev Author: nifi Date: 2010-07-09 22:09:16 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added access methods for IN, OUT, DIR, SEL Modified Paths: -------------- mspsim/se/sics/mspsim/core/IOPort.java Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2010-07-09 21:59:22 UTC (rev 720) +++ mspsim/se/sics/mspsim/core/IOPort.java 2010-07-09 22:09:16 UTC (rev 721) @@ -89,6 +89,22 @@ this.cpu = cpu; } + public int getIn() { + return memory[offset + IN]; + } + + public int getOut() { + return out; + } + + public int getDirection() { + return dirReg; + } + + public int getSelect() { + return memory[offset + (interrupt > 0 ? ISEL : SEL)]; + } + public void setPortListener(PortListener listener) { this.listener = listener; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 21:59:28
|
Revision: 720 http://mspsim.svn.sourceforge.net/mspsim/?rev=720&view=rev Author: nifi Date: 2010-07-09 21:59:22 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Bug fix: synchronized on wrong object Modified Paths: -------------- mspsim/se/sics/mspsim/util/ComponentRegistry.java Modified: mspsim/se/sics/mspsim/util/ComponentRegistry.java =================================================================== --- mspsim/se/sics/mspsim/util/ComponentRegistry.java 2010-07-09 21:37:03 UTC (rev 719) +++ mspsim/se/sics/mspsim/util/ComponentRegistry.java 2010-07-09 21:59:22 UTC (rev 720) @@ -8,7 +8,7 @@ private boolean running = false; public void registerComponent(String name, Object component) { - synchronized (components) { + synchronized (this) { components.add(new ComponentEntry(name, component)); } if (component instanceof ActiveComponent) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 21:37:09
|
Revision: 719 http://mspsim.svn.sourceforge.net/mspsim/?rev=719&view=rev Author: nifi Date: 2010-07-09 21:37:03 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Divided MoteIVNode into more generic CC2420Node and MoteIVNode that adds leds and sensors Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/platform/sky/TelosNode.java Added Paths: ----------- mspsim/se/sics/mspsim/platform/sky/CC2420Node.java Added: mspsim/se/sics/mspsim/platform/sky/CC2420Node.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/CC2420Node.java (rev 0) +++ mspsim/se/sics/mspsim/platform/sky/CC2420Node.java 2010-07-09 21:37:03 UTC (rev 719) @@ -0,0 +1,206 @@ +package se.sics.mspsim.platform.sky; +import se.sics.mspsim.chip.CC2420; +import se.sics.mspsim.chip.DS2411; +import se.sics.mspsim.chip.PacketListener; +import se.sics.mspsim.core.IOPort; +import se.sics.mspsim.core.IOUnit; +import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.core.PortListener; +import se.sics.mspsim.core.USART; +import se.sics.mspsim.core.USARTListener; +import se.sics.mspsim.extutil.jfreechart.DataChart; +import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; +import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.ui.SerialMon; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.NetworkConnection; +import se.sics.mspsim.util.OperatingModeStatistics; + +public abstract class CC2420Node extends GenericNode implements PortListener, USARTListener { + + // Port 2. + public static final int DS2411_DATA_PIN = 4; + public static final int DS2411_DATA = 1 << DS2411_DATA_PIN; + + /* P1.0 - Input: FIFOP from CC2420 */ + /* P1.3 - Input: FIFO from CC2420 */ + /* P1.4 - Input: CCA from CC2420 */ + public static final int CC2420_FIFOP = 0; + public static final int CC2420_FIFO = 3; + public static final int CC2420_CCA = 4; + + /* P4.1 - Input: SFD from CC2420 */ + /* P4.5 - Output: VREG_EN to CC2420 */ + /* P4.2 - Output: SPI Chip Select (CS_N) */ + public static final int CC2420_SFD = 1; + public static final int CC2420_VREG = (1 << 5); + public static final int CC2420_CHIP_SELECT = 0x04; + + protected IOPort port1; + protected IOPort port2; + protected IOPort port4; + protected IOPort port5; + + public CC2420 radio; + public DS2411 ds2411; + + protected String flashFile; + + public CC2420Node(String id) { + super(id); + } + + public void setDebug(boolean debug) { + cpu.setDebug(debug); + } + + public boolean getDebug() { + return cpu.getDebug(); + } + + public ELF getElfInfo() { + return elf; + } + + public void setNodeID(int id) { + ds2411.setMACID(id & 0xff, id & 0xff, id & 0xff, (id >> 8) & 0xff, id & 0xff, id & 0xff); + } + + public void setupNodePorts() { + ds2411 = new DS2411(cpu); + + IOUnit unit = cpu.getIOUnit("P1"); + if (unit instanceof IOPort) { + port1 = (IOPort) unit; + port1.setPortListener(this); + } + + unit = cpu.getIOUnit("P2"); + if (unit instanceof IOPort) { + port2 = (IOPort) unit; + ds2411.setDataPort(port2, DS2411_DATA_PIN); + port2.setPortListener(this); + } + + unit = cpu.getIOUnit("P4"); + if (unit instanceof IOPort) { + port4 = (IOPort) unit; + port4.setPortListener(this); + } + + unit = cpu.getIOUnit("P5"); + if (unit instanceof IOPort) { + port5 = (IOPort) unit; + port5.setPortListener(this); + } + + IOUnit usart0 = cpu.getIOUnit("USART0"); + if (usart0 instanceof USART) { + radio = new CC2420(cpu); + radio.setCCAPort(port1, CC2420_CCA); + radio.setFIFOPPort(port1, CC2420_FIFOP); + radio.setFIFOPort(port1, CC2420_FIFO); + + ((USART) usart0).setUSARTListener(this); + if (port4 != null) { + radio.setSFDPort(port4, CC2420_SFD); + } + } + } + + public void setupNode() { + // create a filename for the flash file + // This should be possible to take from a config file later! + String fileName = config.getProperty("flashfile"); + if (fileName == null) { + fileName = firmwareFile; + if (fileName != null) { + int ix = fileName.lastIndexOf('.'); + if (ix > 0) { + fileName = fileName.substring(0, ix); + } + fileName = fileName + ".flash"; + } + } + if (DEBUG) System.out.println("Using flash file: " + (fileName == null ? "no file" : fileName)); + + this.flashFile = fileName; + + setupNodePorts(); + + if (stats != null) { + stats.addMonitor(this); + stats.addMonitor(radio); + stats.addMonitor(cpu); + } + if (!config.getPropertyAsBoolean("nogui", true)) { + setupGUI(); + + // Add some windows for listening to serial output + IOUnit usart = cpu.getIOUnit("USART1"); + if (usart instanceof USART) { + SerialMon serial = new SerialMon((USART)usart, "USART1 Port Output"); + ((USART) usart).setUSARTListener(serial); + } + if (stats != null) { + // A HACK for some "graphs"!!! + DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle"); + registry.registerComponent("dutychart", dataChart); + DataSourceSampler dss = dataChart.setupChipFrame(cpu); + dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getID(), 0, OperatingModeStatistics.OP_INVERT)); + dataChart.addDataSource(dss, "Listen", stats.getDataSource(radio.getID(), CC2420.MODE_RX_ON)); + dataChart.addDataSource(dss, "Transmit", stats.getDataSource(radio.getID(), CC2420.MODE_TXRX_ON)); + dataChart.addDataSource(dss, "CPU", stats.getDataSource(cpu.getID(), MSP430.MODE_ACTIVE)); + } + } + + if (config.getPropertyAsBoolean("enableNetwork", false)) { + final NetworkConnection network = new NetworkConnection(); + final RadioWrapper radioWrapper = new RadioWrapper(radio); + radioWrapper.setPacketListener(new PacketListener() { + public void transmissionStarted() { + } + public void transmissionEnded(byte[] receivedData) { +// System.out.println("**** Sending data len = " + receivedData.length); +// for (int i = 0; i < receivedData.length; i++) { +// System.out.println("Byte: " + Utils.hex8(receivedData[i])); +// } + network.dataSent(receivedData); + } + }); + + network.addPacketListener(new PacketListener() { + public void transmissionStarted() { + } + public void transmissionEnded(byte[] receivedData) { +// System.out.println("**** Receiving data = " + receivedData.length); + radioWrapper.packetReceived(receivedData); + } + }); + } + } + + public void setupGUI() { + } + + public void portWrite(IOPort source, int data) { + if (source == port4) { + // Chip select = active low... + radio.setChipSelect((data & CC2420_CHIP_SELECT) == 0); + radio.setVRegOn((data & CC2420_VREG) != 0); + //radio.portWrite(source, data); + flashWrite(source, data); + } else if (source == port2) { + ds2411.dataPin((data & DS2411_DATA) != 0); + } + } + + protected abstract void flashWrite(IOPort source, int data); + + public abstract void dataReceived(USART source, int data); + + public void stateChanged(int state) { + // Ignore UART state changes by default + } + +} Property changes on: mspsim/se/sics/mspsim/platform/sky/CC2420Node.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-07-09 21:33:24 UTC (rev 718) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-07-09 21:37:03 UTC (rev 719) @@ -1,23 +1,8 @@ package se.sics.mspsim.platform.sky; - -import se.sics.mspsim.chip.CC2420; -import se.sics.mspsim.chip.DS2411; -import se.sics.mspsim.chip.PacketListener; import se.sics.mspsim.chip.SHT11; import se.sics.mspsim.core.IOPort; -import se.sics.mspsim.core.IOUnit; -import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.core.PortListener; -import se.sics.mspsim.core.USART; -import se.sics.mspsim.core.USARTListener; -import se.sics.mspsim.extutil.jfreechart.DataChart; -import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; -import se.sics.mspsim.platform.GenericNode; -import se.sics.mspsim.util.ELF; -import se.sics.mspsim.util.NetworkConnection; -import se.sics.mspsim.util.OperatingModeStatistics; -public abstract class MoteIVNode extends GenericNode implements PortListener, USARTListener { +public abstract class MoteIVNode extends CC2420Node { public static final int MODE_LEDS_OFF = 0; public static final int MODE_LEDS_1 = 1; @@ -25,31 +10,14 @@ public static final int MODE_LEDS_3 = 3; public static final int MODE_MAX = MODE_LEDS_3; // Port 2. - public static final int DS2411_DATA_PIN = 4; - public static final int DS2411_DATA = 1 << DS2411_DATA_PIN; public static final int BUTTON_PIN = 7; - /* P1.0 - Input: FIFOP from CC2420 */ - /* P1.3 - Input: FIFO from CC2420 */ - /* P1.4 - Input: CCA from CC2420 */ - public static final int CC2420_FIFOP = 0; - public static final int CC2420_FIFO = 3; - public static final int CC2420_CCA = 4; - public static final int SHT11_CLK_PIN = 6; public static final int SHT11_DATA_PIN = 5; public static final int SHT11_CLK = 1 << SHT11_CLK_PIN; public static final int SHT11_DATA = 1 << SHT11_DATA_PIN; - - /* P4.1 - Input: SFD from CC2420 */ - /* P4.5 - Output: VREG_EN to CC2420 */ - /* P4.2 - Output: SPI Chip Select (CS_N) */ - public static final int CC2420_SFD = 1; - public static final int CC2420_VREG = (1 << 5); - public static final int CC2420_CHIP_SELECT = 0x04; - public static final int BLUE_LED = 0x40; public static final int GREEN_LED = 0x20; public static final int RED_LED = 0x10; @@ -58,158 +26,38 @@ public boolean blueLed; public boolean greenLed; - protected IOPort port1; - protected IOPort port2; - protected IOPort port4; - protected IOPort port5; - - public CC2420 radio; public SHT11 sht11; - public DS2411 ds2411; public SkyGui gui; - public NetworkConnection network; - protected String flashFile; - public MoteIVNode(String id) { super(id); setMode(MODE_LEDS_OFF); } - public void setDebug(boolean debug) { - cpu.setDebug(debug); - } - public void setButton(boolean hi) { port2.setPinState(BUTTON_PIN, hi ? IOPort.PIN_HI : IOPort.PIN_LOW); } - public boolean getDebug() { - return cpu.getDebug(); - } - - public ELF getElfInfo() { - return elf; - } - - public void setNodeID(int id) { - ds2411.setMACID(id & 0xff, id & 0xff, id & 0xff, (id >> 8) & 0xff, id & 0xff, id & 0xff); - } - public void setupNodePorts() { - sht11 = new SHT11(cpu); - ds2411 = new DS2411(cpu); + super.setupNodePorts(); - IOUnit unit = cpu.getIOUnit("Port 5"); - if (unit instanceof IOPort) { - port5 = (IOPort) unit; - port5.setPortListener(this); - } - - unit = cpu.getIOUnit("Port 1"); - if (unit instanceof IOPort) { - port1 = (IOPort) unit; - port1.setPortListener(this); + sht11 = new SHT11(cpu); + if (port1 != null) { sht11.setDataPort(port1, SHT11_DATA_PIN); } - - unit = cpu.getIOUnit("Port 2"); - if (unit instanceof IOPort) { - port2 = (IOPort) unit; - ds2411.setDataPort(port2, DS2411_DATA_PIN); - port2.setPortListener(this); - } - - IOUnit usart0 = cpu.getIOUnit("USART 0"); - if (usart0 instanceof USART) { - radio = new CC2420(cpu); - radio.setCCAPort(port1, CC2420_CCA); - radio.setFIFOPPort(port1, CC2420_FIFOP); - radio.setFIFOPort(port1, CC2420_FIFO); - - ((USART) usart0).setUSARTListener(this); - port4 = (IOPort) cpu.getIOUnit("Port 4"); - if (port4 != null) { - port4.setPortListener(this); - radio.setSFDPort(port4, CC2420_SFD); - } - } } - public void setupNode() { - // create a filename for the flash file - // This should be possible to take from a config file later! - String fileName = config.getProperty("flashfile"); - if (fileName == null) { - fileName = firmwareFile; - if (fileName != null) { - int ix = fileName.lastIndexOf('.'); - if (ix > 0) { - fileName = fileName.substring(0, ix); - } - fileName = fileName + ".flash"; - } - } - if (DEBUG) System.out.println("Using flash file: " + (fileName == null ? "no file" : fileName)); - - this.flashFile = fileName; - - setupNodePorts(); - - stats.addMonitor(this); - stats.addMonitor(radio); - stats.addMonitor(cpu); - - if (config.getPropertyAsBoolean("enableNetwork", false)) { - network = new NetworkConnection(); - final RadioWrapper radioWrapper = new RadioWrapper(radio); - radioWrapper.setPacketListener(new PacketListener() { - public void transmissionStarted() { - } - public void transmissionEnded(byte[] receivedData) { - // System.out.println("**** Sending data len = " + receivedData.length); - // for (int i = 0; i < receivedData.length; i++) { - // System.out.println("Byte: " + Utils.hex8(receivedData[i])); - // } - network.dataSent(receivedData); - } - }); - - network.addPacketListener(new PacketListener() { - public void transmissionStarted() { - } - public void transmissionEnded(byte[] receivedData) { - // System.out.println("**** Receiving data = " + receivedData.length); - radioWrapper.packetReceived(receivedData); - } - }); - } - - // UART0 TXreg = 0x77? -// cpu.setBreakPoint(0x77, new CPUMonitor() { -// public void cpuAction(int type, int adr, int data) { -// System.out.println("Write to USART0 TX: " + data + " at " + -// SkyNode.this.elf.getDebugInfo(SkyNode.this.cpu.readRegister(0))); -// } -// }); - - if (!config.getPropertyAsBoolean("nogui", true)) { + public void setupGUI() { + if (gui == null) { gui = new SkyGui(this); registry.registerComponent("nodegui", gui); - - // A HACK for some "graphs"!!! - DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle"); - registry.registerComponent("dutychart", dataChart); - DataSourceSampler dss = dataChart.setupChipFrame(cpu); - dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getID(), 0, OperatingModeStatistics.OP_INVERT)); - dataChart.addDataSource(dss, "Listen", stats.getDataSource("CC2420", CC2420.MODE_RX_ON)); - dataChart.addDataSource(dss, "Transmit", stats.getDataSource("CC2420", CC2420.MODE_TXRX_ON)); - dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430", MSP430.MODE_ACTIVE)); } } public void portWrite(IOPort source, int data) { + super.portWrite(source, data); + if (source == port5) { redLed = (data & RED_LED) == 0; blueLed = (data & BLUE_LED) == 0; @@ -220,17 +68,9 @@ if (gui != null) { gui.repaint(); } - } else if (source == port4) { - // Chip select = active low... - radio.setChipSelect((data & CC2420_CHIP_SELECT) == 0); - radio.setVRegOn((data & CC2420_VREG) != 0); - //radio.portWrite(source, data); - flashWrite(source, data); } else if (source == port1) { sht11.clockPin((data & SHT11_CLK) != 0); sht11.dataPin((data & SHT11_DATA) != 0); - } else if (source == port2) { - ds2411.dataPin((data & DS2411_DATA) != 0); } } @@ -238,6 +78,4 @@ return MODE_MAX; } - protected abstract void flashWrite(IOPort source, int data); - } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2010-07-09 21:33:24 UTC (rev 718) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2010-07-09 21:37:03 UTC (rev 719) @@ -102,9 +102,4 @@ node.setupArgs(config); } - public void stateChanged(int state) { - // TODO Auto-generated method stub - - } - } Modified: mspsim/se/sics/mspsim/platform/sky/TelosNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2010-07-09 21:33:24 UTC (rev 718) +++ mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2010-07-09 21:37:03 UTC (rev 719) @@ -103,9 +103,4 @@ node.setupArgs(config); } - public void stateChanged(int state) { - // TODO Auto-generated method stub - - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 21:33:29
|
Revision: 718 http://mspsim.svn.sourceforge.net/mspsim/?rev=718&view=rev Author: nifi Date: 2010-07-09 21:33:24 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Changed to use case insensitive lookup of Chip and IOUnit Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-07-09 21:22:13 UTC (rev 717) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-07-09 21:33:24 UTC (rev 718) @@ -117,7 +117,7 @@ double currentDCOFactor = 1.0; // Clk A can be "captured" by timers - needs to be handled close to CPU...? - private int clkACaptureMode = CLKCAPTURE_NONE; +// private int clkACaptureMode = CLKCAPTURE_NONE; // Other clocks too... long nextEventCycles; private EventQueue vTimeEventQueue = new EventQueue(); @@ -297,7 +297,7 @@ public Chip getChip(String name) { for(Chip chip : chips) { - if (name.equals(chip.getID()) || name.equals(chip.getName())) { + if (name.equalsIgnoreCase(chip.getID()) || name.equalsIgnoreCase(chip.getName())) { return chip; } } @@ -584,7 +584,7 @@ // Should also return active units... public IOUnit getIOUnit(String name) { for (int i = 0, n = ioUnits.length; i < n; i++) { - if (name.equals(ioUnits[i].getID()) || name.equals(ioUnits[i].getName())) { + if (name.equalsIgnoreCase(ioUnits[i].getID()) || name.equalsIgnoreCase(ioUnits[i].getName())) { return ioUnits[i]; } } @@ -896,10 +896,9 @@ breakPoints[pc].cpuAction(CPUMonitor.EXECUTE, pc, 0); breakpointActive = false; return false; - } else { - // Execute this instruction - this is second call... - breakpointActive = true; } + // Execute this instruction - this is second call... + breakpointActive = true; } if (globalMonitor != null) { globalMonitor.cpuAction(CPUMonitor.EXECUTE, pc, 0); Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2010-07-09 21:22:13 UTC (rev 717) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2010-07-09 21:33:24 UTC (rev 718) @@ -41,7 +41,8 @@ package se.sics.mspsim.util; import java.io.PrintStream; -import java.util.HashMap; +import java.util.ArrayList; + import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430Core; import se.sics.mspsim.core.OperatingModeListener; @@ -56,20 +57,20 @@ public static final int OP_INVERT = 1; private final MSP430Core cpu; - private HashMap<String, StatEntry> statistics = new HashMap<String, StatEntry>(); - private HashMap<String, StatEntry> aliases = new HashMap<String, StatEntry>(); + private ArrayList<StatEntry> statistics = new ArrayList<StatEntry>(); public OperatingModeStatistics(MSP430Core cpu) { this.cpu = cpu; } - private StatEntry getStatEntry(String name) { - StatEntry entry = statistics.get(name); - if (entry == null) { - // If not found by id, try finding the entry by name - entry = aliases.get(name); + private synchronized StatEntry getStatEntry(String name) { + for (StatEntry entry : statistics) { + if (name.equalsIgnoreCase(entry.chip.getID()) || + name.equalsIgnoreCase(entry.chip.getName())) { + return entry; + } } - return entry; + return null; } public Chip getChip(String chipName) { @@ -77,10 +78,10 @@ return entry == null ? null : entry.chip; } - public Chip[] getChips() { + public synchronized Chip[] getChips() { Chip[] chips = new Chip[statistics.size()]; int index = 0; - for (StatEntry entry : statistics.values()) { + for (StatEntry entry : statistics) { chips[index++] = entry.chip; } return chips; @@ -88,12 +89,13 @@ public void addMonitor(Chip chip) { StatEntry entry = new StatEntry(chip); - statistics.put(chip.getID(), entry); - aliases.put(chip.getName(), entry); + synchronized (this) { + statistics.add(entry); + } } - public void printStat() { - for (StatEntry entry : statistics.values()) { + public synchronized void printStat() { + for (StatEntry entry : statistics) { entry.printStat(System.out); } } @@ -233,7 +235,7 @@ } void printStat(PrintStream out) { - out.println("Stat for: " + chip.getName()); + out.println("Stat for: " + chip.getID()); for (int i = 0; i < elapsed.length; i++) { out.println("" + (i + 1) + " = " + elapsed[i]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 21:22:19
|
Revision: 717 http://mspsim.svn.sourceforge.net/mspsim/?rev=717&view=rev Author: nifi Date: 2010-07-09 21:22:13 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Fixed compiler warnings Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELFDebug.java Modified: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java 2010-07-09 21:01:16 UTC (rev 716) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2010-07-09 21:22:13 UTC (rev 717) @@ -93,7 +93,7 @@ } public StabFile[] getStabFiles() { - ArrayList files = new ArrayList(); + ArrayList<StabFile> files = new ArrayList<StabFile>(); StabFile currentFile = null; for (int i = 0, n = stabs.length; i < n; i++) { Stab stab = stabs[i]; @@ -111,7 +111,7 @@ break; } } - return (StabFile[]) files.toArray(new StabFile[0]); + return files.toArray(new StabFile[files.size()]); } @@ -190,7 +190,7 @@ String currentFile = null; String currentFunction = null; int lastAddress = 0; - int currentLine = 0; +// int currentLine = 0; int currentLineAdr = 0; for (Stab stab : stabs) { switch(stab.type) { @@ -220,7 +220,7 @@ case N_SLINE: if (currentPath != null) { /* only files with path... */ if (currentLineAdr < address) { - currentLine = stab.desc; +// currentLine = stab.desc; currentLineAdr = lastAddress + stab.value; allAddresses.add(new Integer(currentLineAdr)); /*if (currentLineAdr >= address) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 21:01:22
|
Revision: 716 http://mspsim.svn.sourceforge.net/mspsim/?rev=716&view=rev Author: nifi Date: 2010-07-09 21:01:16 +0000 (Fri, 09 Jul 2010) Log Message: ----------- * Moved the drawing of the node image to AbstractNodeGUI * Removed the serial monitoring from the node gui Modified Paths: -------------- mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java mspsim/se/sics/mspsim/platform/sky/SkyGui.java Modified: mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java =================================================================== --- mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java 2010-07-09 17:00:19 UTC (rev 715) +++ mspsim/se/sics/mspsim/platform/AbstractNodeGUI.java 2010-07-09 21:01:16 UTC (rev 716) @@ -43,6 +43,7 @@ package se.sics.mspsim.platform; import java.awt.Color; import java.awt.Dimension; +import java.awt.Graphics; import java.io.File; import java.net.URL; @@ -149,4 +150,20 @@ protected abstract void stopGUI(); + protected void paintComponent(Graphics g) { + Color old = g.getColor(); + ImageIcon nodeImage = getNodeImage(); + int w = getWidth(), h = getHeight(); + int iw = nodeImage.getIconWidth(), ih = nodeImage.getIconHeight(); + nodeImage.paintIcon(this, g, 0, 0); + // Clear all areas not covered by the image + g.setColor(getBackground()); + if (w > iw) { + g.fillRect(iw, 0, w, h); + } + if (h > ih) { + g.fillRect(0, ih, w, h); + } + g.setColor(old); + } } Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2010-07-09 17:00:19 UTC (rev 715) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2010-07-09 21:01:16 UTC (rev 716) @@ -51,16 +51,12 @@ import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.TargetDataLine; -import javax.swing.ImageIcon; import se.sics.mspsim.chip.Beeper; import se.sics.mspsim.core.ADC12; import se.sics.mspsim.core.ADCInput; import se.sics.mspsim.core.IOUnit; -import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.core.USART; import se.sics.mspsim.platform.AbstractNodeGUI; -import se.sics.mspsim.ui.SerialMon; public class ESBGui extends AbstractNodeGUI implements ADCInput { @@ -86,7 +82,6 @@ private MouseMotionAdapter mouseMotionListener; private MouseAdapter mouseListener; - private SerialMon serial; Beeper beeper; private ESBNode node; @@ -159,17 +154,7 @@ }; addMouseListener(mouseListener); - // Add some windows for listening to serial output - MSP430 cpu = node.getCPU(); - IOUnit usart = cpu.getIOUnit("USART 1"); - if (usart instanceof USART) { - if (serial == null) { - serial = new SerialMon((USART)usart, "RS232 Port Output"); - } - ((USART) usart).setUSARTListener(serial); - } - - IOUnit adc = cpu.getIOUnit("ADC12"); + IOUnit adc = node.getCPU().getIOUnit("ADC12"); if (adc instanceof ADC12) { ((ADC12) adc).setADCInput(0, this); } @@ -217,21 +202,10 @@ } protected void paintComponent(Graphics g) { - Color old = g.getColor(); - int w = getWidth(), h = getHeight(); - ImageIcon esbImage = getNodeImage(); - int iw = esbImage.getIconWidth(), ih = esbImage.getIconHeight(); - esbImage.paintIcon(this, g, 0, 0); - // Clear all areas not covered by the image - g.setColor(getBackground()); - if (w > iw) { - g.fillRect(iw, 0, w, h); - } - if (h > ih) { - g.fillRect(0, ih, w, h); - } + super.paintComponent(g); // Display all active leds + Color old = g.getColor(); if (node.greenLed) { g.setColor(GREEN_TRANS); g.fillOval(GREEN_X - 1, LED_Y - 3, 5, 9); Modified: mspsim/se/sics/mspsim/platform/sky/SkyGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2010-07-09 17:00:19 UTC (rev 715) +++ mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2010-07-09 21:01:16 UTC (rev 716) @@ -45,13 +45,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.ImageIcon; - -import se.sics.mspsim.core.IOUnit; -import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.core.USART; import se.sics.mspsim.platform.AbstractNodeGUI; -import se.sics.mspsim.ui.SerialMon; public class SkyGui extends AbstractNodeGUI { @@ -70,8 +64,6 @@ public static final Color GREEN_C = new Color(0xff60ff60); public static final Color RED_C = new Color(0xffff8000); - private SerialMon serial; - private MoteIVNode node; public SkyGui(MoteIVNode node) { @@ -116,31 +108,13 @@ }; this.addMouseListener(mouseHandler); - - // Add some windows for listening to serial output - MSP430 cpu = node.getCPU(); - IOUnit usart = cpu.getIOUnit("USART 1"); - if (usart instanceof USART) { - serial = new SerialMon((USART)usart, "USART1 Port Output"); - ((USART) usart).setUSARTListener(serial); - } } protected void paintComponent(Graphics g) { Color old = g.getColor(); - ImageIcon skyImage = getNodeImage(); - int w = getWidth(), h = getHeight(); - int iw = skyImage.getIconWidth(), ih = skyImage.getIconHeight(); - skyImage.paintIcon(this, g, 0, 0); - // Clear all areas not covered by the image - g.setColor(getBackground()); - if (w > iw) { - g.fillRect(iw, 0, w, h); - } - if (h > ih) { - g.fillRect(0, ih, w, h); - } + super.paintComponent(g); + // Display all active leds if (node.redLed) { g.setColor(RED_TRANS); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 17:00:25
|
Revision: 715 http://mspsim.svn.sourceforge.net/mspsim/?rev=715&view=rev Author: nifi Date: 2010-07-09 17:00:19 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added configured CC2420 address information to the chip info Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-07-09 16:54:54 UTC (rev 714) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-07-09 17:00:19 UTC (rev 715) @@ -1293,18 +1293,31 @@ public int getModeMax() { return MODE_MAX; } - + + private String getLongAddress() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 8; i++) { + if ((i % 2 == 0) && i > 0) { + sb.append(':'); + } + sb.append(Utils.hex8(memory[RAM_IEEEADDR + 7 - i])); + } + return sb.toString(); + } + public String info() { updateActiveFrequency(); - return " VREG_ON: " + on + " ChipSel: " + chipSelect + - "\n OSC_Stable: " + ((status & STATUS_XOSC16M_STABLE) > 0) + - "\n RSSI_Valid: " + ((status & STATUS_RSSI_VALID) > 0) + " CCA: " + cca + + return " VREG_ON: " + on + " Chip Select: " + chipSelect + + " OSC Stable: " + ((status & STATUS_XOSC16M_STABLE) > 0) + + "\n RSSI Valid: " + ((status & STATUS_RSSI_VALID) > 0) + " CCA: " + cca + "\n FIFOP Polarity: " + ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) + - " FIFOP: " + fifoP + " FIFO: " + currentFIFO + " SFD: " + currentSFD + - "\n Radio State: " + stateMachine + - "\n RXFIFO: " + rxFIFO.stateToString() + - "\n AutoACK: " + autoAck + " AddrDecode: " + addressDecode + " AutoCRC: " + autoCRC + - "\n SPI State: " + state + + " FIFOP: " + fifoP + " FIFO: " + currentFIFO + " SFD: " + currentSFD + + "\n " + rxFIFO.stateToString() + + "\n Radio State: " + stateMachine + " SPI State: " + state + + "\n AutoACK: " + autoAck + " AddrDecode: " + addressDecode + " AutoCRC: " + autoCRC + + "\n PanID: 0x" + Utils.hex8(memory[RAM_PANID + 1]) + Utils.hex8(memory[RAM_PANID]) + + " ShortAddr: 0x" + Utils.hex8(memory[RAM_SHORTADDR + 1]) + Utils.hex8(memory[RAM_SHORTADDR]) + + " LongAddr: 0x" + getLongAddress() + "\n Channel: " + activeChannel + "\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 16:55:01
|
Revision: 714 http://mspsim.svn.sourceforge.net/mspsim/?rev=714&view=rev Author: nifi Date: 2010-07-09 16:54:54 +0000 (Fri, 09 Jul 2010) Log Message: ----------- * Added getID() to Loggable for short unique identifier * Moved implementation of getID()/getName() from the subclasses to IOUnit and Chip * Added cpu to constructor in Chip for auto-registering chips * Renamed the command 'chipinfo' to 'info' since it now handles all Loggables (both Chip and IOUnits) * Lookup of Chip/IOUnit now possible by id or name Modified Paths: -------------- mspsim/se/sics/mspsim/chip/AT45DB.java mspsim/se/sics/mspsim/chip/Beeper.java mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/chip/DS2411.java mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/chip/SHT11.java mspsim/se/sics/mspsim/chip/TR1001.java mspsim/se/sics/mspsim/core/ADC12.java mspsim/se/sics/mspsim/core/BasicClockModule.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/Flash.java mspsim/se/sics/mspsim/core/IOPort.java mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/Loggable.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Multiplier.java mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/Timer.java mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/core/Watchdog.java mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/platform/sky/TelosNode.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java mspsim/se/sics/mspsim/util/StatCommands.java Modified: mspsim/se/sics/mspsim/chip/AT45DB.java =================================================================== --- mspsim/se/sics/mspsim/chip/AT45DB.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/AT45DB.java 2010-07-09 16:54:54 UTC (rev 714) @@ -132,10 +132,8 @@ setReady(true); }}; - private MSP430Core cpu; - public AT45DB(MSP430Core cpu) { - this.cpu = cpu; + super("AT45DB", "External Flash", cpu); } private void setReady(boolean ready) { @@ -362,10 +360,6 @@ return 0; } - public String getName() { - return "AT45DB: external flash"; - } - public abstract void seek(long pos) throws IOException; public abstract int read(byte[] b) throws IOException; public abstract void write(byte[] b) throws IOException; Modified: mspsim/se/sics/mspsim/chip/Beeper.java =================================================================== --- mspsim/se/sics/mspsim/chip/Beeper.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/Beeper.java 2010-07-09 16:54:54 UTC (rev 714) @@ -64,7 +64,7 @@ int beepCtr = 0; public Beeper() { - super(null, 0); + super("Beeper", null, 0); AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, false); DataLine.Info dli = new DataLine.Info(SourceDataLine.class, af, 16384); @@ -124,10 +124,6 @@ public void write(int address, int data, boolean word, long cycler) { } - public String getName() { - return "Beeper"; - } - // Nothing for interrupts... public void interruptServiced(int vector) { } Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-07-09 16:54:54 UTC (rev 714) @@ -304,8 +304,6 @@ private RFListener listener; private boolean on; - private MSP430Core cpu; - private TimeEvent oscillatorEvent = new TimeEvent(0, "CC2420 OSC") { public void execute(long t) { status |= STATUS_XOSC16M_STABLE; @@ -398,20 +396,18 @@ return stateMachine; } - // TODO: super(cpu) and chip autoregister chips into the CPU. public CC2420(MSP430Core cpu) { + super("CC2420", "Radio", cpu); rxFIFO = new ArrayFIFO("RXFIFO", memory, RAM_RXFIFO, 128); registers[REG_SNOP] = 0; registers[REG_TXCTRL] = 0xa0ff; - this.cpu = cpu; setModeNames(MODE_NAMES); setMode(MODE_POWER_OFF); fifoP = false; rxFIFO.reset(); overflow = false; reset(); - cpu.addChip(this); } private void reset() { @@ -1293,9 +1289,6 @@ /***************************************************************************** * Chip APIs *****************************************************************************/ - public String getName() { - return "CC2420"; - } public int getModeMax() { return MODE_MAX; Modified: mspsim/se/sics/mspsim/chip/DS2411.java =================================================================== --- mspsim/se/sics/mspsim/chip/DS2411.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/DS2411.java 2010-07-09 16:54:54 UTC (rev 714) @@ -56,9 +56,8 @@ } private static final int CMD_READ_ROM = 0x33; - private static final int CMD_SEACH_ROM = 0xf0; + //private static final int CMD_SEARCH_ROM = 0xf0; - MSP430Core cpu; private IOPort sdataPort; private int sdataPin; private STATE state = STATE.IDLE; @@ -108,7 +107,7 @@ }; public DS2411(MSP430Core cpu) { - this.cpu = cpu; + super("DS2411", "Silicon Serial Number", cpu); if (DEBUG) { setLogStream(System.out); } @@ -153,10 +152,6 @@ return 0; } - public String getName() { - return "DS2411"; - } - public void setDataPort(IOPort port, int bit) { sdataPort = port; sdataPin = bit; Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2010-07-09 16:54:54 UTC (rev 714) @@ -92,10 +92,8 @@ writing = false; }}; - private MSP430Core cpu; - public M25P80(MSP430Core cpu) { - this.cpu = cpu; + super("M25P80", "External Flash", cpu); } public void stateChanged(int state) { @@ -380,10 +378,6 @@ return 0; } - public String getName() { - return "M25P80: external flash"; - } - public abstract void seek(long pos) throws IOException; public abstract int readFully(byte[] b) throws IOException; public abstract void write(byte[] b) throws IOException; Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2010-07-09 16:54:54 UTC (rev 714) @@ -84,8 +84,6 @@ private int writeLen = 0; private int writeData = 0; - private MSP430Core cpu; - private static int rev8bits(int v) { int r = 0; int s = 8; @@ -151,10 +149,8 @@ this.humid = humidity; } - // TODO: super(cpu) and chip autoregister chips into the CPU. - public SHT11(MSP430Core core) { - cpu = core; - cpu.addChip(this); + public SHT11(MSP430Core cpu) { + super("SHT11", "Digital Humidity Sensor", cpu); } public void setDataPort(IOPort port, int bit) { @@ -285,7 +281,4 @@ return 0; } - public String getName() { - return "SHT11"; - } } Modified: mspsim/se/sics/mspsim/chip/TR1001.java =================================================================== --- mspsim/se/sics/mspsim/chip/TR1001.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/chip/TR1001.java 2010-07-09 16:54:54 UTC (rev 714) @@ -60,10 +60,10 @@ private RFListener rfListener; public TR1001(MSP430Core cpu, USART usart) { + super("TR1001", "Radio", cpu); this.usart = usart; setModeNames(MODE_NAMES); setMode(MODE_TXRX_OFF); - cpu.addChip(this); usart.setUSARTListener(new USARTListener() { public void dataReceived(USART source, int data) { @@ -82,11 +82,6 @@ }}); } - @Override - public String getName() { - return "TR1001"; - } - public void setMode(int mode) { super.setMode(mode); } Modified: mspsim/se/sics/mspsim/core/ADC12.java =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/ADC12.java 2010-07-09 16:54:54 UTC (rev 714) @@ -143,7 +143,7 @@ public ADC12(MSP430Core cpu) { - super(cpu.memory, 0); + super("ADC12", cpu.memory, 0); core = cpu; } @@ -263,10 +263,6 @@ return 0; } - public String getName() { - return "ADC12"; - } - int smp = 0; private void convert() { // If off then just return... Modified: mspsim/se/sics/mspsim/core/BasicClockModule.java =================================================================== --- mspsim/se/sics/mspsim/core/BasicClockModule.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/BasicClockModule.java 2010-07-09 16:54:54 UTC (rev 714) @@ -86,7 +86,7 @@ * */ public BasicClockModule(MSP430Core core, int[] memory, int offset, Timer[] timers) { - super(memory, offset); + super("BasicClockModule", memory, offset); this.core = core; this.timers = timers; reset(); @@ -167,10 +167,6 @@ } } - public String getName() { - return "BasicClockModule"; - } - public void interruptServiced(int vector) { } } Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/Chip.java 2010-07-09 16:54:54 UTC (rev 714) @@ -52,6 +52,10 @@ */ public abstract class Chip implements Loggable, EventSource { + protected final String id; + protected final String name; + protected final MSP430Core cpu; + private OperatingModeListener[] omListeners; private EventListener eventListener; protected boolean sendEvents = false; @@ -60,7 +64,20 @@ protected EmulationLogger logger; private PrintStream log; protected boolean DEBUG = false; - + + public Chip(String id, MSP430Core cpu) { + this(id, id, cpu); + } + + public Chip(String id, String name, MSP430Core cpu) { + this.id = id; + this.name = name; + this.cpu = cpu; + if (cpu != null) { + cpu.addChip(this); + } + } + public void addOperatingModeListener(OperatingModeListener listener) { omListeners = (OperatingModeListener[]) ArrayUtils.add(OperatingModeListener.class, omListeners, listener); } @@ -125,7 +142,14 @@ return -1; } - public abstract String getName(); + public String getID() { + return id; + } + + public String getName() { + return name; + } + public abstract int getModeMax(); /* By default the cs is set high */ Modified: mspsim/se/sics/mspsim/core/Flash.java =================================================================== --- mspsim/se/sics/mspsim/core/Flash.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/Flash.java 2010-07-09 16:54:54 UTC (rev 714) @@ -174,7 +174,7 @@ public Flash(MSP430Core cpu, int[] memory, FlashRange main_range, FlashRange info_range) { - super(memory, FCTL1); + super("Flash", "Internal Flash", memory, FCTL1); this.cpu = cpu; this.memory = memory; this.main_range = main_range; @@ -189,10 +189,6 @@ return blocked_cpu; } - public String getName() { - return "Flash"; - } - public void interruptServiced(int vector) { cpu.flagInterrupt(vector, this, false); } Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/IOPort.java 2010-07-09 16:54:54 UTC (rev 714) @@ -52,7 +52,6 @@ private static final String[] names = { "IN", "OUT", "DIR", "SEL" }; - private final String name; private final int interrupt; private final MSP430Core cpu; private int interruptFlag; @@ -82,10 +81,9 @@ * Creates a new <code>IOPort</code> instance. * */ - public IOPort(MSP430Core cpu, String portName, + public IOPort(MSP430Core cpu, int port, int interrupt, int[] memory, int offset) { - super(memory, offset); - name = "Port " + portName; + super("P" + port, "Port " + port, memory, offset); this.interrupt = interrupt; this.interruptEnable = 0; this.cpu = cpu; @@ -119,7 +117,7 @@ int iAddress = address - offset; if (iAddress == IN) { - logw("WARNING: writing to read-only PxIN"); + logw("WARNING: writing to read-only " + getID() + "IN"); } else { memory[address] = data & 0xff; if (word) { @@ -127,7 +125,7 @@ } if (DEBUG) { try { - log("Writing to Px" + + log("Writing to " + getID() + (interrupt > 0? iNames[iAddress] : names[iAddress]) + " $" + Utils.hex8(address) + " => $" + Utils.hex8(data) + "=#" + @@ -183,10 +181,6 @@ } } - public String getName() { - return name; - } - public void interruptServiced(int vector) { } Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2010-07-09 16:54:54 UTC (rev 714) @@ -47,13 +47,21 @@ int[] memory; int offset; - + + protected final String id; + protected final String name; + protected EmulationLogger logger; private PrintStream log; protected boolean DEBUG = false; + public IOUnit(String id, int[] memory, int offset) { + this(id, id, memory, offset); + } - public IOUnit(int[] memory, int offset) { + public IOUnit(String id, String name, int[] memory, int offset) { + this.id = id; + this.name = name; this.memory = memory; this.offset = offset; } @@ -79,9 +87,15 @@ // Second byte => hi byte return (data >> 8) & 0xff; } + + public String getID() { + return id; + } + + public String getName() { + return name; + } - public abstract String getName(); - /* Loggable */ public void clearLogStream() { log = null; Modified: mspsim/se/sics/mspsim/core/Loggable.java =================================================================== --- mspsim/se/sics/mspsim/core/Loggable.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/Loggable.java 2010-07-09 16:54:54 UTC (rev 714) @@ -40,6 +40,7 @@ public void setEmulationLogger(EmulationLogger log); public void setLogStream(PrintStream out); public void clearLogStream(); + public String getID(); public String getName(); public String info(); Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/MSP430.java 2010-07-09 16:54:54 UTC (rev 714) @@ -80,7 +80,6 @@ public MSP430(int type, ComponentRegistry registry) { super(type, registry); disAsm = new DisAsm(); - addChip(this); } public double getCPUPercent() { Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-07-09 16:54:54 UTC (rev 714) @@ -134,16 +134,21 @@ private Flash flash; public MSP430Core(int type, ComponentRegistry registry) { + super("MSP430", "MSP430 Core", null); + this.registry = registry; + + // The CPU need to register itself as chip + addChip(this); + // Ignore type for now... setModeNames(MODE_NAMES); - this.registry = registry; int passIO = 0; // IOUnits should likely be placed in a hashtable? // Maybe for debugging purposes... ioUnits = new IOUnit[PORTS + 7]; - Timer ta = new Timer(this, Timer.TIMER_Ax149, memory, 0x160); - Timer tb = new Timer(this, Timer.TIMER_Bx149, memory, 0x180); + Timer ta = new Timer(this, "A", Timer.TIMER_Ax149, memory, 0x160); + Timer tb = new Timer(this, "B", Timer.TIMER_Bx149, memory, 0x180); for (int i = 0, n = 0x20; i < n; i++) { memOut[0x160 + i] = ta; memOut[0x180 + i] = tb; @@ -186,8 +191,8 @@ memIn[i] = mp; } - USART usart0 = new USART(this, memory, 0x70); - USART usart1 = new USART(this, memory, 0x78); + USART usart0 = new USART(this, 0, memory, 0x70); + USART usart1 = new USART(this, 1, memory, 0x78); for (int i = 0, n = 8; i < n; i++) { memOut[0x70 + i] = usart0; @@ -199,8 +204,8 @@ // Add port 1,2 with interrupt capability! - ioUnits[0] = new IOPort(this, "1", 4, memory, 0x20); - ioUnits[1] = new IOPort(this, "2", 1, memory, 0x28); + ioUnits[0] = new IOPort(this, 1, 4, memory, 0x20); + ioUnits[1] = new IOPort(this, 2, 1, memory, 0x28); for (int i = 0, n = 8; i < n; i++) { memOut[0x20 + i] = ioUnits[0]; memOut[0x28 + i] = ioUnits[1]; @@ -208,15 +213,13 @@ // Add port 3,4 & 5,6 for (int i = 0, n = 2; i < n; i++) { - ioUnits[i + 2] = new IOPort(this, "" + (3 + i), 0, - memory, 0x18 + i * 4); + ioUnits[i + 2] = new IOPort(this, (3 + i), 0, memory, 0x18 + i * 4); memOut[0x18 + i * 4] = ioUnits[i + 2]; memOut[0x19 + i * 4] = ioUnits[i + 2]; memOut[0x1a + i * 4] = ioUnits[i + 2]; memOut[0x1b + i * 4] = ioUnits[i + 2]; - ioUnits[i + 4] = new IOPort(this, "" + (5 + i), 0, - memory, 0x30 + i * 4); + ioUnits[i + 4] = new IOPort(this, (5 + i), 0, memory, 0x30 + i * 4); memOut[0x30 + i * 4] = ioUnits[i + 4]; memOut[0x31 + i * 4] = ioUnits[i + 4]; @@ -270,7 +273,11 @@ public void setGlobalMonitor(CPUMonitor mon) { globalMonitor = mon; } - + + public ComponentRegistry getRegistry() { + return registry; + } + /* returns port 1 ... 6 */ public IOPort getIOPort(int portID) { if (portID > 0 && portID < 7) { @@ -290,7 +297,7 @@ public Chip getChip(String name) { for(Chip chip : chips) { - if (name.equals(chip.getName())) { + if (name.equals(chip.getID()) || name.equals(chip.getName())) { return chip; } } @@ -577,7 +584,7 @@ // Should also return active units... public IOUnit getIOUnit(String name) { for (int i = 0, n = ioUnits.length; i < n; i++) { - if (name.equals(ioUnits[i].getName())) { + if (name.equals(ioUnits[i].getID()) || name.equals(ioUnits[i].getName())) { return ioUnits[i]; } } @@ -1427,10 +1434,6 @@ return true; } - public String getName() { - return "MSP430 Core"; - } - public int getModeMax() { return MODE_MAX; } Modified: mspsim/se/sics/mspsim/core/Multiplier.java =================================================================== --- mspsim/se/sics/mspsim/core/Multiplier.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/Multiplier.java 2010-07-09 16:54:54 UTC (rev 714) @@ -76,7 +76,7 @@ * */ public Multiplier(MSP430Core core, int memory[], int offset) { - super(memory, offset); + super("Multiplier", "Hardware Multiplier", memory, offset); this.core = core; } @@ -184,10 +184,6 @@ } } - public String getName() { - return "Hardware Multiplier"; - } - public void interruptServiced(int vector) { } } Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/SFR.java 2010-07-09 16:54:54 UTC (rev 714) @@ -72,7 +72,7 @@ private int[] irqTriggeredPos = new int[16]; public SFR(MSP430Core cpu, int[] memory) { - super(memory, 0); + super("SFR", "Special Function Register", memory, 0); this.cpu = cpu; this.memory = memory; reset(0); @@ -271,8 +271,4 @@ } } - public String getName() { - return "SpecialFunctionRegister, SFR"; - } - } // SFR Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/Timer.java 2010-07-09 16:54:54 UTC (rev 714) @@ -174,7 +174,6 @@ "NONE", "RISING", "FALLING", "BOTH" }; - private final String name; private final int tiv; private int inputDivider = 1; @@ -406,34 +405,29 @@ * */ - public Timer(MSP430Core core, int[] srcMap, int[] memory, int offset) { - super(memory, offset); + public Timer(MSP430Core core, String type, int[] srcMap, int[] memory, int offset) { + super("Timer" + type, "Timer " + type, memory, offset); this.srcMap = srcMap; this.core = core; noCompare = (srcMap.length / 4) - 1; if (DEBUG) { System.out.println("Timer: noComp:" + noCompare); } - String type = ""; if (srcMap == TIMER_Ax149) { - name = "Timer A"; - type = " A"; tiv = TAIV; timerOverflow = 0x0a; ccr0Vector = TACCR0_VECTOR; ccr1Vector = TACCR1_VECTOR; } else { - type = " B"; - name = "Timer B"; tiv = TBIV; timerOverflow = 0x0e; ccr0Vector = TBCCR0_VECTOR; ccr1Vector = TBCCR1_VECTOR; } - counterTrigger.name += type; + counterTrigger.name += ' ' + type; for (int i = 0; i < noCompare; i++) { - ccr[i] = new CCR(0, "CCR" + i + type, i == 0 ? ccr0Vector : ccr1Vector, i); + ccr[i] = new CCR(0, "CCR" + i + " " + type, i == 0 ? ccr0Vector : ccr1Vector, i); } reset(0); @@ -900,10 +894,6 @@ return ""; } - public String getName() { - return name; - } - /** * capture - perform a capture if the timer CCRx is configured for captures * Note: capture may only be called when value has changed Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/USART.java 2010-07-09 16:54:54 UTC (rev 714) @@ -64,7 +64,7 @@ public static final int IE1 = 0; public static final int IFG1 = 2; - private int uartID = 0; + private final int uartID; public static final int USART0_RX_VEC = 9; public static final int USART0_TX_VEC = 8; @@ -124,13 +124,11 @@ * Creates a new <code>USART</code> instance. * */ - public USART(MSP430Core cpu, int[] memory, int offset) { - super(memory, offset); + public USART(MSP430Core cpu, int uartID, int[] memory, int offset) { + super("USART" + uartID, "USART " + uartID, memory, offset); this.cpu = cpu; + this.uartID = uartID; sfr = cpu.getSFR(); - if (offset == 0x78) { - uartID = 1; - } // Initialize - transmit = ok... // and set which interrupts are used @@ -344,11 +342,6 @@ } } - - public String getName() { - return "USART " + uartID; - } - // We should add "Interrupt serviced..." to indicate that its latest // Interrupt was serviced... public void interruptServiced(int vector) { Modified: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2010-07-09 16:54:54 UTC (rev 714) @@ -89,15 +89,11 @@ }; public Watchdog(MSP430Core cpu) { - super(cpu.memory, 0x120); + super("Watchdog", cpu.memory, 0x120); this.cpu = cpu; cpu.getSFR().registerSFDModule(0, WATCHDOG_INTERRUPT_BIT, this, WATCHDOG_VECTOR); } - public String getName() { - return "Watchdog"; - } - public void interruptServiced(int vector) { cpu.flagInterrupt(vector, this, false); } Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2010-07-09 16:54:54 UTC (rev 714) @@ -75,14 +75,21 @@ private static final String PROMPT = "MSPSim>"; + protected final MSP430 cpu; + protected final ComponentRegistry registry; protected ConfigManager config; - protected ComponentRegistry registry = new ComponentRegistry(); - protected MSP430 cpu = new MSP430(0, registry); protected String firmwareFile = null; protected ELF elf; protected OperatingModeStatistics stats; + + public GenericNode(String id) { + super(id, new MSP430(0, new ComponentRegistry())); + this.cpu = (MSP430)super.cpu; + this.registry = cpu.getRegistry(); + } + public ComponentRegistry getRegistry() { return registry; } Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-07-09 16:54:54 UTC (rev 714) @@ -83,6 +83,7 @@ * */ public ESBNode() { + super("ESB"); } public void setPIR(boolean hi) { @@ -166,10 +167,10 @@ DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle"); registry.registerComponent("dutychart", dataChart); DataSourceSampler dss = dataChart.setupChipFrame(cpu); - dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getName(), 0, OperatingModeStatistics.OP_INVERT)); + dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getID(), 0, OperatingModeStatistics.OP_INVERT)); dataChart.addDataSource(dss, "Listen", stats.getDataSource("TR1001", TR1001.MODE_RX_ON)); dataChart.addDataSource(dss, "Transmit", stats.getDataSource("TR1001", TR1001.MODE_TXRX_ON)); - dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE)); + dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430", MSP430.MODE_ACTIVE)); } } @@ -177,10 +178,6 @@ return 0; } - public String getName() { - return "ESB"; - } - public static void main(String[] args) throws IOException { ESBNode node = new ESBNode(); ArgumentManager config = new ArgumentManager(); Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-07-09 16:54:54 UTC (rev 714) @@ -72,6 +72,11 @@ protected String flashFile; + public MoteIVNode(String id) { + super(id); + setMode(MODE_LEDS_OFF); + } + public void setDebug(boolean debug) { cpu.setDebug(debug); } @@ -197,10 +202,10 @@ DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle"); registry.registerComponent("dutychart", dataChart); DataSourceSampler dss = dataChart.setupChipFrame(cpu); - dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getName(), 0, OperatingModeStatistics.OP_INVERT)); + dataChart.addDataSource(dss, "LEDS", stats.getDataSource(getID(), 0, OperatingModeStatistics.OP_INVERT)); dataChart.addDataSource(dss, "Listen", stats.getDataSource("CC2420", CC2420.MODE_RX_ON)); dataChart.addDataSource(dss, "Transmit", stats.getDataSource("CC2420", CC2420.MODE_TXRX_ON)); - dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE)); + dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430", MSP430.MODE_ACTIVE)); } } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2010-07-09 16:54:54 UTC (rev 714) @@ -61,7 +61,7 @@ * */ public SkyNode() { - setMode(MODE_LEDS_OFF); + super("Tmote Sky"); } public M25P80 getFlash() { @@ -88,10 +88,6 @@ flash.portWrite(source, data); } - public String getName() { - return "Tmote Sky"; - } - public void setupNodePorts() { super.setupNodePorts(); if (flashFile != null) { Modified: mspsim/se/sics/mspsim/platform/sky/TelosNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2010-07-09 16:54:54 UTC (rev 714) @@ -66,7 +66,7 @@ * */ public TelosNode() { - setMode(MODE_LEDS_OFF); + super("Telos"); } public AT45DB getFlash() { @@ -89,10 +89,6 @@ flash.dataReceived(source, data); } - public String getName() { - return "Telos"; - } - public void setupNodePorts() { super.setupNodePorts(); if (flashFile != null) { Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2010-07-09 16:54:54 UTC (rev 714) @@ -55,15 +55,25 @@ public static final int OP_NORMAL = 0; public static final int OP_INVERT = 1; - private MSP430Core cpu; + private final MSP430Core cpu; private HashMap<String, StatEntry> statistics = new HashMap<String, StatEntry>(); + private HashMap<String, StatEntry> aliases = new HashMap<String, StatEntry>(); public OperatingModeStatistics(MSP430Core cpu) { this.cpu = cpu; } + private StatEntry getStatEntry(String name) { + StatEntry entry = statistics.get(name); + if (entry == null) { + // If not found by id, try finding the entry by name + entry = aliases.get(name); + } + return entry; + } + public Chip getChip(String chipName) { - StatEntry entry = statistics.get(chipName); + StatEntry entry = getStatEntry(chipName); return entry == null ? null : entry.chip; } @@ -78,7 +88,8 @@ public void addMonitor(Chip chip) { StatEntry entry = new StatEntry(chip); - statistics.put(chip.getName(), entry); + statistics.put(chip.getID(), entry); + aliases.put(chip.getName(), entry); } public void printStat() { @@ -92,7 +103,7 @@ } public DataSource getDataSource(String chip, String modeStr) { - StatEntry se = statistics.get(chip); + StatEntry se = getStatEntry(chip); if (se != null) { int mode = se.chip.getModeByName(modeStr); if (mode != -1) { @@ -104,7 +115,7 @@ public DataSource getDataSource(String chip, int mode, int operation) { - StatEntry se = statistics.get(chip); + StatEntry se = getStatEntry(chip); if (se != null) { return new StatDataSource(se, mode, operation); } @@ -112,7 +123,7 @@ } public MultiDataSource getMultiDataSource(String chip) { - StatEntry se = statistics.get(chip); + StatEntry se = getStatEntry(chip); if (se != null) { return new StatMultiDataSource(se); } Modified: mspsim/se/sics/mspsim/util/StatCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/StatCommands.java 2010-07-09 13:52:06 UTC (rev 713) +++ mspsim/se/sics/mspsim/util/StatCommands.java 2010-07-09 16:54:54 UTC (rev 714) @@ -47,7 +47,6 @@ import se.sics.mspsim.cli.CommandBundle; import se.sics.mspsim.cli.CommandContext; import se.sics.mspsim.cli.CommandHandler; -import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.Loggable; import se.sics.mspsim.core.MSP430Core; import se.sics.mspsim.core.TimeEvent; @@ -63,32 +62,38 @@ } public void setupCommands(ComponentRegistry registry, CommandHandler handler) { - handler.registerCommand("chipinfo", new BasicCommand("show information about specified chip/loggable", - "[chips...]") { + handler.registerCommand("info", new BasicCommand("show information about specified chip/loggable", + "[unit...]") { @Override public int executeCommand(CommandContext context) { if (context.getArgumentCount() > 0) { for (int i = 0, n = context.getArgumentCount(); i < n; i++) { - String chipName = context.getArgument(i); - Loggable chip = cpu.getLoggable(chipName); - if (chip == null) { - context.out.println(" " + chipName + ": NOT FOUND"); + String unitName = context.getArgument(i); + Loggable unit = cpu.getLoggable(unitName); + if (unit == null) { + context.out.println(" " + unitName + ": NOT FOUND"); } else { - context.out.println(chipName + ": " + chip); - String info = chip.info(); + context.out.println(unitName + ": " + unit); + String info = unit.info(); if (info != null) { context.out.println(info); } } } } else { - Loggable[] chips = cpu.getLoggables(); - if (chips == null) { + Loggable[] units = cpu.getLoggables(); + if (units == null) { context.out.println("No loggables found."); } else { - for (int i = 0, n = chips.length; i < n; i++) { - context.out.println(" " + chips[i].getName()); + for (int i = 0, n = units.length; i < n; i++) { + String id = units[i].getID(); + String name = units[i].getName(); + if (id == name) { + context.out.println(" " + id); + } else { + context.out.println(" " + id + " (" + name + ')'); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-09 13:52:14
|
Revision: 713 http://mspsim.svn.sourceforge.net/mspsim/?rev=713&view=rev Author: nifi Date: 2010-07-09 13:52:06 +0000 (Fri, 09 Jul 2010) Log Message: ----------- * Added warning for writing to read-only PxIN * Updated to use Loggable instead of printing to system out Modified Paths: -------------- mspsim/se/sics/mspsim/core/IOPort.java Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2010-07-05 10:41:36 UTC (rev 712) +++ mspsim/se/sics/mspsim/core/IOPort.java 2010-07-09 13:52:06 UTC (rev 713) @@ -47,18 +47,16 @@ public static final int PIN_LOW = 0; public static final int PIN_HI = 1; - public static final boolean DEBUG = false; + private static final String[] iNames = { + "IN", "OUT", "DIR", "IFG", "IES", "IE", "SEL" }; + private static final String[] names = { + "IN", "OUT", "DIR", "SEL" }; - public static final String[] iNames = { - "P_IN","P_OUT", "P_DIR", "P_IFG", "P_IES", "P_IE", "P_SEL" }; - public static final String[] names = { - "P_IN", "P_OUT", "P_DIR", "P_SEL" }; - - private String name; - private int interrupt; + private final String name; + private final int interrupt; + private final MSP430Core cpu; private int interruptFlag; private int interruptEnable; - private MSP430Core cpu; // External pin state! private int pinState[] = new int[8]; @@ -87,7 +85,7 @@ public IOPort(MSP430Core cpu, String portName, int interrupt, int[] memory, int offset) { super(memory, offset); - name = portName; + name = "Port " + portName; this.interrupt = interrupt; this.interruptEnable = 0; this.cpu = cpu; @@ -98,13 +96,15 @@ } public void setTimerCapture(Timer timer, int pin) { - System.out.println("Setting timer capture for pin: " + pin); + if (DEBUG) { + log("Setting timer capture for pin: " + pin); + } timerCapture[pin] = timer; } public int read(int address, boolean word, long cycles) { if (DEBUG) { - System.out.println("Notify read: " + address); + log("Notify read: " + address); } int val = memory[address]; @@ -115,24 +115,27 @@ } public void write(int address, int data, boolean word, long cycles) { - memory[address] = data & 0xff; - if (word) { - memory[address + 1] = (data >> 8) & 0xff; - } - // This does not handle word writes yet... int iAddress = address - offset; - if (DEBUG) { - try { - System.out.println("Writing to " + getName() + ":" + - (interrupt > 0? iNames[iAddress] : names[iAddress]) + - " " + Utils.hex8(address) + - " => " + Utils.hex8(data) + "=#" + - Utils.binary8(data) + " word: " + word); - } catch (Exception e) { - e.printStackTrace(); + if (iAddress == IN) { + logw("WARNING: writing to read-only PxIN"); + } else { + memory[address] = data & 0xff; + if (word) { + memory[address + 1] = (data >> 8) & 0xff; } + if (DEBUG) { + try { + log("Writing to Px" + + (interrupt > 0? iNames[iAddress] : names[iAddress]) + + " $" + Utils.hex8(address) + + " => $" + Utils.hex8(data) + "=#" + + Utils.binary8(data) + " word: " + word); + } catch (Exception e) { + e.printStackTrace(); + } + } } switch (iAddress) { @@ -162,13 +165,13 @@ if (interrupt > 0) { // IFG - writing a zero => clear the flag! if (DEBUG) { - System.out.println(getName() + " Clearing IFlag: " + data); + log("Clearing IFlag: " + data); } interruptFlag &= data; memory[offset + IFG] = interruptFlag; cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); } else { - // Samel as ISEL!!! + // Same as ISEL!!! } break; case IES: @@ -181,7 +184,7 @@ } public String getName() { - return "Port " + name; + return name; } public void interruptServiced(int vector) { @@ -203,8 +206,7 @@ if (state == PIN_HI) { interruptFlag |= bit; if (DEBUG) { - System.out.println(getName() + - " Flagging interrupt (HI): " + bit); + log("Flagging interrupt (HI): " + bit); } } } else { @@ -212,8 +214,7 @@ if (state == PIN_LOW) { interruptFlag |= bit; if (DEBUG) { - System.out.println(getName() + - " Flagging interrupt (LOW): " + bit); + log("Flagging interrupt (LOW): " + bit); } } } @@ -224,16 +225,15 @@ if (timerCapture[pin] != null) { /* should not be pin and 0 here - * pin might need configration and 0 can maybe also be 1? + * pin might need configuration and 0 can maybe also be 1? */ -// System.out.println(getName() + " Notifying timer of changed pin value"); +// if (DEBUG) log("Notifying timer of changed pin value"); timerCapture[pin].capture(pin, 0, state); } } } - public void reset(int type) { for (int i = 0, n = 8; i < n; i++) { pinState[i] = PIN_LOW; @@ -242,4 +242,16 @@ interruptEnable = 0; cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); } + + public String info() { + StringBuilder sb = new StringBuilder(); + String[] regs = (interrupt > 0) ? iNames : names; + sb.append('$').append(Utils.hex16(offset)).append(':'); + for (int i = 0, n = regs.length; i < n; i++) { + sb.append(' ').append(regs[i]).append(":$") + .append(Utils.hex8(memory[offset + i])); + } + return sb.toString(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |