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...> - 2008-04-16 11:56:22
|
Revision: 236 http://mspsim.svn.sourceforge.net/mspsim/?rev=236&view=rev Author: nifi Date: 2008-04-16 04:56:14 -0700 (Wed, 16 Apr 2008) Log Message: ----------- fixed the echo command to echo all arguments Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 11:53:59 UTC (rev 235) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-16 11:56:14 UTC (rev 236) @@ -159,7 +159,12 @@ handler.registerCommand("echo", new BasicCommand("echoes argument", "") { public int executeCommand(CommandContext context) { - context.out.println(context.getArgument(0)); + StringBuilder sb = new StringBuilder(); + for (int i = 0, n = context.getArgumentCount(); i < n; i++) { + if (i > 0) sb.append(' '); + sb.append(context.getArgument(i)); + } + context.out.println(sb.toString()); return 0; } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-16 11:54:21
|
Revision: 235 http://mspsim.svn.sourceforge.net/mspsim/?rev=235&view=rev Author: nifi Date: 2008-04-16 04:53:59 -0700 (Wed, 16 Apr 2008) Log Message: ----------- renamed parseLine to parseCommandLine() + added parseLine() for simple line parsing + added execution of last command by page up + return when not running from terminal with history support Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/CommandParser.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-15 22:33:10 UTC (rev 234) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-04-16 11:53:59 UTC (rev 235) @@ -68,15 +68,21 @@ } public void run() { + String lastLine = null; while(!exit) { try { out.print(">"); out.flush(); String line = readLine(inReader);//.readLine(); + // Simple execution of last called command line when not running from terminal with history support + if (((char) 27 + "[A").equals(line)) { + line = lastLine; + } if (line != null && line.length() > 0) { + lastLine = line; String[][] parts; try { - parts = CommandParser.parseLine(line); + parts = CommandParser.parseCommandLine(line); } catch (Exception e) { err.println("Error: failed to parse command:"); e.printStackTrace(err); Modified: mspsim/se/sics/mspsim/cli/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandParser.java 2008-04-15 22:33:10 UTC (rev 234) +++ mspsim/se/sics/mspsim/cli/CommandParser.java 2008-04-16 11:53:59 UTC (rev 235) @@ -49,7 +49,19 @@ // Prevent instances of this class } - public static String[][] parseLine(String line) { + public static String[][] parseCommandLine(String line) { + return parseLine(line, true, true); + } + + public static String[] parseLine(String line) { + String[][] lines = parseLine(line, false, false); + if (lines != null && lines.length > 0) { + return lines[0]; + } + return null; + } + + public static String[][] parseLine(String line, boolean handlePipes, boolean handleRedirect) { ArrayList<String[]> list = new ArrayList<String[]>(); ArrayList<String> args = new ArrayList<String>(); StringBuilder sb = null; @@ -119,14 +131,18 @@ } break; case '#': - if (state == TEXT && redirectCommand != null && redirectFile == args.size()) { + if (!handleRedirect) { + // No redirect handling. Process as normal character. + } else if (state == TEXT && redirectCommand != null && redirectFile == args.size()) { redirectCommand += '#'; } else if (state != QUOTE) { throw new IllegalArgumentException("illegal character '#'"); } break; case '>': - if (state != QUOTE) { + if (!handleRedirect) { + // No redirect handling. Process as normal character. + } else if (state != QUOTE) { // Redirection if (state == ARG) { if (sb == null) { @@ -150,7 +166,9 @@ } break; case '|': - if (state != QUOTE) { + if (!handlePipes) { + // No pipe handling. Process as normal character. + } else if (state != QUOTE) { // PIPE if (state == ARG) { if (sb == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-15 22:33:20
|
Revision: 234 http://mspsim.svn.sourceforge.net/mspsim/?rev=234&view=rev Author: joxe Date: 2008-04-15 15:33:10 -0700 (Tue, 15 Apr 2008) Log Message: ----------- added some functionality for the ADC12. Not yet working. Modified Paths: -------------- mspsim/se/sics/mspsim/core/ADC12.java Modified: mspsim/se/sics/mspsim/core/ADC12.java =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java 2008-04-15 20:33:24 UTC (rev 233) +++ mspsim/se/sics/mspsim/core/ADC12.java 2008-04-15 22:33:10 UTC (rev 234) @@ -31,8 +31,13 @@ * * ----------------------------------------------------------------- * - * AD12 + * ADC12 * + * Each time a sample is converted the ADC12 system will check for EOS flag + * and if not set it just continues with the next conversion (x + 1). + * If EOS next conv is startMem. + * + * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 * Updated : $Date$ @@ -43,7 +48,7 @@ public class ADC12 extends IOUnit { - private static final boolean DEBUG = false; + private static final boolean DEBUG = true; //false; public static final int ADC12CTL0 = 0x01A0;// Reset with POR public static final int ADC12CTL1 = 0x01A2;// Reset with POR @@ -88,13 +93,28 @@ 256, 384, 512, 768, 1024, 1024, 1024, 1024 }; + + private int adc12ctl0 = 0; + private int adc12ctl1 = 0; + private int[] adc12mctl = new int[16]; + private int[] adc12mem = new int[16]; private int shTime0 = 4; private int shTime1 = 4; private boolean adc12On = false; private boolean enableConversion; private boolean startConversion; + + private int shSource = 0; + private int startMem = 0; + private int adcDiv = 1; + + private int conSeq; + private int adc12ie; + private int adc12ifg; + + private int adcSSel; public ADC12(MSP430Core cpu) { super(cpu.memory, 0); @@ -112,9 +132,32 @@ enableConversion = (value & 0x02) > 0; startConversion = (value & 0x01) > 0; - if (DEBUG ) System.out.println(getName() + ": Set SHTime0: " + shTime0 + " SHTime1: " + shTime1 + " ENC:" + + if (DEBUG) System.out.println(getName() + ": Set SHTime0: " + shTime0 + " SHTime1: " + shTime1 + " ENC:" + enableConversion + " Start: " + startConversion + " ADC12ON: " + adc12On); break; + case ADC12CTL1: + startMem = (value >> 12) & 0xf; + shSource = (value >> 10) & 0x3; + adcDiv = ((value >> 5) & 0x7) + 1; + conSeq = (value >> 1) & 0x03; + adcSSel = (value >> 3) & 0x03; + if (DEBUG) System.out.println(getName() + ": Set startMem: " + startMem + " SHSource: " + shSource + + " ConSeq-mode:" + conSeq + " Div: " + adcDiv + " ADCSSEL: " + adcSSel); + + break; + case ADC12IE: + adc12ie = value; + break; + case ADC12IFG: + adc12ifg = value; + break; + default: + if (address >= ADC12MCTL0 && address <= ADC12MCTL15) { + adc12mctl[address - ADC12MCTL0] = value & 0xff; + if ((value & 0x80) != 0) { + System.out.println("ADC12MCTL" + (address - ADC12MCTL0) + " EOS bit set"); + } + } } } @@ -123,6 +166,18 @@ switch(address) { case ADC12CTL0: return adc12ctl0; + case ADC12CTL1: + return adc12ctl1; + case ADC12IE: + return adc12ie; + case ADC12IFG: + return adc12ifg; + default: + if (address >= ADC12MCTL0 && address <= ADC12MCTL15) { + return adc12mctl[address - ADC12MCTL0]; + } else if (address >= ADC12MEM0) { + return adc12mem[address - ADC12MEM0]; + } } return 0; } @@ -133,8 +188,4 @@ public void interruptServiced(int vector) { } - - public long ioTick(long cycles) { - return cycles + 1000000; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-15 20:33:27
|
Revision: 233 http://mspsim.svn.sourceforge.net/mspsim/?rev=233&view=rev Author: joxe Date: 2008-04-15 13:33:24 -0700 (Tue, 15 Apr 2008) Log Message: ----------- added line-sample chart Added Paths: ----------- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java Added: mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java (rev 0) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-04-15 20:33:24 UTC (rev 233) @@ -0,0 +1,76 @@ +package se.sics.mspsim.extutil.jfreechart; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.util.Date; + +import javax.swing.JComponent; +import javax.swing.JPanel; + +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; + +import se.sics.mspsim.cli.WindowDataHandler; + +public class LineSampleChart implements WindowDataHandler { + + JPanel panel; + private TimeSeriesCollection dataset; + private TimeSeries timeSeries; + + public LineSampleChart() { + DateAxis domain = new DateAxis("Time"); + NumberAxis range = new NumberAxis("Value"); + XYPlot xyplot = new XYPlot(); + xyplot.setDomainAxis(domain); + xyplot.setRangeAxis(range); + // xyplot.setBackgroundPaint(Color.black); + xyplot.setDataset(dataset = new TimeSeriesCollection()); + + DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); + renderer.setSeriesPaint(0, Color.black); + renderer.setSeriesShapesVisible(0, false); + xyplot.setRenderer(renderer); + + domain.setAutoRange(true); + domain.setLowerMargin(0.0); + domain.setUpperMargin(0.0); + + domain.setTickLabelsVisible(true); + range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + JFreeChart chart = new JFreeChart("Test", + JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); + ChartPanel chartPanel = new ChartPanel(chart); + panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.setPreferredSize(new Dimension(400, 200)); + panel.add(chartPanel, BorderLayout.CENTER); + + timeSeries = new TimeSeries("-", Millisecond.class); + timeSeries.setMaximumItemCount(200); + dataset.addSeries(timeSeries); + } + + public JComponent getJComponent() { + return panel; + } + + @Override + public void lineRead(String line) { + System.out.println("Got line to: " + line); + String parts[] = line.trim().split(" "); + timeSeries.clear(); + for (int i = 0; i < parts.length; i++) { + timeSeries.add(new Millisecond(new Date(i)), Integer.parseInt(parts[i])); + } + panel.repaint(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-15 20:27:18
|
Revision: 232 http://mspsim.svn.sourceforge.net/mspsim/?rev=232&view=rev Author: joxe Date: 2008-04-15 13:27:00 -0700 (Tue, 15 Apr 2008) Log Message: ----------- added mem dump feature + line-sample type window that can show the memory dump as a chart. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/cli/WindowTarget.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/WindowDataHandler.java Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-04-15 18:49:21 UTC (rev 231) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-04-15 20:27:00 UTC (rev 232) @@ -249,6 +249,39 @@ return 0; } }); + + ch.registerCommand("mem", new BasicCommand("dump memory", "<start address> <num_emtries> [type]") { + public int executeCommand(final CommandContext context) { + int start = context.getArgumentAsAddress(0); + int count = context.getArgumentAsInt(1); + int size = 1; // unsigned byte + boolean signed = false; + if (context.getArgumentCount() > 2) { + String tS = context.getArgument(2); + if ("byte".equals(tS)) { + signed = true; + } else if ("word".equals(tS)) { + signed = true; + size = 2; + } else if ("uword".equals(tS)) { + size = 2; + } + } + // Does not yet handle signed data... + for (int i = 0; i < count; i++) { + int data = 0; + data = cpu.memory[start++]; + if (size == 2) { + data = data + (cpu.memory[start++] << 8); + } + context.out.print(" " + data); + } + context.out.println(); + return 0; + } + }); + + } } } Added: mspsim/se/sics/mspsim/cli/WindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowDataHandler.java (rev 0) +++ mspsim/se/sics/mspsim/cli/WindowDataHandler.java 2008-04-15 20:27:00 UTC (rev 232) @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2007, 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: $ + * + * ----------------------------------------------------------------- + * + * WindowDataHandler + * + * Author : Joakim Eriksson + * Created : 15 apr 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +import javax.swing.JComponent; + +/** + * @author joakim + * + */ +public interface WindowDataHandler extends LineListener { + public JComponent getJComponent(); +} Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-15 18:49:21 UTC (rev 231) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-15 20:27:00 UTC (rev 232) @@ -3,16 +3,19 @@ import javax.swing.JFrame; import javax.swing.JTextArea; +import se.sics.mspsim.extutil.jfreechart.LineSampleChart; + public class WindowTarget implements LineListener { private JFrame window; private String targetName; private JTextArea jta = new JTextArea(20,20); + private WindowDataHandler dataHandler = null; public WindowTarget(String name) { window = new JFrame(name); window.setVisible(true); - window.add(jta); + window.getContentPane().add(jta); targetName = name; } @@ -30,12 +33,24 @@ } catch (Exception e) { System.err.println("Cound not set bounds: " + line); } - } - if ("title".equals(cmd)) { + } else if ("title".equals(cmd)) { window.setTitle(parts[1]); + } else if ("type".equals(cmd)) { + if ("line-sample".equals(parts[1])) { + dataHandler = new LineSampleChart(); + } + if (dataHandler != null) { + System.out.println("Replacing window data handler! " + parts[1] + " " + dataHandler); + window.getContentPane().removeAll(); + window.getContentPane().add(dataHandler.getJComponent()); + } } - } else { - jta.append(line + '\n'); + } else { + if (dataHandler != null) { + dataHandler.lineRead(line); + } else { + jta.append(line + '\n'); + } } // jta.set } @@ -51,6 +66,5 @@ public String getName() { // TODO Auto-generated method stub return targetName; - } - + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-15 18:49:48
|
Revision: 231 http://mspsim.svn.sourceforge.net/mspsim/?rev=231&view=rev Author: joxe Date: 2008-04-15 11:49:21 -0700 (Tue, 15 Apr 2008) Log Message: ----------- added first version of window subsystem with management commands from CLI. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/platform/GenericNode.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/WindowCommands.java mspsim/se/sics/mspsim/cli/WindowTarget.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-04 08:34:41 UTC (rev 230) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-04-15 18:49:21 UTC (rev 231) @@ -157,6 +157,13 @@ } }); + handler.registerCommand("echo", new BasicCommand("echoes argument", "") { + public int executeCommand(CommandContext context) { + context.out.println(context.getArgument(0)); + return 0; + } + }); + handler.registerCommand("exec", new ExecCommand()); } Added: mspsim/se/sics/mspsim/cli/WindowCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowCommands.java (rev 0) +++ mspsim/se/sics/mspsim/cli/WindowCommands.java 2008-04-15 18:49:21 UTC (rev 231) @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2007, 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: WindowCommands.java 187 2008-03-17 19:34:12Z joxe $ + * + * ----------------------------------------------------------------- + * + * WindowCommands - + * + * Author : Joakim Eriksson + * Created : 9 april 2008 + * Updated : $Date: 2008-03-17 20:34:12 +0100 (Mon, 17 Mar 2008) $ + * $Revision: 187 $ + */ +package se.sics.mspsim.cli; + +import java.util.Hashtable; + +import se.sics.mspsim.util.ComponentRegistry; + +public class WindowCommands implements CommandBundle { + + private Hashtable <String, WindowTarget> windowTargets = new Hashtable<String, WindowTarget>(); + + public void setupCommands(ComponentRegistry registry, CommandHandler handler) { + handler.registerCommand(">#", new BasicLineCommand(null, "<windowname>") { + WindowTarget wt; + public int executeCommand(CommandContext context) { + String windowName = context.getArgument(0); + wt = windowTargets.get(windowName); + if (wt == null) { + wt = new WindowTarget(windowName); + windowTargets.put(windowName, wt); + } + return 0; + } + public void lineRead(String line) { + wt.lineRead(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()); + } + }); + + handler.registerCommand("wclose", new BasicCommand("close the specified window", "<windowname>") { + public int executeCommand(CommandContext context) { + String name = context.getArgument(0); + WindowTarget wt = windowTargets.get(name); + if (wt != null) { + context.out.println("Closing window " + name); + windowTargets.remove(name); + wt.close(); + return 0; + } else { + context.err.println("Could not find the window " + name); + return 1; + } + } + }); + } +} Added: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java (rev 0) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-04-15 18:49:21 UTC (rev 231) @@ -0,0 +1,56 @@ +package se.sics.mspsim.cli; + +import javax.swing.JFrame; +import javax.swing.JTextArea; + +public class WindowTarget implements LineListener { + + private JFrame window; + private String targetName; + private JTextArea jta = new JTextArea(20,20); + + public WindowTarget(String name) { + window = new JFrame(name); + window.setVisible(true); + window.add(jta); + targetName = name; + } + + @Override + public void lineRead(String line) { + // TODO Auto-generated method stub + if (line != null && line.startsWith("#!")) { + line = line.substring(2); + String[] parts = line.split(" "); + String cmd = parts[0]; + if ("bounds".equals(cmd)) { + try { + window.setBounds(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), + Integer.parseInt(parts[3]), Integer.parseInt(parts[4])); + } catch (Exception e) { + System.err.println("Cound not set bounds: " + line); + } + } + if ("title".equals(cmd)) { + window.setTitle(parts[1]); + } + } else { + jta.append(line + '\n'); + } + // jta.set + } + + public void close() { + // Notify all the currently active "streams" of lines to this windows + // data-handlers + window.setVisible(false); + window.removeAll(); + window = null; + } + + public String getName() { + // TODO Auto-generated method stub + return targetName; + } + +} Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-04-04 08:34:41 UTC (rev 230) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-04-15 18:49:21 UTC (rev 231) @@ -43,6 +43,7 @@ import se.sics.mspsim.cli.CommandHandler; import se.sics.mspsim.cli.DebugCommands; import se.sics.mspsim.cli.MiscCommands; +import se.sics.mspsim.cli.WindowCommands; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; @@ -85,6 +86,7 @@ registry.registerComponent("debugcmd", new DebugCommands()); registry.registerComponent("misccmd", new MiscCommands()); registry.registerComponent("statcmd", new StatCommands(cpu, stats)); + registry.registerComponent("wincmd", new WindowCommands()); registry.registerComponent("node", this); registry.registerComponent("config", config); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-04 08:34:57
|
Revision: 230 http://mspsim.svn.sourceforge.net/mspsim/?rev=230&view=rev Author: nifi Date: 2008-04-04 01:34:41 -0700 (Fri, 04 Apr 2008) Log Message: ----------- fixed length handling of radio packet Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-04 07:45:50 UTC (rev 229) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-04 08:34:41 UTC (rev 230) @@ -183,9 +183,10 @@ System.out.println(getName() + ": **** Transmitting package to listener (if any)"); } if (packetListener != null) { + // First byte is length and is not included in the data buffer (and its length) int len = memory[RAM_TXFIFO]; - int[] data = new int[len - 1]; - System.arraycopy(memory, RAM_TXFIFO + 1, data, 0, len - 1); + int[] data = new int[len]; + System.arraycopy(memory, RAM_TXFIFO + 1, data, 0, len); packetListener.transmissionEnded(data); } } @@ -425,8 +426,8 @@ if (packetListener != null) { packetListener.transmissionStarted(); cpu.scheduleTimeEventMillis(transmissionEvent, 1000 * time); - memory[RAM_TXFIFO + len - 2] = 1; - memory[RAM_TXFIFO + len - 1] = 2; + memory[RAM_TXFIFO + len - 1] = 1; + memory[RAM_TXFIFO + len - 0] = 2; } } @@ -484,8 +485,8 @@ // Length is not assumed to be and no CRC?! public void setIncomingPacket(int[] packet) { int adr = RAM_RXFIFO; - // Lenght is added + RSSI and CRC/Correlation! - memory[adr++] = packet.length + 3; + // length of packet is data size + RSSI and CRC/Correlation! + memory[adr++] = packet.length + 2; for (int element : packet) { memory[adr++] = element & 0xff; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-04 07:46:06
|
Revision: 229 http://mspsim.svn.sourceforge.net/mspsim/?rev=229&view=rev Author: joxe Date: 2008-04-04 00:45:50 -0700 (Fri, 04 Apr 2008) Log Message: ----------- fixed network connection (server) to avoid sending back to the source radio. Modified Paths: -------------- mspsim/se/sics/mspsim/util/NetworkConnection.java Modified: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-04 06:53:36 UTC (rev 228) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-04 07:45:50 UTC (rev 229) @@ -104,19 +104,20 @@ } // Data incoming from the network!!! - private void dataReceived(byte[] data, int len) { + private void dataReceived(byte[] data, int len, ConnectionThread source) { int[] buf = new int[len]; if (listener != null) { for (int i = 0; i < buf.length; i++) { buf[i] = data[i]; } - // Send this data to the transmitter + // Send this data to the transmitter in this node! listener.transmissionStarted(); listener.transmissionEnded(buf); } + // And if this is the server, propagate to the others if (serverSocket != null) { - dataSent(buf); + dataSent(buf, source); } } @@ -126,6 +127,12 @@ // Data was sent from the radio in the node (or other node) and should // be sent out to other nodes!!! public void dataSent(int[] data) { + dataSent(data, null); + } + + // Data was sent either from radio, or came from another "radio" - + // and if so it should be propagated to all others. + public void dataSent(int[] data, ConnectionThread source) { if (connections.size() > 0) { for (int i = 0; i < data.length; i++) { buf[i] = (byte) data[i]; @@ -134,7 +141,8 @@ for (int i = 0; i < cthr.length; i++) { if (cthr[i].isClosed()) { connections.remove(cthr); - } else { + // Do not write back to the source + } else if (cthr[i] != source){ try { cthr[i].output.write((byte) data.length); cthr[i].output.write(buf, 0, data.length); @@ -215,8 +223,7 @@ System.out.println("NetworkConnection: Read packet with " + len + " bytes"); printPacket(buffer, len); } - - dataReceived(buffer, len); + dataReceived(buffer, len, this); } } catch (IOException e) { e.printStackTrace(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-04 06:53:50
|
Revision: 228 http://mspsim.svn.sourceforge.net/mspsim/?rev=228&view=rev Author: joxe Date: 2008-04-03 23:53:36 -0700 (Thu, 03 Apr 2008) Log Message: ----------- removed some debug printouts. Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-03 22:19:51 UTC (rev 227) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-04 06:53:36 UTC (rev 228) @@ -277,7 +277,7 @@ } break; case WRITE_TXFIFO: - System.out.println("Writing data: " + data + " to tx: " + txCursor); +// System.out.println("Writing data: " + data + " to tx: " + txCursor); memory[RAM_TXFIFO + txCursor++] = data & 0xff; break; case RAM_ACCESS: Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-03 22:19:51 UTC (rev 227) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-04 06:53:36 UTC (rev 228) @@ -264,11 +264,11 @@ // TODO: remove this test... radio.setPacketListener(new PacketListener() { public void transmissionEnded(int[] receivedData) { - System.out.println(getName() + " got packet from radio " + SkyNode.this.cpu.getTimeMillis()); +// System.out.println(getName() + " got packet from radio " + SkyNode.this.cpu.getTimeMillis()); network.dataSent(receivedData); } public void transmissionStarted() { - System.out.println(getName() + " got indication on transmission from radio " + SkyNode.this.cpu.getTimeMillis()); +// System.out.println(getName() + " got indication on transmission from radio " + SkyNode.this.cpu.getTimeMillis()); } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-04-03 22:20:09
|
Revision: 227 http://mspsim.svn.sourceforge.net/mspsim/?rev=227&view=rev Author: nifi Date: 2008-04-03 15:19:51 -0700 (Thu, 03 Apr 2008) Log Message: ----------- added file locking to select next unused flash file Modified Paths: -------------- mspsim/se/sics/mspsim/chip/FileM25P80.java Modified: mspsim/se/sics/mspsim/chip/FileM25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/FileM25P80.java 2008-04-03 15:48:42 UTC (rev 226) +++ mspsim/se/sics/mspsim/chip/FileM25P80.java 2008-04-03 22:19:51 UTC (rev 227) @@ -31,7 +31,7 @@ * * ----------------------------------------------------------------- * - * ExtFlash + * FileM25P80 - File based implementation of external flash. * * Author : Joakim Eriksson, Fredrik Osterlind * Created : Sun Oct 21 22:00:00 2007 @@ -40,31 +40,86 @@ */ package se.sics.mspsim.chip; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import se.sics.mspsim.core.MSP430Core; -import se.sics.mspsim.core.*; - public class FileM25P80 extends M25P80 { + private static final boolean DEBUG = true; + private RandomAccessFile file; + private FileChannel fileChannel; + private FileLock fileLock; public FileM25P80(MSP430Core cpu, String filename) { super(cpu); if (filename == null) { filename = "flash.bin"; } + // Open flash file for R/W + if (!openFile(filename)) { + // Failed to open/lock the specified file. Add a counter and try with next filename. + Matcher m = Pattern.compile("^(.+?)(\\d*)(\\..+)$").matcher(filename); + if (m.matches()) { + String baseName = m.group(1); + String c = m.group(2); + String extName = m.group(3); + int count = 1; + if (c != null && c.length() > 0) { + count = Integer.parseInt(c) + 1; + } + for (int i = 0; !openFile(baseName + count + extName) && i < 100; i++, count++); + } + } + if (fileLock == null) { + // Failed to open flash file + throw new IllegalStateException("failed to open flash file '" + filename + '\''); + } + // Set size of flash try { + file.setLength(1024 * 1024); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private boolean openFile(String filename) { + // Open flash file for R/W + try { file = new RandomAccessFile(filename, "rw"); - } catch (FileNotFoundException e) { + fileChannel = file.getChannel(); + fileLock = fileChannel.tryLock(); + if (fileLock != null) { + // The file is now locked for use + if (DEBUG) System.out.println("FileM25P80: using flash file '" + filename + '\''); + return true; + } else { + fileChannel.close(); + return false; + } + } catch (IOException e) { e.printStackTrace(); - return; + closeFile(); + return false; } - // Set size of flash + } + + private void closeFile() { try { - file.setLength(1024 * 1024); + if (fileLock != null) { + fileLock.release(); + fileLock = null; + } + if (fileChannel != null) { + fileChannel.close(); + fileChannel = null; + } } catch (IOException e) { e.printStackTrace(); } @@ -82,4 +137,4 @@ file.write(b); } -} // ExtFlash +} // FileM25P80 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-04-03 15:51:35
|
Revision: 226 http://mspsim.svn.sourceforge.net/mspsim/?rev=226&view=rev Author: fros4943 Date: 2008-04-03 08:48:42 -0700 (Thu, 03 Apr 2008) Log Message: ----------- load flash file from disk optional Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-03 14:43:45 UTC (rev 225) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-03 15:48:42 UTC (rev 226) @@ -187,7 +187,7 @@ return "Tmote Sky"; } - public void setupNodePorts() { + public void setupNodePorts(boolean loadFlash) { IOUnit unit = cpu.getIOUnit("Port 5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; @@ -210,7 +210,9 @@ radio.setCCAPort(port1, CC2420_CCA); radio.setFIFOPPort(port1, CC2420_FIFOP); radio.setFIFOPort(port1, CC2420_FIFO); - flash = new FileM25P80(cpu, flashFile); + if (loadFlash) { + flash = new FileM25P80(cpu, flashFile); + } ((USART) usart0).setUSARTListener(this); port4 = (IOPort) cpu.getIOUnit("Port 4"); if (port4 != null && port4 instanceof IOPort) { @@ -235,7 +237,7 @@ this.flashFile = fileName; - setupNodePorts(); + setupNodePorts(true); stats.addMonitor(this); stats.addMonitor(radio); @@ -250,7 +252,7 @@ // } // }, 1000000); - + network = new NetworkConnection(); network.addPacketListener(new PacketListener() { public void transmissionEnded(int[] receivedData) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-04-03 14:43:54
|
Revision: 225 http://mspsim.svn.sourceforge.net/mspsim/?rev=225&view=rev Author: fros4943 Date: 2008-04-03 07:43:45 -0700 (Thu, 03 Apr 2008) Log Message: ----------- set readall method public Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2008-04-02 21:55:51 UTC (rev 224) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-04-03 14:43:45 UTC (rev 225) @@ -243,7 +243,7 @@ } } - private void readAll() { + public void readAll() { readHeader(); readPrograms(); readSections(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-02 21:55:57
|
Revision: 224 http://mspsim.svn.sourceforge.net/mspsim/?rev=224&view=rev Author: joxe Date: 2008-04-02 14:55:51 -0700 (Wed, 02 Apr 2008) Log Message: ----------- minor fixes to CC2420 send/receive API handling Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-01 22:27:48 UTC (rev 223) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-04-02 21:55:51 UTC (rev 224) @@ -184,8 +184,8 @@ } if (packetListener != null) { int len = memory[RAM_TXFIFO]; - int[] data = new int[len]; - System.arraycopy(memory, RAM_TXFIFO + 1, data, 0, len); + int[] data = new int[len - 1]; + System.arraycopy(memory, RAM_TXFIFO + 1, data, 0, len - 1); packetListener.transmissionEnded(data); } } @@ -208,97 +208,98 @@ } switch(state) { case WAITING: - state = WRITE_REGISTER; - if ((data & FLAG_READ) != 0) { - state = READ_REGISTER; - } - if ((data & FLAG_RAM) != 0) { - state = RAM_ACCESS; - address = data & 0x7f; - } else { - // The register address - address = data & 0x3f; + state = WRITE_REGISTER; + if ((data & FLAG_READ) != 0) { + state = READ_REGISTER; + } + if ((data & FLAG_RAM) != 0) { + state = RAM_ACCESS; + address = data & 0x7f; + } else { + // The register address + address = data & 0x3f; - if (address == REG_RXFIFO) { - // check read/write??? -// System.out.println("CC2420: Reading RXFIFO!!!"); - state = READ_RXFIFO; - } else if (address == REG_TXFIFO) { - state = WRITE_TXFIFO; - } - } - if (data < 0x0f) { - strobe(data); - } - pos = 0; - // Assuming that the status always is sent back??? - source.byteReceived(status); - break; + if (address == REG_RXFIFO) { + // check read/write??? +// System.out.println("CC2420: Reading RXFIFO!!!"); + state = READ_RXFIFO; + } else if (address == REG_TXFIFO) { + state = WRITE_TXFIFO; + } + } + if (data < 0x0f) { + strobe(data); + } + pos = 0; + // Assuming that the status always is sent back??? + source.byteReceived(status); + break; case WRITE_REGISTER: - if (pos == 0) { - source.byteReceived(registers[address] >> 8); - // set the high bits - registers[address] = registers[address] & 0xff | (data << 8); - } else { - source.byteReceived(registers[address] & 0xff); - // set the low bits - registers[address] = registers[address] & 0xff00 | data; - if (DEBUG) { + if (pos == 0) { + source.byteReceived(registers[address] >> 8); + // set the high bits + registers[address] = registers[address] & 0xff | (data << 8); + } else { + source.byteReceived(registers[address] & 0xff); + // set the low bits + registers[address] = registers[address] & 0xff00 | data; + if (DEBUG) { System.out.println("CC2420: wrote to " + Utils.hex8(address) + " = " - + registers[address]); + + registers[address]); } - } + } pos++; break; case READ_REGISTER: - if (pos == 0) { - source.byteReceived(registers[address] >> 8); - } else { - source.byteReceived(registers[address] & 0xff); - if (DEBUG) { + if (pos == 0) { + source.byteReceived(registers[address] >> 8); + } else { + source.byteReceived(registers[address] & 0xff); + if (DEBUG) { System.out.println("CC2420: read from " + Utils.hex8(address) + " = " - + registers[address]); + + registers[address]); } - } + } pos++; break; case READ_RXFIFO: -// System.out.println("CC2420: RXFIFO READ => " + -// memory[RAM_RXFIFO + rxCursor]); - source.byteReceived(memory[RAM_RXFIFO + rxCursor++]); - // What if wrap cursor??? - if (rxCursor >= 128) { +// System.out.println("CC2420: RXFIFO READ => " + +// memory[RAM_RXFIFO + rxCursor]); + source.byteReceived(memory[RAM_RXFIFO + rxCursor++]); + // What if wrap cursor??? + if (rxCursor >= 128) { rxCursor = 0; } - // When is this set to "false" - when is interrupt de-triggered? - if (rxPacket) { - rxPacket = false; - updateFifopPin(); - } - break; + // When is this set to "false" - when is interrupt de-triggered? + if (rxPacket) { + rxPacket = false; + updateFifopPin(); + } + break; case WRITE_TXFIFO: + System.out.println("Writing data: " + data + " to tx: " + txCursor); memory[RAM_TXFIFO + txCursor++] = data & 0xff; break; case RAM_ACCESS: - if (pos == 0) { - address = address | (data << 1) & 0x180; - ramRead = (data & 0x20) != 0; - if (DEBUG) { + if (pos == 0) { + address = address | (data << 1) & 0x180; + ramRead = (data & 0x20) != 0; + if (DEBUG) { System.out.println("CC2420: Address: " + Utils.hex16(address) + - " read: " + ramRead); + " read: " + ramRead); } - pos++; - } else { - if (!ramRead) { - memory[address++] = data; - if (DEBUG && address == RAM_PANID + 2) { - System.out.println("CC2420: Pan ID set to: 0x" + - Utils.hex8(memory[RAM_PANID]) + - Utils.hex8(memory[RAM_PANID + 1])); - } - } - } - break; + pos++; + } else { + if (!ramRead) { + memory[address++] = data; + if (DEBUG && address == RAM_PANID + 2) { + System.out.println("CC2420: Pan ID set to: 0x" + + Utils.hex8(memory[RAM_PANID]) + + Utils.hex8(memory[RAM_PANID + 1])); + } + } + } + break; } } } @@ -424,6 +425,8 @@ if (packetListener != null) { packetListener.transmissionStarted(); cpu.scheduleTimeEventMillis(transmissionEvent, 1000 * time); + memory[RAM_TXFIFO + len - 2] = 1; + memory[RAM_TXFIFO + len - 1] = 2; } } @@ -478,9 +481,11 @@ registers[register] = data; } + // Length is not assumed to be and no CRC?! public void setIncomingPacket(int[] packet) { int adr = RAM_RXFIFO; - memory[adr++] = packet.length + 2; + // Lenght is added + RSSI and CRC/Correlation! + memory[adr++] = packet.length + 3; for (int element : packet) { memory[adr++] = element & 0xff; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-01 22:27:59
|
Revision: 223 http://mspsim.svn.sourceforge.net/mspsim/?rev=223&view=rev Author: joxe Date: 2008-04-01 15:27:48 -0700 (Tue, 01 Apr 2008) Log Message: ----------- added configuration for flashfile Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-01 22:27:08 UTC (rev 222) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-01 22:27:48 UTC (rev 223) @@ -222,12 +222,15 @@ public void setupNode() { // create a filename for the flash file // This should be possible to take from a config file later! - String fileName = firmwareFile; - int ix = fileName.lastIndexOf('.'); - if (ix > 0) { - fileName = fileName.substring(0, ix); + String fileName = config.getProperty("flashfile"); + if (fileName == null) { + fileName = firmwareFile; + int ix = fileName.lastIndexOf('.'); + if (ix > 0) { + fileName = fileName.substring(0, ix); + } + fileName = fileName + ".flash"; } - fileName = fileName + ".flash"; System.out.println("Using flash file: " + fileName); this.flashFile = fileName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-01 22:27:28
|
Revision: 222 http://mspsim.svn.sourceforge.net/mspsim/?rev=222&view=rev Author: joxe Date: 2008-04-01 15:27:08 -0700 (Tue, 01 Apr 2008) Log Message: ----------- added config to the registry. Modified Paths: -------------- mspsim/se/sics/mspsim/platform/GenericNode.java Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-04-01 22:25:56 UTC (rev 221) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-04-01 22:27:08 UTC (rev 222) @@ -86,6 +86,7 @@ registry.registerComponent("misccmd", new MiscCommands()); registry.registerComponent("statcmd", new StatCommands(cpu, stats)); registry.registerComponent("node", this); + registry.registerComponent("config", config); // Monitor execution cpu.setMonitorExec(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-01 22:26:19
|
Revision: 221 http://mspsim.svn.sourceforge.net/mspsim/?rev=221&view=rev Author: joxe Date: 2008-04-01 15:25:56 -0700 (Tue, 01 Apr 2008) Log Message: ----------- fixed bug and debug-output for NC. Modified Paths: -------------- mspsim/se/sics/mspsim/util/NetworkConnection.java Modified: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-01 08:19:47 UTC (rev 220) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-01 22:25:56 UTC (rev 221) @@ -137,8 +137,11 @@ } else { try { cthr[i].output.write((byte) data.length); - cthr[i].output.write(buf); - if (DEBUG) System.out.println("NetworkConnection: wrote " + data.length + " bytes"); + cthr[i].output.write(buf, 0, data.length); + if (DEBUG) { + System.out.println("NetworkConnection: wrote " + data.length + " bytes"); + printPacket(buf, data.length); + } } catch (IOException e) { e.printStackTrace(); cthr[i].close(); @@ -148,6 +151,13 @@ } } + private void printPacket(byte[] data, int len) { + for (int i = 0; i < len; i++) { + System.out.print("" + Utils.hex8(data[i]) + " "); + } + System.out.println(); + } + private boolean connect(int port) { try { Socket socket = new Socket("127.0.0.1", port); @@ -201,7 +211,11 @@ len = input.read(); if (len > 0) { input.readFully(buffer, 0, len); - if (DEBUG) System.out.println("NetworkConnection: Read packet with " + len + " bytes"); + if (DEBUG) { + System.out.println("NetworkConnection: Read packet with " + len + " bytes"); + printPacket(buffer, len); + } + dataReceived(buffer, len); } } catch (IOException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-04-01 08:19:50
|
Revision: 220 http://mspsim.svn.sourceforge.net/mspsim/?rev=220&view=rev Author: fros4943 Date: 2008-04-01 01:19:47 -0700 (Tue, 01 Apr 2008) Log Message: ----------- separated m24p80 from external files Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-01 08:18:31 UTC (rev 219) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-04-01 08:19:47 UTC (rev 220) @@ -44,12 +44,12 @@ import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.M25P80; +import se.sics.mspsim.chip.FileM25P80; 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.TimeEvent; import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.extutil.jfreechart.DataChart; @@ -129,6 +129,14 @@ return elf; } + public M25P80 getFlash() { + return flash; + } + + public void setFlash(M25P80 flash) { + this.flash = flash; + } + public void setDebug(boolean debug) { cpu.setDebug(debug); } @@ -202,7 +210,7 @@ radio.setCCAPort(port1, CC2420_CCA); radio.setFIFOPPort(port1, CC2420_FIFOP); radio.setFIFOPort(port1, CC2420_FIFO); - flash = new M25P80(cpu, flashFile); + flash = new FileM25P80(cpu, flashFile); ((USART) usart0).setUSARTListener(this); port4 = (IOPort) cpu.getIOUnit("Port 4"); if (port4 != null && port4 instanceof IOPort) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-04-01 08:18:34
|
Revision: 219 http://mspsim.svn.sourceforge.net/mspsim/?rev=219&view=rev Author: fros4943 Date: 2008-04-01 01:18:31 -0700 (Tue, 01 Apr 2008) Log Message: ----------- separated m24p80 from external files Added Paths: ----------- mspsim/se/sics/mspsim/chip/M25P80.java Added: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java (rev 0) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2008-04-01 08:18:31 UTC (rev 219) @@ -0,0 +1,337 @@ +/** + * Copyright (c) 2007, 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: M25P80.java 177 2008-03-11 15:32:12Z nifi $ + * + * ----------------------------------------------------------------- + * + * ExtFlash + * + * Author : Joakim Eriksson, Fredrik Osterlind + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2008-03-11 16:32:12 +0100 (ti, 11 mar 2008) $ + * $Revision: 177 $ + */ + +package se.sics.mspsim.chip; +import java.io.IOException; +import se.sics.mspsim.core.*; + +public abstract class M25P80 extends Chip implements USARTListener, PortListener { + + 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; + public static final int WRITE_DISABLE = 0x04; + public static final int READ_STATUS = 0x05; + public static final int WRITE_ENABLE = 0x06; + public static final int READ_DATA_FAST = 0x0b; + public static final int READ_IDENT = 0x9f; + public static final int SECTOR_ERASE = 0xd8; + public static final int BULK_ERASE = 0xc7; + public static final int DEEP_POWER_DOWN = 0xb9; + public static final int WAKE_UP = 0xab; + + private int state = 0; + public static final int CHIP_SELECT = 0x10; + private boolean chipSelect; + + private int pos; + private int status = 0; + + private boolean writeEnable = false; + private boolean writing = false; + + private int[] identity = new int[] { + 0x20,0x20,0x14,0x10, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + }; + private int readAddress; + private int loadedAddress = -1; + private int blockWriteAddress; + private byte[] readMemory = new byte[256]; + private byte[] buffer = new byte[256]; + + private TimeEvent writeEvent = new TimeEvent(0) { + public void execute(long t) { + writing = false; + }}; + + private MSP430Core cpu; + + public M25P80(MSP430Core cpu) { + this.cpu = cpu; + } + + public void dataReceived(USART source, int data) { + if (chipSelect) { + if (DEBUG) { + System.out.println("M25P80: byte received: " + data); + } + switch(state) { + case READ_IDENT: + source.byteReceived(identity[pos]); + pos++; + if (pos >= identity.length) { + pos = 0; + } + return; + case WRITE_STATUS: + status = data; + source.byteReceived(0); + return; + case READ_DATA: + if (pos < 3) { + readAddress = (readAddress << 8) + data; + source.byteReceived(0); + pos++; + if (DEBUG && pos == 3) { + System.out.println("M25P80: reading from " + Integer.toHexString(readAddress)); + } + } else { + source.byteReceived(readMemory(readAddress++)); + if (readAddress > 0xfffff) { + readAddress = 0; + } + } + return; + case SECTOR_ERASE: + if (pos < 3) { + readAddress = (readAddress << 8) + data; + source.byteReceived(0); + pos++; + if (pos == 3) { + // Clear buffer + sectorErase(readAddress); + } + } + return; + case PAGE_PROGRAM: + if (pos < 3) { + readAddress = (readAddress << 8) + data; + source.byteReceived(0); + pos++; + if (pos == 3) { + // Clear buffer + for (int i = 0; i < buffer.length; i++) { + buffer[i] = (byte) 0xff; + } + blockWriteAddress = readAddress & 0xfff00; + if (DEBUG) { + System.out.println("M25P80: programming at " + Integer.toHexString(readAddress)); + } + } + } else { + // Do the programming!!! + source.byteReceived(0); + writeBuffer((readAddress++) & 0xff, data); + } + return; + } + if (DEBUG) { + System.out.println("M25P80: new command: " + data); + } + switch (data) { + case WRITE_ENABLE: + if (DEBUG) { + System.out.println("M25P80: Write Enable"); + } + writeEnable = true; + break; + case WRITE_DISABLE: + if (DEBUG) { + System.out.println("M25P80: Write Disable"); + } + writeEnable = false; + break; + case READ_IDENT: + if (DEBUG) { + System.out.println("M25P80: Read ident."); + } + state = READ_IDENT; + pos = 0; + source.byteReceived(identity[pos++]); + return; + case READ_STATUS: + status = (status & (0xff - 1 - 2)) | (writeEnable ? 0x02 : 0x00) | + (writing ? 0x01 : 0x00); + source.byteReceived(status); + if (DEBUG) { + System.out.println("M25P80: Read status => " + status); + } + return; + case WRITE_STATUS: + if (DEBUG) { + System.out.println("M25P80: Write status"); + } + state = WRITE_STATUS; + break; + case READ_DATA: + if (DEBUG) { + System.out.println("M25P80: Read Data"); + } + state = READ_DATA; + pos = readAddress = 0; + break; + case PAGE_PROGRAM: + if (DEBUG) { + System.out.println("M25P80: Page Program"); + } + state = PAGE_PROGRAM; + pos = readAddress = 0; + break; + case SECTOR_ERASE: + if (DEBUG) { + System.out.println("M25P80: Sector Erase"); + } + state = SECTOR_ERASE; + pos = 0; + break; + case BULK_ERASE: + System.out.println("M25P80: Bulk Erase"); + break; + } + source.byteReceived(0); + } + } + + // Should return correct data! + private int readMemory(int address) { + if (DEBUG) { + System.out.println("M25P80: Reading memory address: " + Integer.toHexString(address)); + } + ensureLoaded(address); + return readMemory[address & 0xff]; + } + + private void writeBuffer(int address, int data) { + buffer[address] = (byte) data; + } + + private void ensureLoaded(int address) { + if (loadedAddress < 0 + || ((loadedAddress & 0xfff00) != (address & 0xfff00))) { + try { + if (DEBUG) { + System.out.println("M25P80: Loading memory: " + (address & 0xfff00)); + } + seek(address & 0xfff00); + readFully(readMemory); + for (int i = 0; i < readMemory.length; i++) { + readMemory[i] = (byte) (~readMemory[i] & 0xff); + } + } catch (IOException e) { + e.printStackTrace(); + } + loadedAddress = address & 0xfff00; + } + } + + public void portWrite(IOPort source, int data) { + // Chip select = active low... + if (chipSelect && (data & CHIP_SELECT) != 0) { + // Chip select will go "off" + switch(state) { + case PAGE_PROGRAM: + programPage(); + break; + } + } + chipSelect = (data & CHIP_SELECT) == 0; +// System.out.println("M25P80: write to Port4: " + +// Integer.toString(data, 16) +// + " CS:" + chipSelect); + state = 0; + } + + private void writeStatus(double time) { + writing = true; + cpu.scheduleTimeEventMillis(writeEvent, time); + } + + private void programPage() { + writeStatus(0.64); + ensureLoaded(blockWriteAddress); + for (int i = 0; i < readMemory.length; i++) { + readMemory[i] &= buffer[i]; + } + writeBack(blockWriteAddress, readMemory); + } + + private void sectorErase(int address) { + writeStatus(600); + int sectorAddress = address & 0xf0000; + loadedAddress = -1; + for (int i = 0; i < buffer.length; i++) { + buffer[i] = (byte)0xff; + } + // Erase a complete sector + blockWriteAddress = sectorAddress; + for (int i = 0; i < 0x100; i++) { + if (DEBUG) { + System.out.println("M25P80: erasing at " + Integer.toHexString(blockWriteAddress)); + } + writeBack(blockWriteAddress, buffer); + blockWriteAddress += 0x100; + } + } + + + private void writeBack(int address, byte[] data) { + try { + byte[] tmp = new byte[data.length]; + if (DEBUG) { + System.out.println("M25P80: Writing data to disk at " + Integer.toHexString(address)); + } + seek(address & 0xfff00); + for (int i = 0; i < data.length; i++) { + tmp[i] = (byte) (~data[i] & 0xff); + } + write(tmp); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public int getModeMax() { + 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; + +} // ExtFlash This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-04-01 08:18:06
|
Revision: 218 http://mspsim.svn.sourceforge.net/mspsim/?rev=218&view=rev Author: fros4943 Date: 2008-04-01 01:18:03 -0700 (Tue, 01 Apr 2008) Log Message: ----------- separated m24p80 from external files Added Paths: ----------- mspsim/se/sics/mspsim/chip/FileM25P80.java Removed Paths: ------------- mspsim/se/sics/mspsim/chip/M25P80.java Copied: mspsim/se/sics/mspsim/chip/FileM25P80.java (from rev 198, mspsim/se/sics/mspsim/chip/M25P80.java) =================================================================== --- mspsim/se/sics/mspsim/chip/FileM25P80.java (rev 0) +++ mspsim/se/sics/mspsim/chip/FileM25P80.java 2008-04-01 08:18:03 UTC (rev 218) @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2007, 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$ + * + * ----------------------------------------------------------------- + * + * ExtFlash + * + * Author : Joakim Eriksson, Fredrik Osterlind + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.chip; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +import se.sics.mspsim.core.*; + +public class FileM25P80 extends M25P80 { + + private RandomAccessFile file; + + public FileM25P80(MSP430Core cpu, String filename) { + super(cpu); + if (filename == null) { + filename = "flash.bin"; + } + // Open flash file for R/W + try { + file = new RandomAccessFile(filename, "rw"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return; + } + // Set size of flash + try { + file.setLength(1024 * 1024); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void seek(long pos) throws IOException { + file.seek(pos); + } + + public int readFully(byte[] b) throws IOException { + return file.read(b); + } + + public void write(byte[] b) throws IOException { + file.write(b); + } + +} // ExtFlash Deleted: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2008-04-01 06:03:58 UTC (rev 217) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2008-04-01 08:18:03 UTC (rev 218) @@ -1,338 +0,0 @@ -/** - * Copyright (c) 2007, 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$ - * - * ----------------------------------------------------------------- - * - * ExtFlash - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ - */ - -package se.sics.mspsim.chip; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; - -import se.sics.mspsim.core.*; - -public class M25P80 extends Chip implements USARTListener, PortListener { - - 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; - public static final int WRITE_DISABLE = 0x04; - public static final int READ_STATUS = 0x05; - public static final int WRITE_ENABLE = 0x06; - public static final int READ_DATA_FAST = 0x0b; - public static final int READ_IDENT = 0x9f; - public static final int SECTOR_ERASE = 0xd8; - public static final int BULK_ERASE = 0xc7; - public static final int DEEP_POWER_DOWN = 0xb9; - public static final int WAKE_UP = 0xab; - - private int state = 0; - public static final int CHIP_SELECT = 0x10; - private boolean chipSelect; - - private int pos; - private int status = 0; - - private boolean writeEnable = false; - private boolean writing = false; - - private int[] identity = new int[] { - 0x20,0x20,0x14,0x10, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - }; - private int readAddress; - private int loadedAddress = -1; - private int blockWriteAddress; - private byte[] readMemory = new byte[256]; - private byte[] buffer = new byte[256]; - - private RandomAccessFile file; - - private TimeEvent writeEvent = new TimeEvent(0) { - public void execute(long t) { - writing = false; - }}; - - private MSP430Core cpu; - - public M25P80(MSP430Core cpu, String filename) { - this.cpu = cpu; - if (filename == null) - filename = "flash.bin"; - // Open flash file for R/W - try { - file = new RandomAccessFile(filename, "rw"); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return; - } - // Set size of flash - try { - file.setLength(1024 * 1024); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void dataReceived(USART source, int data) { - if (chipSelect) { - if (DEBUG) { - System.out.println("M25P80: byte received: " + data); - } - switch(state) { - case READ_IDENT: - source.byteReceived(identity[pos]); - pos++; - if (pos >= identity.length) - pos = 0; - return; - case WRITE_STATUS: - status = data; - source.byteReceived(0); - return; - case READ_DATA: - if (pos < 3) { - readAddress = (readAddress << 8) + data; - source.byteReceived(0); - pos++; - if (DEBUG && pos == 3) - System.out.println("M25P80: reading from " + Integer.toHexString(readAddress)); - } else { - source.byteReceived(readMemory(readAddress++)); - if (readAddress > 0xfffff) { - readAddress = 0; - } - } - return; - case SECTOR_ERASE: - if (pos < 3) { - readAddress = (readAddress << 8) + data; - source.byteReceived(0); - pos++; - if (pos == 3) { - // Clear buffer - sectorErase(readAddress); - } - } - return; - case PAGE_PROGRAM: - if (pos < 3) { - readAddress = (readAddress << 8) + data; - source.byteReceived(0); - pos++; - if (pos == 3) { - // Clear buffer - for (int i = 0; i < buffer.length; i++) { - buffer[i] = (byte) 0xff; - } - blockWriteAddress = readAddress & 0xfff00; - if (DEBUG) - System.out.println("M25P80: programming at " + Integer.toHexString(readAddress)); - } - } else { - // Do the programming!!! - source.byteReceived(0); - writeBuffer((readAddress++) & 0xff, data); - } - return; - } - if (DEBUG) - System.out.println("M25P80: new command: " + data); - switch (data) { - case WRITE_ENABLE: - if (DEBUG) - System.out.println("M25P80: Write Enable"); - writeEnable = true; - break; - case WRITE_DISABLE: - if (DEBUG) - System.out.println("M25P80: Write Disable"); - writeEnable = false; - break; - case READ_IDENT: - if (DEBUG) - System.out.println("M25P80: Read ident."); - state = READ_IDENT; - pos = 0; - source.byteReceived(identity[pos++]); - return; - case READ_STATUS: - status = (status & (0xff - 1 - 2)) | (writeEnable ? 0x02 : 0x00) | - (writing ? 0x01 : 0x00); - source.byteReceived(status); - if (DEBUG) - System.out.println("M25P80: Read status => " + status); - return; - case WRITE_STATUS: - if (DEBUG) - System.out.println("M25P80: Write status"); - state = WRITE_STATUS; - break; - case READ_DATA: - if (DEBUG) - System.out.println("M25P80: Read Data"); - state = READ_DATA; - pos = readAddress = 0; - break; - case PAGE_PROGRAM: - if (DEBUG) - System.out.println("M25P80: Page Program"); - state = PAGE_PROGRAM; - pos = readAddress = 0; - break; - case SECTOR_ERASE: - if (DEBUG) - System.out.println("M25P80: Sector Erase"); - state = SECTOR_ERASE; - pos = 0; - break; - case BULK_ERASE: - System.out.println("M25P80: Bulk Erase"); - break; - } - source.byteReceived(0); - } - } - - // Should return correct data! - private int readMemory(int address) { - if (DEBUG) - System.out.println("M25P80: Reading memory address: " + Integer.toHexString(address)); - ensureLoaded(address); - return readMemory[address & 0xff]; - } - - private void writeBuffer(int address, int data) { - buffer[address] = (byte) data; - } - - private void ensureLoaded(int address) { - if (loadedAddress < 0 - || ((loadedAddress & 0xfff00) != (address & 0xfff00))) { - try { - if (DEBUG) - System.out.println("M25P80: Loading memory: " + (address & 0xfff00)); - file.seek(address & 0xfff00); - file.readFully(readMemory); - for (int i = 0; i < readMemory.length; i++) { - readMemory[i] = (byte) (~readMemory[i] & 0xff); - } - } catch (IOException e) { - e.printStackTrace(); - } - loadedAddress = address & 0xfff00; - } - } - - public void portWrite(IOPort source, int data) { - // Chip select = active low... - if (chipSelect && (data & CHIP_SELECT) != 0) { - // Chip select will go "off" - switch(state) { - case PAGE_PROGRAM: - programPage(); - break; - } - } - chipSelect = (data & CHIP_SELECT) == 0; -// System.out.println("M25P80: write to Port4: " + -// Integer.toString(data, 16) -// + " CS:" + chipSelect); - state = 0; - } - - private void writeStatus(double time) { - writing = true; - cpu.scheduleTimeEventMillis(writeEvent, time); - } - - private void programPage() { - writeStatus(0.64); - ensureLoaded(blockWriteAddress); - for (int i = 0; i < readMemory.length; i++) { - readMemory[i] &= buffer[i]; - } - writeBack(blockWriteAddress, readMemory); - } - - private void sectorErase(int address) { - writeStatus(600); - int sectorAddress = address & 0xf0000; - loadedAddress = -1; - for (int i = 0; i < buffer.length; i++) { - buffer[i] = (byte)0xff; - } - // Erase a complete sector - blockWriteAddress = sectorAddress; - for (int i = 0; i < 0x100; i++) { - if (DEBUG) - System.out.println("M25P80: erasing at " + Integer.toHexString(blockWriteAddress)); - writeBack(blockWriteAddress, buffer); - blockWriteAddress += 0x100; - } - } - - - private void writeBack(int address, byte[] data) { - try { - byte[] tmp = new byte[data.length]; - if (DEBUG) - System.out.println("M25P80: Writing data to disk at " + Integer.toHexString(address)); - file.seek(address & 0xfff00); - for (int i = 0; i < data.length; i++) { - tmp[i] = (byte) (~data[i] & 0xff); - } - file.write(tmp); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public int getModeMax() { - return 0; - } - - public String getName() { - return "M25P80: external flash"; - } - - -} // ExtFlash This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-01 06:04:03
|
Revision: 217 http://mspsim.svn.sourceforge.net/mspsim/?rev=217&view=rev Author: joxe Date: 2008-03-31 23:03:58 -0700 (Mon, 31 Mar 2008) Log Message: ----------- small fix to the network connection. Modified Paths: -------------- mspsim/se/sics/mspsim/util/NetworkConnection.java Modified: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-03-31 18:12:04 UTC (rev 216) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-01 06:03:58 UTC (rev 217) @@ -56,7 +56,9 @@ */ public class NetworkConnection implements Runnable { + private final static boolean DEBUG = true; private final static int DEFAULT_PORT = 4711; + ServerSocket serverSocket = null; ArrayList<ConnectionThread> connections = new ArrayList<ConnectionThread>(); @@ -65,10 +67,10 @@ public NetworkConnection() { if (connect(DEFAULT_PORT)) { - System.out.println("Connected to network..."); + System.out.println("NetworkConnection: Connected to network..."); } else { setupServer(DEFAULT_PORT); - System.out.println("Setup network server..."); + System.out.println("NetworkConnection: Setup network server..."); } } @@ -80,7 +82,7 @@ private void setupServer(int port) { try { serverSocket = new ServerSocket(port); - System.out.println("setup of server socket finished... "); + if (DEBUG) System.out.println("NetworkConnection: setup of server socket finished... "); new Thread(this).start(); } catch (IOException e) { e.printStackTrace(); @@ -88,11 +90,11 @@ } public void run() { - System.out.println("Accepting new connections..."); + System.out.println("NetworkConnection: Accepting new connections..."); while (true) { try { Socket s = serverSocket.accept(); - System.out.println("New connection accepted..."); + if (DEBUG) System.out.println("NetworkConnection: New connection accepted..."); connections.add(new ConnectionThread(s)); } catch (IOException e) { // TODO Auto-generated catch block @@ -124,19 +126,23 @@ // Data was sent from the radio in the node (or other node) and should // be sent out to other nodes!!! public void dataSent(int[] data) { - for (int i = 0; i < data.length; i++) { - buf[i] = (byte) data[i]; - } - ConnectionThread[] cthr = connections.toArray(new ConnectionThread[connections.size()]); - for (int i = 0; i < cthr.length; i++) { - if (cthr[i].isClosed()) { - connections.remove(cthr); - } else { - try { - cthr[i].output.write(buf); - } catch (IOException e) { - e.printStackTrace(); - cthr[i].close(); + if (connections.size() > 0) { + for (int i = 0; i < data.length; i++) { + buf[i] = (byte) data[i]; + } + ConnectionThread[] cthr = connections.toArray(new ConnectionThread[connections.size()]); + for (int i = 0; i < cthr.length; i++) { + if (cthr[i].isClosed()) { + connections.remove(cthr); + } else { + try { + cthr[i].output.write((byte) data.length); + cthr[i].output.write(buf); + if (DEBUG) System.out.println("NetworkConnection: wrote " + data.length + " bytes"); + } catch (IOException e) { + e.printStackTrace(); + cthr[i].close(); + } } } } @@ -188,15 +194,15 @@ @Override public void run() { - System.out.println("Started connection thread..."); + if (DEBUG) System.out.println("NetworkConnection: Started connection thread..."); while (socket != null) { int len; try { len = input.read(); if (len > 0) { input.readFully(buffer, 0, len); - System.out.println("Read packet with " + len + " bytes"); - dataReceived(buffer, len); + if (DEBUG) System.out.println("NetworkConnection: Read packet with " + len + " bytes"); + dataReceived(buffer, len); } } catch (IOException e) { e.printStackTrace(); @@ -205,6 +211,4 @@ } } } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-31 18:12:12
|
Revision: 216 http://mspsim.svn.sourceforge.net/mspsim/?rev=216&view=rev Author: joxe Date: 2008-03-31 11:12:04 -0700 (Mon, 31 Mar 2008) Log Message: ----------- added simple connection between mspsim nodes (not yet working) Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/ui/SerialMon.java Added Paths: ----------- mspsim/se/sics/mspsim/util/NetworkConnection.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-03-31 18:11:13 UTC (rev 215) +++ mspsim/CHANGE_LOG.txt 2008-03-31 18:12:04 UTC (rev 216) @@ -14,6 +14,7 @@ - added event system for cycle based events - fixed timer (A/B) to be event driven instead of tick driven - fixed bugs in interrupt handling of timer system +- added argument management and -nogui parameter 0.84 Changes: Modified: mspsim/se/sics/mspsim/ui/SerialMon.java =================================================================== --- mspsim/se/sics/mspsim/ui/SerialMon.java 2008-03-31 18:11:13 UTC (rev 215) +++ mspsim/se/sics/mspsim/ui/SerialMon.java 2008-03-31 18:12:04 UTC (rev 216) @@ -55,7 +55,7 @@ public class SerialMon implements KeyListener, USARTListener { private static final String PREFIX = " > "; - + private static final int MAX_LINES = 200; private String name; private JFrame window; private USART usart; @@ -97,7 +97,7 @@ public void dataReceived(USART source, int data) { if (data == '\n') { - if (lines >= 60) { + if (lines >= MAX_LINES) { int index = text.indexOf('\n'); text = text.substring(index + 1); } else { Added: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java (rev 0) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-03-31 18:12:04 UTC (rev 216) @@ -0,0 +1,210 @@ +/** + * Copyright (c) 2007, 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: $ + * + * ----------------------------------------------------------------- + * + * NetworkConnection + * + * Author : Joakim Eriksson + * Created : 31 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.util; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.ArrayList; + +import se.sics.mspsim.chip.PacketListener; + +/** + * @author joakim + * + */ +public class NetworkConnection implements Runnable { + + private final static int DEFAULT_PORT = 4711; + ServerSocket serverSocket = null; + + ArrayList<ConnectionThread> connections = new ArrayList<ConnectionThread>(); + + private PacketListener listener; + + public NetworkConnection() { + if (connect(DEFAULT_PORT)) { + System.out.println("Connected to network..."); + } else { + setupServer(DEFAULT_PORT); + System.out.println("Setup network server..."); + } + } + + // TODO: this should handle several listeners!!! + public void addPacketListener(PacketListener pl) { + listener = pl; + } + + private void setupServer(int port) { + try { + serverSocket = new ServerSocket(port); + System.out.println("setup of server socket finished... "); + new Thread(this).start(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void run() { + System.out.println("Accepting new connections..."); + while (true) { + try { + Socket s = serverSocket.accept(); + System.out.println("New connection accepted..."); + connections.add(new ConnectionThread(s)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + // Data incoming from the network!!! + private void dataReceived(byte[] data, int len) { + int[] buf = new int[len]; + if (listener != null) { + for (int i = 0; i < buf.length; i++) { + buf[i] = data[i]; + } + // Send this data to the transmitter + listener.transmissionStarted(); + listener.transmissionEnded(buf); + } + + if (serverSocket != null) { + dataSent(buf); + } + } + + + byte[] buf = new byte[256]; + + // Data was sent from the radio in the node (or other node) and should + // be sent out to other nodes!!! + public void dataSent(int[] data) { + for (int i = 0; i < data.length; i++) { + buf[i] = (byte) data[i]; + } + ConnectionThread[] cthr = connections.toArray(new ConnectionThread[connections.size()]); + for (int i = 0; i < cthr.length; i++) { + if (cthr[i].isClosed()) { + connections.remove(cthr); + } else { + try { + cthr[i].output.write(buf); + } catch (IOException e) { + e.printStackTrace(); + cthr[i].close(); + } + } + } + } + + private boolean connect(int port) { + try { + Socket socket = new Socket("127.0.0.1", port); + connections.add(new ConnectionThread(socket)); + } catch (UnknownHostException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return false; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return false; + } + return true; + } + + class ConnectionThread implements Runnable { + byte[] buffer = new byte[256]; + + Socket socket; + DataInputStream input; + OutputStream output; + + public ConnectionThread(Socket socket) throws IOException { + this.socket = socket; + input = new DataInputStream(socket.getInputStream()); + output = socket.getOutputStream(); + new Thread(this).start(); + } + + public void close() { + try { + input.close(); + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + } + + public boolean isClosed() { + return socket == null; + } + + @Override + public void run() { + System.out.println("Started connection thread..."); + while (socket != null) { + int len; + try { + len = input.read(); + if (len > 0) { + input.readFully(buffer, 0, len); + System.out.println("Read packet with " + len + " bytes"); + dataReceived(buffer, len); + } + } catch (IOException e) { + e.printStackTrace(); + socket = null; + } + } + } + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-31 18:11:27
|
Revision: 215 http://mspsim.svn.sourceforge.net/mspsim/?rev=215&view=rev Author: joxe Date: 2008-03-31 11:11:13 -0700 (Mon, 31 Mar 2008) Log Message: ----------- added simple connection between mspsim nodes - not yet working. Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-25 13:32:34 UTC (rev 214) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-31 18:11:13 UTC (rev 215) @@ -55,8 +55,10 @@ 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.ArgumentManager; import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.NetworkConnection; import se.sics.mspsim.util.OperatingModeStatistics; /** @@ -92,6 +94,9 @@ private IOPort port5; public CC2420 radio; + public NetworkConnection network; + + private M25P80 flash; private String flashFile; @@ -234,10 +239,20 @@ // } // }, 1000000); + + network = new NetworkConnection(); + network.addPacketListener(new PacketListener() { + public void transmissionEnded(int[] receivedData) { + radio.setIncomingPacket(receivedData); + } + public void transmissionStarted() { + } + }); // TODO: remove this test... radio.setPacketListener(new PacketListener() { public void transmissionEnded(int[] receivedData) { System.out.println(getName() + " got packet from radio " + SkyNode.this.cpu.getTimeMillis()); + network.dataSent(receivedData); } public void transmissionStarted() { System.out.println(getName() + " got indication on transmission from radio " + SkyNode.this.cpu.getTimeMillis()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-25 13:32:39
|
Revision: 214 http://mspsim.svn.sourceforge.net/mspsim/?rev=214&view=rev Author: nifi Date: 2008-03-25 06:32:34 -0700 (Tue, 25 Mar 2008) Log Message: ----------- fixed typo Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/DebugCommands.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-25 13:12:20 UTC (rev 213) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-25 13:32:34 UTC (rev 214) @@ -200,7 +200,7 @@ } private void registerCommands() { - registerCommand("help", new BasicCommand("shows help for the specified command or command list", "[command]") { + registerCommand("help", new BasicCommand("show help for the specified command or command list", "[command]") { public int executeCommand(CommandContext context) { if (context.getArgumentCount() == 0) { context.out.println("Available commands:"); Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-25 13:12:20 UTC (rev 213) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-25 13:32:34 UTC (rev 214) @@ -175,7 +175,7 @@ - ch.registerCommand("symbol", new BasicCommand("list matching symbold", "<regexp>") { + ch.registerCommand("symbol", new BasicCommand("list matching symbols", "<regexp>") { public int executeCommand(final CommandContext context) { String regExp = context.getArgument(0); MapEntry[] entries = context.getMapTable().getEntries(regExp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-25 13:13:05
|
Revision: 213 http://mspsim.svn.sourceforge.net/mspsim/?rev=213&view=rev Author: nifi Date: 2008-03-25 06:12:20 -0700 (Tue, 25 Mar 2008) Log Message: ----------- fixed bug in set of esb node 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 2008-03-25 11:51:57 UTC (rev 212) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-03-25 13:12:20 UTC (rev 213) @@ -167,6 +167,10 @@ public void setupNode() { setupNodePorts(); + stats.addMonitor(this); + stats.addMonitor(radio); + stats.addMonitor(cpu); + if (!config.getPropertyAsBoolean("nogui", false)) { gui = new ESBGui(this); @@ -177,9 +181,6 @@ dataChart.addDataSource(dss, "Transmit", stats.getDataSource("TR1001", TR1001.MODE_TXRX_ON)); dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE)); } - stats.addMonitor(this); - stats.addMonitor(radio); - stats.addMonitor(cpu); } public int getModeMax() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-25 11:51:58
|
Revision: 212 http://mspsim.svn.sourceforge.net/mspsim/?rev=212&view=rev Author: nifi Date: 2008-03-25 04:51:57 -0700 (Tue, 25 Mar 2008) Log Message: ----------- removed debug output + fixed 'kill' to show error if command not was found Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-25 10:30:14 UTC (rev 211) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-25 11:51:57 UTC (rev 212) @@ -36,7 +36,7 @@ registerCommands(); } - // Add it to the hashtable (overwriting anything there) + // Add it to the command table (overwriting anything there) public void registerCommand(String cmd, Command command) { commands.put(cmd, command); } @@ -212,7 +212,8 @@ String argHelp = command.getArgumentHelp(name); String prefix = argHelp != null ? (' ' + name + ' ' + argHelp) : (' ' + name); int n; - if (helpText != null && (n = helpText.indexOf('\n')) > 0) { + if ((n = helpText.indexOf('\n')) > 0) { + // Show only first line as short help if help text consists of several lines helpText = helpText.substring(0, n); } context.out.print(prefix); @@ -234,7 +235,7 @@ String helpText = command.getCommandHelp(cmd); String argHelp = command.getArgumentHelp(cmd); context.out.print(cmd); - if (argHelp != null) { + if (argHelp != null && argHelp.length() > 0) { context.out.print(' ' + argHelp); } context.out.println(); @@ -267,8 +268,11 @@ registerCommand("kill", new BasicCommand("kill a currently executing command", "<process>") { public int executeCommand(CommandContext context) { int pid = context.getArgumentAsInt(0); - removePid(pid); - return 0; + if (removePid(pid)) { + return 0; + } + context.err.println("could not find the command to kill."); + return 1; } }); } @@ -278,9 +282,8 @@ removePid(pid); } } - - private void removePid(int pid) { - System.out.println("Removing pid: " + pid); + + private boolean removePid(int pid) { for (int i = 0; i < currentAsyncCommands.size(); i++) { CommandContext[] contexts = currentAsyncCommands.get(i); CommandContext cmd = contexts[0]; @@ -294,8 +297,9 @@ } } currentAsyncCommands.remove(contexts); - break; + return true; } } + return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |