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-03-25 10:30:20
|
Revision: 211 http://mspsim.svn.sourceforge.net/mspsim/?rev=211&view=rev Author: nifi Date: 2008-03-25 03:30:14 -0700 (Tue, 25 Mar 2008) Log Message: ----------- CLI help text cleanup + improved error handling Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/cli/ExecCommand.java mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/util/StatCommands.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-25 10:29:00 UTC (rev 210) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-25 10:30:14 UTC (rev 211) @@ -74,8 +74,15 @@ out.flush(); String line = readLine(inReader);//.readLine(); if (line != null && line.length() > 0) { - String[][] parts = CommandParser.parseLine(line); - if(parts.length > 0 && checkCommands(parts) == 0) { + String[][] parts; + try { + parts = CommandParser.parseLine(line); + } catch (Exception e) { + err.println("Error: failed to parse command:"); + e.printStackTrace(err); + parts = null; + } + if(parts != null && parts.length > 0 && checkCommands(parts) == 0) { CommandContext[] commands = new CommandContext[parts.length]; boolean error = false; int pid = -1; @@ -145,11 +152,11 @@ for (int i = 0; i < cmds.length; i++) { Command command = commands.get(cmds[i][0]); if (command == null) { - err.println("CLI: Command not found: " + cmds[i][0]); + err.println("CLI: Command not found: \"" + cmds[i][0] + "\". Try \"help\"."); return -1; } if (i > 0 && !(command instanceof LineListener)) { - err.println("CLI: Error " + cmds[i][0] + " does not take input"); + err.println("CLI: Error, command \"" + cmds[i][0] + "\" does not take input."); return -1; } // TODO replace with command name @@ -200,20 +207,23 @@ for(Map.Entry<String,Command> entry: commands.entrySet()) { String name = entry.getKey(); Command command = entry.getValue(); - String prefix = ' ' + name + ' ' + command.getArgumentHelp(name); String helpText = command.getCommandHelp(name); - int n; - if (helpText != null && (n = helpText.indexOf('\n')) > 0) { - helpText = helpText.substring(0, n); + if (helpText != null) { + String argHelp = command.getArgumentHelp(name); + String prefix = argHelp != null ? (' ' + name + ' ' + argHelp) : (' ' + name); + int n; + if (helpText != null && (n = helpText.indexOf('\n')) > 0) { + helpText = helpText.substring(0, n); + } + context.out.print(prefix); + if (prefix.length() < 8) { + context.out.print('\t'); + } + if (prefix.length() < 16) { + context.out.print('\t'); + } + context.out.println("\t " + helpText); } - context.out.print(prefix); - if (prefix.length() < 8) { - context.out.print('\t'); - } - if (prefix.length() < 16) { - context.out.print('\t'); - } - context.out.println("\t " + helpText); } return 0; } @@ -221,15 +231,23 @@ String cmd = context.getArgument(0); Command command = commands.get(cmd); if (command != null) { - context.out.println(cmd + ' ' + command.getArgumentHelp(cmd)); - context.out.println(" " + command.getCommandHelp(cmd)); + String helpText = command.getCommandHelp(cmd); + String argHelp = command.getArgumentHelp(cmd); + context.out.print(cmd); + if (argHelp != null) { + context.out.print(' ' + argHelp); + } + context.out.println(); + if (helpText != null && helpText.length() > 0) { + context.out.println(" " + helpText); + } return 0; } context.err.println("Error: unknown command '" + cmd + '\''); return 1; } }); - registerCommand("workaround", new BasicCommand("", "") { + registerCommand("workaround", new BasicCommand("activate workaround for Java console input bug", "") { public int executeCommand(CommandContext context) { workaround = true; return 0; Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-25 10:29:00 UTC (rev 210) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-25 10:30:14 UTC (rev 211) @@ -52,13 +52,13 @@ public class DebugCommands implements CommandBundle { private long lastCall = 0; private long lastWall = 0; - + public void setupCommands(ComponentRegistry registry, CommandHandler ch) { final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); final ELF elf = (ELF) registry.getComponent(ELF.class); final GenericNode node = (GenericNode) registry.getComponent("node"); if (cpu != null) { - ch.registerCommand("break", new BasicAsyncCommand("adds a breakpoint to a given address or symbol", + ch.registerCommand("break", new BasicAsyncCommand("add a breakpoint to a given address or symbol", "<address or symbol>") { int address = 0; public int executeCommand(final CommandContext context) { @@ -78,7 +78,7 @@ }); ch.registerCommand("watch", - new BasicAsyncCommand("adds a write watch to a given address or symbol", "<address or symbol>") { + new BasicAsyncCommand("add a write watch to a given address or symbol", "<address or symbol>") { int mode = 0; int address = 0; public int executeCommand(final CommandContext context) { @@ -118,7 +118,7 @@ }); ch.registerCommand("watchreg", - new BasicAsyncCommand("adds a write watch to a given register", "<register> [int]") { + new BasicAsyncCommand("add a write watch to a given register", "<register> [int]") { int mode = 0; int register = 0; public int executeCommand(final CommandContext context) { @@ -169,13 +169,13 @@ } public String getCommandHelp(String commandName) { - return "clears a breakpoint or watch from a given address or symbol"; + return "clear a breakpoint or watch from a given address or symbol"; } }); - ch.registerCommand("symbol", new BasicCommand("lists matching symbold", "<regexp>") { + ch.registerCommand("symbol", new BasicCommand("list matching symbold", "<regexp>") { public int executeCommand(final CommandContext context) { String regExp = context.getArgument(0); MapEntry[] entries = context.getMapTable().getEntries(regExp); @@ -189,29 +189,29 @@ }); if (node != null) { - ch.registerCommand("stop", new BasicCommand("stops mspsim", "") { + ch.registerCommand("stop", new BasicCommand("stop the CPU", "") { public int executeCommand(CommandContext context) { node.stop(); context.out.println("CPU stopped at: $" + Utils.hex16(cpu.readRegister(0))); return 0; } }); - ch.registerCommand("start", new BasicCommand("starts mspsim", "") { + ch.registerCommand("start", new BasicCommand("start the CPU", "") { public int executeCommand(CommandContext context) { node.start(); return 0; } }); - ch.registerCommand("step", new BasicCommand("singlesteps mspsim", "<number of lines>") { + ch.registerCommand("step", new BasicCommand("singlestep the CPU", "[number of instructions]") { public int executeCommand(CommandContext context) { int nr = context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1; while(nr-- > 0) node.step(); - context.out.println("CPU stepped to: " + Utils.hex16(cpu.readRegister(0))); + context.out.println("CPU stepped to: $" + Utils.hex16(cpu.readRegister(0))); return 0; } }); - ch.registerCommand("print", new BasicCommand("prints value of an address or symbol", "<address or symbol>") { + ch.registerCommand("print", new BasicCommand("print value of an address or symbol", "<address or symbol>") { public int executeCommand(CommandContext context) { int adr = context.getArgumentAsAddress(0); if (adr != -1) { @@ -222,7 +222,7 @@ return 0; } }); - ch.registerCommand("printreg", new BasicCommand("prints value of an register", "<register>") { + ch.registerCommand("printreg", new BasicCommand("print value of an register", "<register>") { public int executeCommand(CommandContext context) { int register = context.getArgumentAsRegister(0); if (register >= 0) { @@ -232,14 +232,14 @@ return -1; } }); - ch.registerCommand("reset", new BasicCommand("resets the CPU", "") { + ch.registerCommand("reset", new BasicCommand("reset the CPU", "") { public int executeCommand(CommandContext context) { cpu.reset(); return 0; } }); - ch.registerCommand("time", new BasicCommand("prints the elapse time and cycles", "") { + ch.registerCommand("time", new BasicCommand("print the elapse time and cycles", "") { public int executeCommand(CommandContext context) { long time = ((long)(cpu.getTimeMillis())); context.out.println("Emulated time elapsed: " + time + "(ms) since last: " + (time - lastCall) + " ms" + " wallTime: " + Modified: mspsim/se/sics/mspsim/cli/ExecCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/ExecCommand.java 2008-03-25 10:29:00 UTC (rev 210) +++ mspsim/se/sics/mspsim/cli/ExecCommand.java 2008-03-25 10:30:14 UTC (rev 211) @@ -52,7 +52,7 @@ private PrintStream output; public ExecCommand() { - super("executes the specified command", "<cmd> [args...]"); + super("execute the specified command", "<cmd> [args...]"); } public int executeCommand(CommandContext context) { Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-25 10:29:00 UTC (rev 210) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-25 10:30:14 UTC (rev 211) @@ -39,14 +39,11 @@ * $Revision$ */ package se.sics.mspsim.cli; - -import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.util.Hashtable; import java.util.Iterator; import java.util.regex.Pattern; - import se.sics.mspsim.core.MSP430; import se.sics.mspsim.util.ComponentRegistry; @@ -55,10 +52,11 @@ * */ public class MiscCommands implements CommandBundle { - Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); + private Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); + public void setupCommands(final ComponentRegistry registry, CommandHandler handler) { - handler.registerCommand("grep", new BasicLineCommand("grep", "<regexp>") { + handler.registerCommand("grep", new BasicLineCommand("print lines matching the specified pattern", "<regexp>") { private PrintStream out; private Pattern pattern; public int executeCommand(CommandContext context) { @@ -77,14 +75,14 @@ // TODO: this should also be "registered" as a "sink". // probably this should be handled using ">" instead! - handler.registerCommand(">", new BasicLineCommand(">", "<filename>") { + handler.registerCommand(">", new BasicLineCommand(null, "<filename>") { FileTarget ft; public int executeCommand(CommandContext context) { String fileName = context.getArgument(0); ft = fileTargets.get(fileName); if (ft == null) { try { - System.out.println("Creating new file target: " + fileName); +// System.out.println("Creating new file target: " + fileName); ft = new FileTarget(fileName); fileTargets.put(fileName, ft); } catch (IOException e) { @@ -102,22 +100,23 @@ } }); - handler.registerCommand("fclose", new BasicCommand("fclose", "<filename>") { + 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); if (ft != null) { - context.out.println("Closing file:" + name); + context.out.println("Closing file " + name); fileTargets.remove(name); ft.close(); + return 0; } else { - context.err.println("No file named: " + name + " open"); + context.err.println("Could not find the open file " + name); + return 1; } - return 0; } }); - handler.registerCommand("files", new BasicCommand("files", "") { + handler.registerCommand("files", new BasicCommand("list open files", "") { public int executeCommand(CommandContext context) { for (Iterator<FileTarget> iterator = fileTargets.values().iterator(); iterator.hasNext();) { FileTarget type = (FileTarget) iterator.next(); @@ -127,29 +126,37 @@ } }); - handler.registerCommand("speed", new BasicCommand("speed", "<factor>") { + handler.registerCommand("speed", new BasicCommand("set the speed factor for the CPU", "[factor]") { public int executeCommand(CommandContext context) { - double d = context.getArgumentAsDouble(0); MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); - if (cpu != null) { - if (d < 0.0) { - System.out.println("Rate needs to be larger than zero"); + if (cpu == null) { + context.err.println("could not access the CPU."); + return 1; + } else if (context.getArgumentCount() == 0) { + long rate = cpu.getSleepRate(); + double d = rate / 25000.0; + context.out.println("Speed factor is set to " + (((int)(d * 100 + 0.5)) / 100.0)); + } else { + double d = context.getArgumentAsDouble(0); + if (d > 0.0) { + long rate = (long) (25000 * d); + cpu.setSleepRate(rate); } else { - long rate = (long)(25000 * d); - cpu.setSleepRate(rate); + context.err.println("Speed factor must be larger than zero."); + return 1; } } return 0; } }); - - handler.registerCommand("exit", new BasicCommand("exit", "") { + + handler.registerCommand("quit", new BasicCommand("exit MSPSim", "") { public int executeCommand(CommandContext context) { System.exit(0); return 0; } }); - + handler.registerCommand("exec", new ExecCommand()); } Modified: mspsim/se/sics/mspsim/util/StatCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/StatCommands.java 2008-03-25 10:29:00 UTC (rev 210) +++ mspsim/se/sics/mspsim/util/StatCommands.java 2008-03-25 10:30:14 UTC (rev 211) @@ -62,23 +62,29 @@ @Override public void setupCommands(ComponentRegistry registry, CommandHandler handler) { - handler.registerCommand("chipinfo", new BasicCommand("shows information about specified chip", + handler.registerCommand("chipinfo", new BasicCommand("show information about specified chip", "[chips...]") { @Override public int executeCommand(CommandContext context) { if (context.getArgumentCount() > 0) { for (int i = 0, n = context.getArgumentCount(); i < n; i++) { - // TODO list chips + String chipName = context.getArgument(i); + Chip chip = statistics.getChip(chipName); + if (chip == null) { + context.out.println(" " + chipName + ": NOT FOUND"); + } else { + context.out.println(" " + chipName + ": " + chip); + } } - return 0; - } - Chip[] chips = statistics.getChips(); - if (chips == null) { - context.out.println("No chips found"); } else { - for (int i = 0, n = chips.length; i < n; i++) { - context.out.println(" " + chips[i].getName()); + Chip[] chips = statistics.getChips(); + if (chips == null) { + context.out.println("No chips found."); + } else { + for (int i = 0, n = chips.length; i < n; i++) { + context.out.println(" " + chips[i].getName()); + } } } return 0; @@ -86,7 +92,7 @@ }); - handler.registerCommand("duty", new BasicAsyncCommand("adds a duty cycle sampler for operating modes to the specified chips", + handler.registerCommand("duty", new BasicAsyncCommand("add a duty cycle sampler for operating modes to the specified chips", "<frequency> <chip> [chips...]") { private PrintStream out; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-25 10:29:04
|
Revision: 210 http://mspsim.svn.sourceforge.net/mspsim/?rev=210&view=rev Author: nifi Date: 2008-03-25 03:29:00 -0700 (Tue, 25 Mar 2008) Log Message: ----------- added lookup of chip by name Modified Paths: -------------- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-03-25 10:24:01 UTC (rev 209) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-03-25 10:29:00 UTC (rev 210) @@ -40,6 +40,7 @@ */ package se.sics.mspsim.util; +import java.io.PrintStream; import java.util.Arrays; import java.util.HashMap; @@ -63,6 +64,11 @@ this.cpu = cpu; } + public Chip getChip(String chipName) { + StatEntry entry = statistics.get(chipName); + return entry == null ? null : entry.chip; + } + public Chip[] getChips() { Chip[] chips = new Chip[statistics.size()]; int index = 0; @@ -76,13 +82,13 @@ StatEntry entry = new StatEntry(chip); statistics.put(chip.getName(), entry); } - - public void printStat() { + + public void printStat() { for (StatEntry entry : statistics.values()) { - entry.printStat(); + entry.printStat(System.out); } } - + public DataSource getDataSource(String chip, int mode) { return getDataSource(chip, mode, OP_NORMAL); } @@ -194,10 +200,10 @@ this.startTime = cpu.cycles; } - void printStat() { - System.out.println("Stat for: " + chip.getName()); + void printStat(PrintStream out) { + out.println("Stat for: " + chip.getName()); for (int i = 0; i < elapsed.length; i++) { - System.out.println("" + (i + 1) + " = " + elapsed[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...> - 2008-03-25 10:24:20
|
Revision: 209 http://mspsim.svn.sourceforge.net/mspsim/?rev=209&view=rev Author: nifi Date: 2008-03-25 03:24:01 -0700 (Tue, 25 Mar 2008) Log Message: ----------- added option to specify arguments to run targets Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2008-03-25 10:07:17 UTC (rev 208) +++ mspsim/Makefile 2008-03-25 10:24:01 UTC (rev 209) @@ -100,13 +100,13 @@ @echo "Usage: make [all,compile,clean,run,runsky,runesb]" run: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.util.IHexReader $(FIRMWAREFILE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.util.IHexReader $(ARGS) $(FIRMWAREFILE) $(MAPFILE) runesb: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ESBFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ARGS) $(ESBFIRMWARE) $(MAPFILE) runsky: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) test: cputest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-25 10:07:21
|
Revision: 208 http://mspsim.svn.sourceforge.net/mspsim/?rev=208&view=rev Author: nifi Date: 2008-03-25 03:07:17 -0700 (Tue, 25 Mar 2008) Log Message: ----------- added access method for sleep rate Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-03-25 10:04:01 UTC (rev 207) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-03-25 10:07:17 UTC (rev 208) @@ -288,8 +288,13 @@ public boolean isRunning() { return running; } - + + public long getSleepRate() { + return sleepRate; + } + public void setSleepRate(long rate) { sleepRate = rate; } -} \ No newline at end of file + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-25 10:04:20
|
Revision: 207 http://mspsim.svn.sourceforge.net/mspsim/?rev=207&view=rev Author: nifi Date: 2008-03-25 03:04:01 -0700 (Tue, 25 Mar 2008) Log Message: ----------- removed unused imports Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-03-20 16:01:11 UTC (rev 206) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-03-25 10:04:01 UTC (rev 207) @@ -1,35 +1,28 @@ package se.sics.mspsim.extutil.jfreechart; -import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; - import javax.swing.JFrame; 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.chart.renderer.xy.XYItemRenderer; import org.jfree.data.time.Millisecond; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; - -import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.ui.WindowUtils; import se.sics.mspsim.util.DataSource; -import se.sics.mspsim.util.OperatingModeStatistics; import se.sics.mspsim.util.StackMonitor; @SuppressWarnings("serial") public class DataChart extends JPanel { private TimeSeriesCollection dataset; - + public DataChart(String title, String yaxis) { DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis(yaxis); @@ -52,14 +45,14 @@ renderer.setSeriesShapesVisible(2, false); renderer.setSeriesShapesVisible(3, 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(title, + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); ChartPanel chartPanel = new ChartPanel(chart); setLayout(new BorderLayout()); @@ -70,7 +63,7 @@ public void addTimeSeries(TimeSeries ts) { dataset.addSeries(ts); } - + private JFrame openFrame(String name) { JFrame jw = new JFrame(name); jw.add(this); @@ -79,7 +72,7 @@ // jw.setBounds(100, 100, 400, 200); return jw; } - + public void setupStackFrame(MSP430 cpu) { JFrame jw = openFrame("Stack Monitor"); StackMonitor sm = new StackMonitor(cpu); @@ -94,7 +87,7 @@ dss.addDataSource(sm.getSource(), ts); jw.setVisible(true); } - + public DataSourceSampler setupChipFrame(MSP430 cpu) { JFrame jw = openFrame("Duty-Cycle Monitor"); DataSourceSampler dss = new DataSourceSampler(cpu); @@ -108,5 +101,5 @@ ts.setMaximumItemCount(200); addTimeSeries(ts); dss.addDataSource(src, ts); - } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-20 16:01:32
|
Revision: 206 http://mspsim.svn.sourceforge.net/mspsim/?rev=206&view=rev Author: joxe Date: 2008-03-20 09:01:11 -0700 (Thu, 20 Mar 2008) Log Message: ----------- fixed so that all events are removed when mspsim is reset Modified Paths: -------------- mspsim/se/sics/mspsim/core/EventQueue.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/EventQueue.java =================================================================== --- mspsim/se/sics/mspsim/core/EventQueue.java 2008-03-20 13:31:07 UTC (rev 205) +++ mspsim/se/sics/mspsim/core/EventQueue.java 2008-03-20 16:01:11 UTC (rev 206) @@ -140,6 +140,19 @@ return tmp; } + public void removeAll() { + TimeEvent t = first; + while(t != null) { + TimeEvent clr = t; + t = t.nextEvent; + clr.nextEvent = null; + clr.time = 0; + clr.scheduled = false; + } + first = null; + eventCount = 0; + } + public void print() { TimeEvent t = first; System.out.print("nxt: " + nextTime + " ["); Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-20 13:31:07 UTC (rev 205) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-20 16:01:11 UTC (rev 206) @@ -515,6 +515,10 @@ servicedInterrupt = -1; interruptMax = -1; writeRegister(SR, 0); + + cycleEventQueue.removeAll(); + vTimeEventQueue.removeAll(); + } // Indicate that we have an interrupt now! Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 13:31:07 UTC (rev 205) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 16:01:11 UTC (rev 206) @@ -131,12 +131,12 @@ public static final int CC_IE = 0x10; // Bit 4 public static final int CC_TRIGGER_INT = CC_IE | CC_IFG; - private long counterStart = 0; - private long nextTimerTrigger = 0; // Number of cycles passed since current counter value was set // useful for setting expected compare and capture times to correct time. // valid for timer A private int timerOverflow = 0x0a; + private long counterStart = 0; + private long nextTimerTrigger = 0; // Input map for timer A public static final int[] TIMER_Ax149 = new int[] { @@ -242,35 +242,44 @@ for (int i = 0, n = expCompare.length; i < n; i++) { expCompare[i] = -1; expCaptureTime[i] = -1; + expCapInterval[i] = 0; + outMode[i] = 0; + capMode[i] = 0; + inputSel[i] = 0; + inputSrc[i] = 0; + captureOn[i] = false; } for (int i = 0; i < tcctl.length; i++) { tcctl[i] = 0; tccr[i] = 0; } - + tctl = 0; + lastTIV = 0; interruptEnable = false; interruptPending = false; counter = 0; counterPassed = 0; + counterStart = 0; + clockSource = 0; + cyclesMultiplicator = 1; + mode = STOP; + nextTimerTrigger = 0; + inputDivider = 1; } // Should handle read of byte also (currently ignores that...) public int read(int address, boolean word, long cycles) { - - int val = memory[address]; - if (word) { - val |= memory[(address + 1) & 0xffff] << 8; - } - if (address == TAIV || address == TBIV) { // should clear registers for cause of interrupt (highest value)? // but what if a higher value have been triggered since this was // triggered??? -> does that matter??? // But this mess the TIV up too early...... // Must DELAY the reset of interrupt flags until next read...? + int val = lastTIV; resetTIV(); + return val; } - + int val = 0; int index = address - offset; switch(index) { case TR: @@ -312,6 +321,8 @@ i = (index - TCCR0) / 2; val = tccr[i]; break; + default: + System.out.println("Not supported read, returning zero!!!"); } if (DEBUG) { @@ -344,11 +355,6 @@ } 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/byte difference yet... assumes it gets // all 16 bits when called!!! @@ -579,7 +585,6 @@ } private void updateTimers(long cycles) { - if (cycles >= nextTimerTrigger) { interruptPending = true; // This should be updated whenever clockspeed changes... @@ -590,8 +595,7 @@ // But the timer does not need to be updated this often... // Do we need to update the counter here??? // System.out.println("Checking capture register [ioTick]: " + cycles); - for (int i = 0, n = noCompare; i < n; i++) { - // System.out.println("Checking: " + i); + for (int i = 0, n = noCompare; i < n; i++) { if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) { if (DEBUG) { System.out.println(getName() + " CAPTURE: " + i + @@ -684,7 +688,7 @@ // Trigger this! // This is handled by its own vector!!! if (trigger) { - lastTIV = memory[type == TIMER_A ? TAIV : TBIV] = 0; + lastTIV = 0; return; } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-20 13:31:27
|
Revision: 205 http://mspsim.svn.sourceforge.net/mspsim/?rev=205&view=rev Author: nifi Date: 2008-03-20 06:31:07 -0700 (Thu, 20 Mar 2008) Log Message: ----------- - added config and argument handling - added option 'nogui' for ESB and Sky platforms - fixed Sky platform to use filename based on firmware name to store flash file Modified Paths: -------------- mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Added Paths: ----------- mspsim/se/sics/mspsim/util/ArgumentManager.java mspsim/se/sics/mspsim/util/ConfigManager.java mspsim/se/sics/mspsim/util/PrefixConfigManager.java Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-03-20 12:49:27 UTC (rev 204) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-03-20 13:31:07 UTC (rev 205) @@ -47,7 +47,9 @@ import se.sics.mspsim.core.MSP430; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; import se.sics.mspsim.ui.ControlUI; +import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.ConfigManager; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; import se.sics.mspsim.util.MapTable; @@ -56,6 +58,8 @@ public abstract class GenericNode extends Chip implements Runnable { + protected ConfigManager config; + protected ComponentRegistry registry = new ComponentRegistry(); protected MSP430 cpu = new MSP430(0); protected String firmwareFile = null; @@ -64,12 +68,15 @@ public abstract void setupNode(); - public void setup(String[] args) throws IOException { + public void setup(ArgumentManager config) throws IOException { + String[] args = config.getArguments(); if (args.length == 0) { System.out.println("Usage: " + getClass().getName() + " <firmware>"); System.exit(1); } + this.config = config; + CommandHandler ch = new CommandHandler(); stats = new OperatingModeStatistics(cpu); @@ -101,13 +108,14 @@ cpu.reset(); setupNode(); - - // Setup control and other UI components - ControlUI control = new ControlUI(registry); - HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); + + if (!config.getPropertyAsBoolean("nogui", false)) { + // Setup control and other UI components + ControlUI control = new ControlUI(registry); + HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); // sourceViewer.addSearchPath(new File("../../contiki-2.x/examples/energest-demo/")); - control.setSourceViewer(sourceViewer); - + control.setSourceViewer(sourceViewer); + } if (args.length > 1) { MapTable map = new MapTable(args[1]); cpu.getDisAsm().setMap(map); @@ -119,9 +127,11 @@ public void run() { - System.out.println("Starting new CPU thread..."); - cpu.cpuloop(); - System.out.println("Stopping CPU thread..."); + if (!cpu.isRunning()) { + System.out.println("Starting new CPU thread..."); + cpu.cpuloop(); + System.out.println("Stopping CPU thread..."); + } } public void start() { if (!cpu.isRunning()) { Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-03-20 12:49:27 UTC (rev 204) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-03-20 13:31:07 UTC (rev 205) @@ -41,7 +41,6 @@ package se.sics.mspsim.platform.esb; import java.io.IOException; - import se.sics.mspsim.chip.TR1001; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; @@ -51,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.util.ArgumentManager; public class ESBNode extends GenericNode implements PortListener { @@ -167,18 +167,19 @@ public void setupNode() { setupNodePorts(); - gui = new ESBGui(this); + if (!config.getPropertyAsBoolean("nogui", false)) { + gui = new ESBGui(this); + // A HACK for some "graphs"!!! + DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); + DataSourceSampler dss = dataChart.setupChipFrame(cpu); + 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)); + } stats.addMonitor(this); stats.addMonitor(radio); stats.addMonitor(cpu); - - // A HACK for some "graphs"!!! - DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); - DataSourceSampler dss = dataChart.setupChipFrame(cpu); - 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)); } public int getModeMax() { @@ -191,7 +192,9 @@ public static void main(String[] args) throws IOException { ESBNode node = new ESBNode(); - node.setup(args); + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + node.setup(config); node.start(); } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-20 12:49:27 UTC (rev 204) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-20 13:31:07 UTC (rev 205) @@ -55,6 +55,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.util.ArgumentManager; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.OperatingModeStatistics; @@ -216,7 +217,7 @@ fileName = fileName + ".flash"; System.out.println("Using flash file: " + fileName); - this.flashFile = flashFile; + this.flashFile = fileName; setupNodePorts(); @@ -251,21 +252,25 @@ // } // }); - gui = new SkyGui(this); + if (!config.getPropertyAsBoolean("nogui", false)) { + gui = new SkyGui(this); - // A HACK for some "graphs"!!! - DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); - DataSourceSampler dss = dataChart.setupChipFrame(cpu); - dataChart.addDataSource(dss, "LEDS", stats.getDataSource("Tmote Sky", 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)); + // A HACK for some "graphs"!!! + DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); + DataSourceSampler dss = dataChart.setupChipFrame(cpu); + dataChart.addDataSource(dss, "LEDS", stats.getDataSource("Tmote Sky", 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)); + } } public static void main(String[] args) throws IOException { SkyNode node = new SkyNode(); - node.setup(args); + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + node.setup(config); node.start(); } Added: mspsim/se/sics/mspsim/util/ArgumentManager.java =================================================================== --- mspsim/se/sics/mspsim/util/ArgumentManager.java (rev 0) +++ mspsim/se/sics/mspsim/util/ArgumentManager.java 2008-03-20 13:31:07 UTC (rev 205) @@ -0,0 +1,114 @@ +/** + * Copyright (c) 2008, 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$ + * + * ----------------------------------------------------------------- + * + * ArgumentManager + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Tue Apr 08 22:08:32 2003 + * Updated : $Date$ + * $Revision$ + */ +package se.sics.mspsim.util; +import java.util.ArrayList; + +/** + */ +public class ArgumentManager extends ConfigManager { + + private String configName = "config"; + private String[] arguments; + private boolean isConfigLoaded; + + public ArgumentManager() { + } + + public ArgumentManager(ConfigManager parent) { + super(parent); + } + + public boolean isConfigLoaded() { + return isConfigLoaded; + } + + public String getConfigArgumentName() { + return configName; + } + + public void setConfigArgumentName(String configName) { + this.configName = configName; + } + + public String[] getArguments() { + return arguments; + } + + public void handleArguments(String[] args) { + ArrayList<String> list = new ArrayList<String>(); + ArrayList<String> config = new ArrayList<String>(); + for (int i = 0, n = args.length; i < n; i++) { + if (args[i].startsWith("-")) { + String param = args[i].substring(1); + String value = ""; + int index = param.indexOf('='); + if (index >= 0) { + if (index < param.length()) { + value = param.substring(index + 1); + } + param = param.substring(0, index); + } + if (param.length() == 0) { + throw new IllegalArgumentException("illegal argument: " + args[i]); + } + if (configName != null && configName.equals(param)) { + if (value.length() == 0) { + throw new IllegalArgumentException("no config file name specified"); + } + if (!loadConfiguration(value)) { + throw new IllegalArgumentException("failed to load configuration " + value); + } + isConfigLoaded = true; + } + config.add(param); + config.add(value.length() > 0 ? value : "true"); + } else { + // Normal argument + list.add(args[i]); + } + } + this.arguments = list.toArray(new String[list.size()]); + for (int i = 0, n = config.size(); i < n; i += 2) { + setProperty(config.get(i), config.get(i + 1)); + } + } + +} // ArgumentManager Property changes on: mspsim/se/sics/mspsim/util/ArgumentManager.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + LF Added: mspsim/se/sics/mspsim/util/ConfigManager.java =================================================================== --- mspsim/se/sics/mspsim/util/ConfigManager.java (rev 0) +++ mspsim/se/sics/mspsim/util/ConfigManager.java 2008-03-20 13:31:07 UTC (rev 205) @@ -0,0 +1,335 @@ +/** + * Copyright (c) 2008, 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$ + * + * ----------------------------------------------------------------- + * + * ConfigManager + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Fri Oct 11 15:24:14 2002 + * Updated : $Date$ + * $Revision$ + */ +package se.sics.mspsim.util; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.Properties; +import java.util.StringTokenizer; + +public class ConfigManager { + + protected final ConfigManager parent; + protected Properties properties = null; + + public ConfigManager() { + this(null); + } + + public ConfigManager(ConfigManager parent) { + this.parent = parent; + } + + + + // ------------------------------------------------------------------- + // Config file handling + // ------------------------------------------------------------------- + + protected String getBackupFile(String configFile) { + int index = configFile.lastIndexOf('.'); + if (index > 0 && index < configFile.length() - 1) { + return configFile.substring(0, index) + ".bak"; + } + return null; + } + + public boolean loadConfiguration(String configFile) { + return loadConfiguration(new File(configFile)); + } + + public boolean loadConfiguration(File configFile) { + try { + InputStream input = + new BufferedInputStream(new FileInputStream(configFile)); + try { + loadConfiguration(input); + } finally { + input.close(); + } + return true; + } catch (FileNotFoundException e) { + return false; + } catch (IOException e) { + throw new IllegalArgumentException("could not read config file '" + + configFile + "': " + e); + } + } + + public boolean loadConfiguration(URL configURL) { + try { + InputStream input = new BufferedInputStream(configURL.openStream()); + try { + loadConfiguration(input); + } finally { + input.close(); + } + return true; + } catch (FileNotFoundException e) { + return false; + } catch (IOException e) { + throw new IllegalArgumentException("could not read config file '" + + configURL + "': " + e); + } + } + + public void loadConfiguration(InputStream input) throws IOException { + Properties p = new Properties(); + p.load(input); + this.properties = p; + } + + public boolean saveConfiguration(File filename, String comments) { + if (properties != null) { + OutputStream output = null; + try { + output = new FileOutputStream(filename); + properties.store(output, comments); + return true; + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (output != null) { + try { + output.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + return false; + } + + + // ------------------------------------------------------------------- + // Properties handling + // ------------------------------------------------------------------- + + /** + * Returns the property names. Does not include inherited properties. + * + * @return an array with the non-inherited property names + */ + public String[] getPropertyNames() { + if (properties == null) { + return new String[0]; + } + synchronized (properties) { + return properties.keySet().toArray(new String[properties.size()]); + } + } + + public String getProperty(String name) { + return getProperty(name, null); + } + + public String getProperty(String name, String defaultValue) { + String value = (properties != null) + ? properties.getProperty(name) + : null; + + if (value == null || value.length() == 0) { + value = parent != null + ? parent.getProperty(name, defaultValue) + : defaultValue; + } + return value; + } + + public void setProperty(String name, String value) { + if (properties == null) { + synchronized (this) { + if (properties == null) { + properties = new Properties(); + } + } + } + + if (value == null) { + properties.remove(name); + } else { + properties.put(name, value); + } + } + + public String[] getPropertyAsArray(String name) { + return getPropertyAsArray(name, null); + } + + public String[] getPropertyAsArray(String name, String defaultValue) { + String valueList = getProperty(name, defaultValue); + if (valueList != null) { + StringTokenizer tok = new StringTokenizer(valueList, ", \t"); + int len = tok.countTokens(); + if (len > 0) { + String[] values = new String[len]; + for (int i = 0; i < len; i++) { + values[i] = tok.nextToken(); + } + return values; + } + } + return null; + } + + public int getPropertyAsInt(String name, int defaultValue) { + String value = getProperty(name, null); + return value != null ? parseInt(name, value, defaultValue) : defaultValue; + } + + public int[] getPropertyAsIntArray(String name) { + return getPropertyAsIntArray(name, null); + } + + public int[] getPropertyAsIntArray(String name, String defaultValue) { + String valueList = getProperty(name, defaultValue); + if (valueList != null) { + return parseIntArray(valueList, defaultValue); + } else if (defaultValue != null) { + return parseIntArray(defaultValue, null); + } else { + return null; + } + } + + private int[] parseIntArray(String valueList, String secondaryValue) { + StringTokenizer tok = new StringTokenizer(valueList, ", \t/"); + int len = tok.countTokens(); + if (len > 0) { + try { + int[] values = new int[len]; + for (int i = 0; i < len; i++) { + values[i] = Integer.parseInt(tok.nextToken()); + } + return values; + } catch (NumberFormatException e) { + // Ignore parse errors and try secondary value if specified and not already tried + } + } + if(secondaryValue != null && !secondaryValue.equals(valueList)) { + return parseIntArray(secondaryValue, null); + } + return null; + } + + public long getPropertyAsLong(String name, long defaultValue) { + String value = getProperty(name, null); + return value != null + ? parseLong(name, value, defaultValue) + : defaultValue; + } + + public float getPropertyAsFloat(String name, float defaultValue) { + String value = getProperty(name, null); + return value != null + ? parseFloat(name, value, defaultValue) + : defaultValue; + } + + public double getPropertyAsDouble(String name, double defaultValue) { + String value = getProperty(name, null); + return value != null + ? parseDouble(name, value, defaultValue) + : defaultValue; + } + + public boolean getPropertyAsBoolean(String name, boolean defaultValue) { + String value = getProperty(name, null); + return value != null + ? parseBoolean(name, value, defaultValue) + : defaultValue; + } + + protected int parseInt(String name, String value, int defaultValue) { + try { + return Integer.parseInt(value); + } catch (Exception e) { + System.err.println("config '" + name + "' has a non-integer value '" + + value + '\''); + } + return defaultValue; + } + + protected long parseLong(String name, String value, long defaultValue) { + try { + return Long.parseLong(value); + } catch (Exception e) { + System.err.println("config '" + name + "' has a non-long value '" + + value + '\''); + } + return defaultValue; + } + + protected float parseFloat(String name, String value, float defaultValue) { + try { + return Float.parseFloat(value); + } catch (Exception e) { + System.err.println("config '" + name + "' has a non-float value '" + + value + '\''); + } + return defaultValue; + } + + protected double parseDouble(String name, String value, + double defaultValue) { + try { + return Double.parseDouble(value); + } catch (Exception e) { + System.err.println("config '" + name + "' has a non-double value '" + + value + '\''); + } + return defaultValue; + } + + protected boolean parseBoolean(String name, String value, + boolean defaultValue) { + return "true".equals(value) || "yes".equals(value) || "1".equals(value); + } + +} // ConfigManager Property changes on: mspsim/se/sics/mspsim/util/ConfigManager.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + LF Added: mspsim/se/sics/mspsim/util/PrefixConfigManager.java =================================================================== --- mspsim/se/sics/mspsim/util/PrefixConfigManager.java (rev 0) +++ mspsim/se/sics/mspsim/util/PrefixConfigManager.java 2008-03-20 13:31:07 UTC (rev 205) @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2008, 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$ + * + * ----------------------------------------------------------------- + * + * PrefixConfigManager + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : Fri Oct 11 15:24:14 2002 + * Updated : $Date$ + * $Revision$ + */ +package se.sics.mspsim.util; + +/** + * + */ +public class PrefixConfigManager extends ConfigManager { + + private final ConfigManager config; + private final String shortPrefix; + private final String longPrefix; + + public PrefixConfigManager(ConfigManager config, String prefix, String name) { + this(config, prefix, name, '.'); + } + + public PrefixConfigManager(ConfigManager config, String prefix, + String name, char separator) { + if (config == null) { + throw new NullPointerException(); + } + this.config = config; + prefix = prefix != null && prefix.length() > 0 ? (prefix + separator) : null; + + if (name != null && name.length() > 0) { + this.longPrefix = prefix == null ? (name + separator) : (prefix + name + separator); + this.shortPrefix = prefix; + } else if (prefix != null) { + this.longPrefix = prefix; + this.shortPrefix = null; + } else { + this.longPrefix = ""; + this.shortPrefix = null; + } + } + + public String getProperty(String name, String defaultValue) { + String value = config.getProperty(longPrefix + name); + if (value != null) { + return value; + } + if (shortPrefix == null) { + return defaultValue; + } + return config.getProperty(shortPrefix + name, defaultValue); + } + + public void setProperty(String name, String value) { + config.setProperty(longPrefix + name, value); + } + +} Property changes on: mspsim/se/sics/mspsim/util/PrefixConfigManager.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-20 12:49:34
|
Revision: 204 http://mspsim.svn.sourceforge.net/mspsim/?rev=204&view=rev Author: joxe Date: 2008-03-20 05:49:27 -0700 (Thu, 20 Mar 2008) Log Message: ----------- fixed so that timer system performs reset when CPU is reset Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-03-20 10:44:01 UTC (rev 203) +++ mspsim/CHANGE_LOG.txt 2008-03-20 12:49:27 UTC (rev 204) @@ -1,4 +1,4 @@ -0.85 +0.90 Changes: - fixed multiplier to handle the different modes better. - refactored so that IOUnit is no longer a Chip @@ -11,6 +11,9 @@ - added watch on register, grep, and other commands in CLI - added redirect to files in CLI - added speed control API and CLI command (speed) +- 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 0.84 Changes: Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-20 10:44:01 UTC (rev 203) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-20 12:49:27 UTC (rev 204) @@ -50,7 +50,9 @@ import se.sics.mspsim.util.Utils; public class DebugCommands implements CommandBundle { - + private long lastCall = 0; + private long lastWall = 0; + public void setupCommands(ComponentRegistry registry, CommandHandler ch) { final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); final ELF elf = (ELF) registry.getComponent(ELF.class); @@ -230,14 +232,23 @@ return -1; } }); + ch.registerCommand("reset", new BasicCommand("resets the CPU", "") { + public int executeCommand(CommandContext context) { + cpu.reset(); + return 0; + } + }); + ch.registerCommand("time", new BasicCommand("prints the elapse time and cycles", "") { public int executeCommand(CommandContext context) { long time = ((long)(cpu.getTimeMillis())); - context.out.println("Emulated time elapsed: " + time + "(ms) cycles: " + cpu.cycles); + context.out.println("Emulated time elapsed: " + time + "(ms) since last: " + (time - lastCall) + " ms" + " wallTime: " + + (System.currentTimeMillis() - lastWall) + " ms"); + lastCall = time; + lastWall = System.currentTimeMillis(); return 0; } }); - } } } Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-20 10:44:01 UTC (rev 203) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-20 12:49:27 UTC (rev 204) @@ -143,6 +143,12 @@ } }); + handler.registerCommand("exit", new BasicCommand("exit", "") { + public int executeCommand(CommandContext context) { + System.exit(0); + return 0; + } + }); handler.registerCommand("exec", new ExecCommand()); } Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-03-20 10:44:01 UTC (rev 203) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-03-20 12:49:27 UTC (rev 204) @@ -43,7 +43,7 @@ public interface MSP430Constants { - public static final String VERSION = "0.85"; + public static final String VERSION = "0.90"; public static final int CLK_ACLK = 1; public static final int CLK_SMCLK = 2; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-20 10:44:01 UTC (rev 203) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-20 12:49:27 UTC (rev 204) @@ -506,6 +506,8 @@ public void reset() { resetIOUnits(); reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); + System.out.println("Reset the CPU: " + reg[PC]); + for (int i = 0, n = 16; i < n; i++) { interruptSource[i] = null; } Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 10:44:01 UTC (rev 203) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 12:49:27 UTC (rev 204) @@ -243,6 +243,15 @@ expCompare[i] = -1; expCaptureTime[i] = -1; } + for (int i = 0; i < tcctl.length; i++) { + tcctl[i] = 0; + tccr[i] = 0; + } + + interruptEnable = false; + interruptPending = false; + counter = 0; + counterPassed = 0; } // Should handle read of byte also (currently ignores that...) @@ -735,6 +744,7 @@ // Some flags should be cleared (the highest priority flags)? public void interruptServiced(int vector) { if (vector == ccr0Vector) { + // Reset the interrupt trigger in "core". core.flagInterrupt(ccr0Vector, this, false); // Remove the flag also... tcctl[0] &= ~CC_IFG; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-20 10:44:06
|
Revision: 203 http://mspsim.svn.sourceforge.net/mspsim/?rev=203&view=rev Author: joxe Date: 2008-03-20 03:44:01 -0700 (Thu, 20 Mar 2008) Log Message: ----------- fixed bug that made timer interrupt flag to stay flagged Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 08:38:31 UTC (rev 202) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 10:44:01 UTC (rev 203) @@ -736,6 +736,8 @@ public void interruptServiced(int vector) { if (vector == ccr0Vector) { core.flagInterrupt(ccr0Vector, this, false); + // Remove the flag also... + tcctl[0] &= ~CC_IFG; } if (MSP430Core.debugInterrupts) { System.out.println("interrupt Serviced..."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-20 08:38:45
|
Revision: 202 http://mspsim.svn.sourceforge.net/mspsim/?rev=202&view=rev Author: joxe Date: 2008-03-20 01:38:31 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Fixed timerbug - interrupt for CCR0 was never "cleared" when serviced. Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-19 17:42:13 UTC (rev 201) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-20 08:38:31 UTC (rev 202) @@ -196,16 +196,18 @@ private boolean interruptEnable = false; private boolean interruptPending = false; + private int ccr1Vector; + private int ccr0Vector; + private MSP430Core core; + private TimeEvent timerTrigger = new TimeEvent(0) { public void execute(long t) { -// System.out.println(getName() + " executing update timers at " + t); +// System.out.println(getName() + " **** executing update timers at " + t + " cycles=" + core.cycles); updateTimers(t); } }; - private MSP430Core core; - private int lastTIV; private int[] srcMap; @@ -213,6 +215,7 @@ * Creates a new <code>Timer</code> instance. * */ + public Timer(MSP430Core core, int[] srcMap, int[] memory, int offset) { super(memory, offset); this.srcMap = srcMap; @@ -228,6 +231,10 @@ type = TIMER_B; timerOverflow = 0x0e; } + + ccr0Vector = type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR; + ccr1Vector = type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR; + reset(); } @@ -259,6 +266,7 @@ switch(index) { case TR: val = updateCounter(cycles); +// System.out.println(getName() + " TR read => " + val); break; case TCTL: val = tctl; @@ -451,7 +459,12 @@ Utils.hex16(counter) + " diff: " + Utils.hex16(diff)); } // Use the counterPassed information to compensate the expected capture/compare time!!! - expCaptureTime[index] = cycles + (long)(cyclesMultiplicator * diff) - counterPassed; + expCaptureTime[index] = cycles + (long)(cyclesMultiplicator * diff) - counterPassed; +// if (counterPassed > 0) { +// System.out.println(getName() + " Comp: " + counterPassed + " cycl: " + cycles + " TR: " + +// counter + " CCR" + index + " = " + data + " diff = " + diff + " cycMul: " + cyclesMultiplicator + " expCyc: " + +// expCaptureTime[index]); +// } counterPassed = 0; if (DEBUG) { System.out.println(getName() + " Cycles: " + cycles + " expCap[" + index + "]: " + expCaptureTime[index] + " ctr:" + counter + @@ -620,12 +633,12 @@ private void calculateNextEventTime(long cycles) { long time = nextTimerTrigger; -// int smallest = -1; + int smallest = -1; for (int i = 0; i < expCaptureTime.length; i++) { long ct = expCaptureTime[i]; if (ct > 0 && ct < time) { time = ct; -// smallest = i; + smallest = i; } } @@ -657,8 +670,8 @@ // This only triggers interrupts - reading TIV clears!??! if (i == 0) { // Execute the interrupt vector... the high-pri one... - core.flagInterrupt(type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR, - this, trigger); +// System.out.println(getName() +">>>> Trigger IRQ for CCR0"); + core.flagInterrupt(ccr0Vector, this, trigger); // Trigger this! // This is handled by its own vector!!! if (trigger) { @@ -690,8 +703,8 @@ } } - core.flagInterrupt(type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR, - this, trigger); +// System.out.println(getName() +">>>> Trigger IRQ for CCR:" + tIndex); + core.flagInterrupt(ccr1Vector, this, trigger); } public String getSourceName(int source) { @@ -721,6 +734,9 @@ // The interrupt have been serviced... // Some flags should be cleared (the highest priority flags)? public void interruptServiced(int vector) { + if (vector == ccr0Vector) { + core.flagInterrupt(ccr0Vector, this, false); + } if (MSP430Core.debugInterrupts) { System.out.println("interrupt Serviced..."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-03-19 17:42:14
|
Revision: 201 http://mspsim.svn.sourceforge.net/mspsim/?rev=201&view=rev Author: fros4943 Date: 2008-03-19 10:42:13 -0700 (Wed, 19 Mar 2008) Log Message: ----------- added methods for reading all references source files as well as all executable addresses Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELFDebug.java Modified: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java 2008-03-19 17:38:19 UTC (rev 200) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2008-03-19 17:42:13 UTC (rev 201) @@ -38,7 +38,7 @@ */ package se.sics.mspsim.util; -import se.sics.mspsim.core.*; +import java.util.ArrayList; public class ELFDebug { @@ -61,7 +61,9 @@ int count = len / dbgStab.entSize; int addr = dbgStab.offset; - if (DEBUG) System.out.println("Number of stabs:" + count); + if (DEBUG) { + System.out.println("Number of stabs:" + count); + } stabs = new Stab[count]; for (int i = 0, n = count; i < n; i++) { elf.pos = addr; @@ -148,6 +150,109 @@ return null; } + public ArrayList<Integer> getExecutableAddresses() { + ArrayList<Integer> allAddresses = new ArrayList<Integer>(); + + int address = Integer.MAX_VALUE; + + String currentPath = null; + String currentFile = null; + String currentFunction = null; + int lastAddress = 0; + int currentLine = 0; + int currentLineAdr = 0; + for (Stab stab : stabs) { + switch(stab.type) { + case N_SO: + if (stab.value < address) { + if (stab.data != null && stab.data.endsWith("/")) { + currentPath = stab.data; + lastAddress = stab.value; + allAddresses.add(new Integer(lastAddress)); + currentFunction = null; + } else { + currentFile = stab.data; + lastAddress = stab.value; + allAddresses.add(new Integer(lastAddress)); + currentFunction = null; + } + } else { + /* requires sorted order of all file entries in stab section */ + if (DEBUG) { + System.out.println("FILE: Already passed address..." + + currentPath + " " + + currentFile + " " + currentFunction); + } + return allAddresses; + } + break; + case N_SLINE: + if (currentPath != null) { /* only files with path... */ + if (currentLineAdr < address) { + currentLine = stab.desc; + currentLineAdr = lastAddress + stab.value; + allAddresses.add(new Integer(currentLineAdr)); + /*if (currentLineAdr >= address) { + // Finished!!! + if (DEBUG) { + System.out.println("File: " + currentPath + " " + currentFile); + System.out.println("Function: " + currentFunction); + System.out.println("Line No: " + currentLine); + } + return new DebugInfo(currentLine, currentPath, currentFile, + currentFunction); + }*/ + } + } + break; + case N_FUN: + if (stab.value < address) { + currentFunction = stab.data; + lastAddress = stab.value; + allAddresses.add(new Integer(lastAddress)); + } else { + if (DEBUG) { + System.out.println("FUN: Already passed address..."); + } + return allAddresses; + } + break; + } + } + return allAddresses; +} + + public String[] getSourceFiles() { + String currentPath = null; + String currentFile = null; + ArrayList<String> sourceFiles = new ArrayList<String>(); + + for (Stab stab : stabs) { + if (stab.type == N_SO) { + if (stab.data != null && stab.data.endsWith("/")) { + currentPath = stab.data; + } else { + currentFile = stab.data; + + if (currentFile != null && !currentFile.isEmpty()) { + if (currentPath == null) { + sourceFiles.add(currentFile); + } else { + sourceFiles.add(currentPath + currentFile); + } + } + } + } + } + + String[] sourceFilesArray = new String[sourceFiles.size()]; + for (int i=0; i < sourceFilesArray.length; i++) { + sourceFilesArray[i] = sourceFiles.get(i); + } + + return sourceFilesArray; + } + private static class Stab { String data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-03-19 17:38:20
|
Revision: 200 http://mspsim.svn.sourceforge.net/mspsim/?rev=200&view=rev Author: fros4943 Date: 2008-03-19 10:38:19 -0700 (Wed, 19 Mar 2008) Log Message: ----------- added access to elf debug object + removed debugging output 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-03-19 15:32:18 UTC (rev 199) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-03-19 17:38:19 UTC (rev 200) @@ -200,8 +200,8 @@ public static void printBytes(String name, byte[] data) { System.out.print(name + " "); - for (int i = 0, n = data.length; i < n; i++) { - System.out.print("" + (char) data[i]); + for (byte element : data) { + System.out.print("" + (char) element); } System.out.println(""); } @@ -262,8 +262,10 @@ private void loadBytes(int[] memory, int offset, int addr, int len, int fill) { - System.out.println("Loading " + len + " bytes into " + - Integer.toString(addr, 16)); + if (DEBUG) { + System.out.println("Loading " + len + " bytes into " + + Integer.toString(addr, 16)); + } for (int i = 0, n = len; i < n; i++) { memory[addr++] = elfData[offset++] & 0xff; } @@ -274,6 +276,10 @@ } } + public ELFDebug getDebug() { + return debug; + } + public DebugInfo getDebugInfo(int adr) { return debug.getDebugInfo(adr); } @@ -287,7 +293,7 @@ } return null; } - + public MapTable getMap() { MapTable map = new MapTable(); @@ -313,8 +319,8 @@ if (type == ELFSection.SYMTYPE_NONE && sn != null){ if ("Letext".equals(sn)) { if (currentFile != null) { -// System.out.println("Found file addr for " + currentFile + " : 0x" + -// Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); +// System.out.println("Found file addr for " + currentFile + " : 0x" + +// Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); files.add(new FileInfo(currentFile, currentAddress, sAddr)); currentAddress = sAddr; } @@ -345,15 +351,19 @@ map.setStackStart(sAddr); } - + if (type == ELFSection.SYMTYPE_FUNCTION) { String file = lookupFile(sAddr); - if (file == null) file = currentFile; + if (file == null) { + file = currentFile; + } map.setEntry(new MapEntry(MapEntry.TYPE.function, sAddr, symbolName, file, bind == ELFSection.SYMBIND_LOCAL)); } else if (type == ELFSection.SYMTYPE_OBJECT) { String file = lookupFile(sAddr); - if (file == null) file = currentFile; + if (file == null) { + file = currentFile; + } map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, symbolName, file, bind == ELFSection.SYMBIND_LOCAL)); } else { @@ -379,7 +389,9 @@ input.close(); buf = null; byte[] data = baous.toByteArray(); - System.out.println("Length of data: " + data.length); + if (DEBUG) { + System.out.println("Length of data: " + data.length); + } ELF elf = new ELF(data); elf.readAll(); @@ -392,15 +404,21 @@ if (args.length < 2) { for (int i = 0, n = elf.shnum; i < n; i++) { - System.out.println("-- Section header " + i + " --\n" + elf.sections[i]); + if (DEBUG) { + System.out.println("-- Section header " + i + " --\n" + elf.sections[i]); + } if (".stab".equals(elf.sections[i].getSectionName()) || ".stabstr".equals(elf.sections[i].getSectionName())) { int adr = elf.sections[i].offset; - System.out.println(" == Section data =="); + if (DEBUG) { + System.out.println(" == Section data =="); + } for (int j = 0, m = 2000; j < m; j++) { - System.out.print((char) elf.elfData[adr++]); - if (i % 20 == 19) { - System.out.println(); + if (DEBUG) { + System.out.print((char) elf.elfData[adr++]); + if (i % 20 == 19) { + System.out.println(); + } } } } @@ -423,13 +441,13 @@ String name; int start; int end; - + FileInfo(String name, int start, int end) { this.name = name; this.start = start; this.end = end; } - + } - + } // ELF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-19 15:47:27
|
Revision: 199 http://mspsim.svn.sourceforge.net/mspsim/?rev=199&view=rev Author: nifi Date: 2008-03-19 08:32:18 -0700 (Wed, 19 Mar 2008) Log Message: ----------- only add search path if user approved file selection Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java Modified: mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java =================================================================== --- mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java 2008-03-18 16:06:23 UTC (rev 198) +++ mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java 2008-03-19 15:32:18 UTC (rev 199) @@ -125,10 +125,11 @@ } currentFile = filename; - setup(); SwingUtilities.invokeLater(new Runnable() { public void run() { try { + setup(); + File file = findSourceFile(path, filename); if (file != null) { FileReader reader = new FileReader(file); @@ -206,12 +207,16 @@ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle("Select compilation directory"); } - fileChooser.showOpenDialog(window); - File d = fileChooser.getSelectedFile(); - if (d != null) { - path.add(d); - return findSourceFile(fPath, filename); + if (!window.isVisible()) { + window.setVisible(true); } + if (fileChooser.showOpenDialog(window) == JFileChooser.APPROVE_OPTION) { + File d = fileChooser.getSelectedFile(); + if (d != null) { + path.add(d); + return findSourceFile(fPath, filename); + } + } return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-18 16:06:30
|
Revision: 198 http://mspsim.svn.sourceforge.net/mspsim/?rev=198&view=rev Author: joxe Date: 2008-03-18 09:06:23 -0700 (Tue, 18 Mar 2008) Log Message: ----------- fixed bug in the new eventsystem. Modified Paths: -------------- mspsim/se/sics/mspsim/core/EventQueue.java mspsim/se/sics/mspsim/core/Timer.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/core/EventQueue.java =================================================================== --- mspsim/se/sics/mspsim/core/EventQueue.java 2008-03-18 15:28:58 UTC (rev 197) +++ mspsim/se/sics/mspsim/core/EventQueue.java 2008-03-18 16:06:23 UTC (rev 198) @@ -59,7 +59,6 @@ if (event.scheduled) { removeEvent(event); } - eventCount++; if (first == null) { first = event; } else { @@ -86,6 +85,7 @@ nextTime = 0; } event.scheduled = true; + eventCount++; } // Not yet impl. @@ -136,6 +136,7 @@ nextTime = 0; } tmp.scheduled = false; + eventCount--; return tmp; } Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 15:28:58 UTC (rev 197) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 16:06:23 UTC (rev 198) @@ -131,13 +131,10 @@ public static final int CC_IE = 0x10; // Bit 4 public static final int CC_TRIGGER_INT = CC_IE | CC_IFG; - private long lastCycles = 0; private long counterStart = 0; private long nextTimerTrigger = 0; // Number of cycles passed since current counter value was set - // useful for setting timeEvents to correct time. - private int counterPassed = 0; - + // useful for setting expected compare and capture times to correct time. // valid for timer A private int timerOverflow = 0x0a; @@ -177,7 +174,7 @@ private int mode; private int counter = 0; - private int countDirection = 1; + private int counterPassed = 0; // The IO registers private int tctl; @@ -365,7 +362,6 @@ counter = 0; counterStart = cycles; // inputDivider = 1; ???? - countDirection = 1; } int newMode = (data >> 4) & 3; Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-18 15:28:58 UTC (rev 197) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-18 16:06:23 UTC (rev 198) @@ -224,14 +224,14 @@ stats.addMonitor(radio); stats.addMonitor(cpu); - cpu.scheduleCycleEvent(new TimeEvent(0) { - public void execute(long t) { - System.out.println("SkyNode: 1000000 cycles elapsed: " + t + " " + - SkyNode.this.cpu.getTimeMillis()); - // schedule at planned time + 1000000 - SkyNode.this.cpu.scheduleCycleEvent(this, time + 1000000); - } - }, 1000000); +// cpu.scheduleCycleEvent(new TimeEvent(0) { +// public void execute(long t) { +// System.out.println("SkyNode: 1000000 cycles elapsed: " + t + " " + +// SkyNode.this.cpu.getTimeMillis()); +// // schedule at planned time + 1000000 +// SkyNode.this.cpu.scheduleCycleEvent(this, time + 1000000); +// } +// }, 1000000); // TODO: remove this test... radio.setPacketListener(new PacketListener() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-18 15:29:03
|
Revision: 197 http://mspsim.svn.sourceforge.net/mspsim/?rev=197&view=rev Author: joxe Date: 2008-03-18 08:28:58 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Added compensation for timer counter system for less drift. Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java mspsim/tests/cputest.c Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 14:48:54 UTC (rev 196) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 15:28:58 UTC (rev 197) @@ -134,6 +134,9 @@ private long lastCycles = 0; private long counterStart = 0; private long nextTimerTrigger = 0; + // Number of cycles passed since current counter value was set + // useful for setting timeEvents to correct time. + private int counterPassed = 0; // valid for timer A private int timerOverflow = 0x0a; @@ -451,7 +454,9 @@ Utils.hex16(data) + " TR: " + Utils.hex16(counter) + " diff: " + Utils.hex16(diff)); } - expCaptureTime[index] = cycles + (long)(cyclesMultiplicator * diff); + // Use the counterPassed information to compensate the expected capture/compare time!!! + expCaptureTime[index] = cycles + (long)(cyclesMultiplicator * diff) - counterPassed; + counterPassed = 0; if (DEBUG) { System.out.println(getName() + " Cycles: " + cycles + " expCap[" + index + "]: " + expCaptureTime[index] + " ctr:" + counter + " data: " + data + " ~" + @@ -526,15 +531,17 @@ } divider = divider * inputDivider; long cycctr = cycles - counterStart; + double tick = cycctr / divider; + counterPassed = (int) (divider * (tick - (long) (tick))); switch (mode) { case CONTIN: - counter = ((int) (cycctr / divider)) & 0xffff; + counter = ((int) tick) & 0xffff; break; case UP: - counter = ((int) (cycctr / divider)) % tccr[0]; + counter = ((int) tick) % tccr[0]; break; case UPDWN: - counter = ((int) (cycctr / divider)) % (tccr[0] * 2); + counter = ((int) tick) % (tccr[0] * 2); if (counter > tccr[0]) { // Should back down to start again! counter = 2 * tccr[0] - counter; Modified: mspsim/tests/cputest.c =================================================================== --- mspsim/tests/cputest.c 2008-03-18 14:48:54 UTC (rev 196) +++ mspsim/tests/cputest.c 2008-03-18 15:28:58 UTC (rev 197) @@ -311,7 +311,7 @@ for (i = 0; i < pos; i++) { unsigned int t = 100 + i * 100; -/* printf("Trigg time %d => %u\n", i + 1, times[i]); */ + printf("Trigg time %d => %u\n", i + 1, times[i]); assertTrue(times[i] >= t && times[i] < t + 2); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-18 14:49:05
|
Revision: 196 http://mspsim.svn.sourceforge.net/mspsim/?rev=196&view=rev Author: joxe Date: 2008-03-18 07:48:54 -0700 (Tue, 18 Mar 2008) Log Message: ----------- setup test for timers. Modified Paths: -------------- mspsim/tests/cputest.c Modified: mspsim/tests/cputest.c =================================================================== --- mspsim/tests/cputest.c 2008-03-18 13:37:58 UTC (rev 195) +++ mspsim/tests/cputest.c 2008-03-18 14:48:54 UTC (rev 196) @@ -289,7 +289,7 @@ /* Select SMCLK (2.4576MHz), clear TAR; This makes the rtimer count the number of processor cycles executed by the CPU. */ //TBCTL = TBSSEL1 | TBCLR; - /* Select ACLK 32768Hz clock, divide by 1 (was ID_8 previously) */ + /* Select ACLK 32768Hz clock, divide by 1 (was ID_3 / 8 previously) */ TBCTL = TBSSEL0 | TBCLR | ID_0; /* CCR1 interrupt enabled, interrupt occurs when timer equals CCR1. */ @@ -305,11 +305,14 @@ eint(); while (pos < 10) { - printf("waiting for timer...%d\n", pos); + printf("."); } + printf("\n"); for (i = 0; i < pos; i++) { - printf("Trigg time %d => %ud\n", i + 1, times[i]); + unsigned int t = 100 + i * 100; +/* printf("Trigg time %d => %u\n", i + 1, times[i]); */ + assertTrue(times[i] >= t && times[i] < t + 2); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-18 13:38:04
|
Revision: 195 http://mspsim.svn.sourceforge.net/mspsim/?rev=195&view=rev Author: joxe Date: 2008-03-18 06:37:58 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Rewrote scheduling of timer system to be eventbased instead of "tick" based. Modified Paths: -------------- mspsim/se/sics/mspsim/core/EventQueue.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Timer.java mspsim/tests/cputest.c Modified: mspsim/se/sics/mspsim/core/EventQueue.java =================================================================== --- mspsim/se/sics/mspsim/core/EventQueue.java 2008-03-18 10:47:10 UTC (rev 194) +++ mspsim/se/sics/mspsim/core/EventQueue.java 2008-03-18 13:37:58 UTC (rev 195) @@ -45,6 +45,7 @@ private TimeEvent first; public long nextTime; + public int eventCount = 0; public EventQueue() { } @@ -58,6 +59,7 @@ if (event.scheduled) { removeEvent(event); } + eventCount++; if (first == null) { first = event; } else { @@ -116,6 +118,7 @@ // System.out.println("Removed =>"); // print(); event.scheduled = false; + eventCount--; return true; } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-18 10:47:10 UTC (rev 194) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-18 13:37:58 UTC (rev 195) @@ -52,7 +52,7 @@ // Try it out with 64 k memory public static final int MAX_MEM = 64*1024; - public static final int INTERNAL_IO_SIZE = 5; + public static final int INTERNAL_IO_SIZE = 3; public static final int PORTS = 6; public static final int MODE_ACTIVE = 0; @@ -131,12 +131,14 @@ // Ignore type for now... // Internal Active IOUnits + int passIO = 0; + int actIO = 0; ioUnits = new IOUnit[INTERNAL_IO_SIZE + 10]; ioCycles = new long[INTERNAL_IO_SIZE + 10]; // Passive IOUnits (no tick) - do we need to remember them??? // Maybe for debugging purposes... - passiveIOUnits = new IOUnit[PORTS]; + passiveIOUnits = new IOUnit[PORTS + 2]; Timer ta = new Timer(this, Timer.TIMER_Ax149, memory, 0x160); Timer tb = new Timer(this, Timer.TIMER_Bx149, memory, 0x180); @@ -168,15 +170,15 @@ memIn[i] = mp; } - ioUnits[0] = ta; - ioUnits[1] = tb; - ioUnits[2] = bcs; +// ioUnits[0] = ta; +// ioUnits[1] = tb; + ioUnits[actIO++] = bcs; USART usart0 = new USART(this, memory, 0x70); USART usart1 = new USART(this, memory, 0x78); - ioUnits[3] = usart0; - ioUnits[4] = usart1; + ioUnits[actIO++] = usart0; + ioUnits[actIO++] = usart1; for (int i = 0, n = 8; i < n; i++) { memOut[0x70 + i] = usart0; @@ -187,7 +189,7 @@ } ADC12 adc12 = new ADC12(this); - ioUnits[5] = adc12; + ioUnits[actIO++] = adc12; for (int i = 0, n = 16; i < n; i++) { memOut[0x80 + i] = adc12; @@ -228,6 +230,11 @@ memOut[0x32 + i * 4] = passiveIOUnits[i + 4]; memOut[0x33 + i * 4] = passiveIOUnits[i + 4]; } + passIO = 6; + + // Add the timers + passiveIOUnits[passIO++] = ta; + passiveIOUnits[passIO++] = tb; initIOUnit(); } @@ -378,30 +385,30 @@ private void executeEvents() { if (cycles >= nextVTimeEventCycles) { - if (vTimeEventQueue.nextTime == 0) { - nextVTimeEventCycles = cycles + 1000; + if (vTimeEventQueue.eventCount == 0) { + nextVTimeEventCycles = cycles + 10000; } else { TimeEvent te = vTimeEventQueue.popFirst(); long now = getTime(); te.execute(now); - if (vTimeEventQueue.nextTime > 0) { + if (vTimeEventQueue.eventCount > 0) { nextVTimeEventCycles = convertVTime(vTimeEventQueue.nextTime); } else { - nextVTimeEventCycles = cycles + 1000; + nextVTimeEventCycles = cycles + 10000; } } } if (cycles >= nextCycleEventCycles) { - if (cycleEventQueue.nextTime == 0) { - nextCycleEventCycles = cycles + 1000; + if (cycleEventQueue.eventCount == 0) { + nextCycleEventCycles = cycles + 10000; } else { TimeEvent te = cycleEventQueue.popFirst(); te.execute(cycles); - if (cycleEventQueue.nextTime > 0) { - nextEventCycles = cycleEventQueue.nextTime; + if (cycleEventQueue.eventCount > 0) { + nextCycleEventCycles = cycleEventQueue.nextTime; } else { - nextCycleEventCycles = cycles + 1000; + nextCycleEventCycles = cycles + 10000; } } } @@ -417,7 +424,7 @@ * @param time */ public void scheduleCycleEvent(TimeEvent event, long cycles) { - long currentNext = vTimeEventQueue.nextTime; + long currentNext = cycleEventQueue.nextTime; cycleEventQueue.addEvent(event, cycles); if (currentNext != cycleEventQueue.nextTime) { nextCycleEventCycles = cycleEventQueue.nextTime; @@ -425,7 +432,6 @@ nextEventCycles = nextCycleEventCycles; } } - } Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 10:47:10 UTC (rev 194) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 13:37:58 UTC (rev 195) @@ -197,7 +197,13 @@ private boolean interruptEnable = false; private boolean interruptPending = false; - + private TimeEvent timerTrigger = new TimeEvent(0) { + public void execute(long t) { +// System.out.println(getName() + " executing update timers at " + t); + updateTimers(t); + } + }; + private MSP430Core core; private int lastTIV; @@ -389,6 +395,7 @@ } updateCaptures(-1, cycles); + break; case TCCTL0: case TCCTL1: @@ -448,8 +455,10 @@ if (DEBUG) { System.out.println(getName() + " Cycles: " + cycles + " expCap[" + index + "]: " + expCaptureTime[index] + " ctr:" + counter + " data: " + data + " ~" + - (100 * (cyclesMultiplicator * diff * 1L) / 2500000) / 100.0 + " sec"); + (100 * (cyclesMultiplicator * diff * 1L) / 2500000) / 100.0 + " sec" + + "at cycles: " + expCaptureTime[index]); } + calculateNextEventTime(cycles); } } @@ -459,10 +468,8 @@ } private void updateCaptures(int index, long cycles) { - int low = 0; int hi = noCompare; if (index != -1) { - low = index; hi = index + 1; } @@ -476,12 +483,12 @@ } else if (clockSource == SRC_ACLK) { frqClk = core.aclkFrq / inputDivider; } - + // Handle the captures... if (captureOn[i]) { - if (inputSrc[i] == SRC_ACLK) { - divisor = core.aclkFrq; - } + if (inputSrc[i] == SRC_ACLK) { + divisor = core.aclkFrq; + } if (DEBUG) { System.out.println(getName() + " expCapInterval[" + i + "] frq = " + @@ -506,6 +513,7 @@ } } } + calculateNextEventTime(cycles); } private int updateCounter(long cycles) { @@ -539,10 +547,15 @@ return counter; } - // Simplest possible - just a call each 1000 cycles (which is wrong...) + // Simplest possible - just a call each 1000 cycles (which is wrong...) public long ioTick(long cycles) { + System.out.println(getName() + " UNEXPECTED CALL TO IOTICK ****"); + return 100000 + cycles; + } - if (cycles > nextTimerTrigger) { + private void updateTimers(long cycles) { + + if (cycles >= nextTimerTrigger) { interruptPending = true; // This should be updated whenever clockspeed changes... nextTimerTrigger = (long) (nextTimerTrigger + 0x10000 * cyclesMultiplicator); @@ -551,57 +564,83 @@ // This will not work very good... // But the timer does not need to be updated this often... // Do we need to update the counter here??? - // System.out.println("Checking capture register [ioTick]: " + cycles); + // System.out.println("Checking capture register [ioTick]: " + cycles); for (int i = 0, n = noCompare; i < n; i++) { // System.out.println("Checking: " + i); - if (expCaptureTime[i] != -1 && cycles > expCaptureTime[i]) { - if (DEBUG) { - System.out.println(getName() + " CAPTURE: " + i + - " Cycles: " + cycles + " expCap: " + - expCaptureTime[i] + - " => ExpCR: " + Utils.hex16(expCompare[i]) + - " TR: " + Utils.hex16(updateCounter(cycles))); - } - // Set the interrupt flag... - tcctl[i] |= CC_IFG; + if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) { + if (DEBUG) { + System.out.println(getName() + " CAPTURE: " + i + + " Cycles: " + cycles + " expCap: " + + expCaptureTime[i] + + " => ExpCR: " + Utils.hex16(expCompare[i]) + + " TR: " + Utils.hex16(updateCounter(cycles))); + } + // Set the interrupt flag... + tcctl[i] |= CC_IFG; - if (captureOn[i]) { - // Write the expected capture time to the register (counter could - // differ slightly) - tccr[i] = expCompare[i]; - // Update capture times... for next capture - expCompare[i] = (expCompare[i] + expCapInterval[i]) & 0xffff; - expCaptureTime[i] += expCapInterval[i] * cyclesMultiplicator; - if (DEBUG) { - System.out.println(getName() + - " setting expCaptureTime to next capture: " + - expCaptureTime[i]); - } - } else { - // Update expected compare time for this compare/cap reg. - // 0x10000 cycles... e.g. a full 16 bits wrap of the timer - expCaptureTime[i] = expCaptureTime[i] + - (long) (0x10000 * cyclesMultiplicator); - if (DEBUG) { - System.out.println(getName() + - " setting expCaptureTime to full wrap: " + - expCaptureTime[i]); - } - } + if (captureOn[i]) { + // Write the expected capture time to the register (counter could + // differ slightly) + tccr[i] = expCompare[i]; + // Update capture times... for next capture + expCompare[i] = (expCompare[i] + expCapInterval[i]) & 0xffff; + expCaptureTime[i] += expCapInterval[i] * cyclesMultiplicator; + if (DEBUG) { + System.out.println(getName() + + " setting expCaptureTime to next capture: " + + expCaptureTime[i]); + } + } else { + // Update expected compare time for this compare/cap reg. + // 0x10000 cycles... e.g. a full 16 bits wrap of the timer + expCaptureTime[i] = expCaptureTime[i] + + (long) (0x10000 * cyclesMultiplicator); + if (DEBUG) { + System.out.println(getName() + + " setting expCaptureTime to full wrap: " + + expCaptureTime[i]); + } + } - if (DEBUG) { - System.out.println("Wrote to: " + - Utils.hex16(offset + TCCTL0 + i * 2 + 1)); - } + if (DEBUG) { + System.out.println("Wrote to: " + + Utils.hex16(offset + TCCTL0 + i * 2 + 1)); + } } } + // Trigger interrupts that are up for triggering! triggerInterrupts(); - - return 1000 + cycles; + calculateNextEventTime(cycles); } - + + private void calculateNextEventTime(long cycles) { + long time = nextTimerTrigger; +// int smallest = -1; + for (int i = 0; i < expCaptureTime.length; i++) { + long ct = expCaptureTime[i]; + if (ct > 0 && ct < time) { + time = ct; +// smallest = i; + } + } + + if (time == 0) { + time = cycles + 1000; + } + + if (!timerTrigger.scheduled) { +// System.out.println(getName() + " new trigger (nothing sch) ..." + time + " re:" + +// smallest + " => " + (smallest > 0 ? expCaptureTime[smallest] + " > " + expCompare[smallest]: +// nextTimerTrigger) + " C:"+ cycles); + core.scheduleCycleEvent(timerTrigger, time); + } else if (timerTrigger.time > time) { +// System.out.println(getName() + " new trigger (new time)..." + time + " C:"+ cycles); + core.scheduleCycleEvent(timerTrigger, time); + } + } + // Can be called to generate any interrupt... public void triggerInterrupts() { // First check if any capture register is generating an interrupt... Modified: mspsim/tests/cputest.c =================================================================== --- mspsim/tests/cputest.c 2008-03-18 10:47:10 UTC (rev 194) +++ mspsim/tests/cputest.c 2008-03-18 13:37:58 UTC (rev 195) @@ -73,7 +73,7 @@ static int pos = 0; static unsigned int times[10]; interrupt(TIMERB1_VECTOR) timerb1 (void) { - if(TBIV == 2) { + if (TBIV == 2) { if (pos < 10) { times[pos] = TBR; pos++; @@ -309,7 +309,7 @@ } for (i = 0; i < pos; i++) { - printf("Trigg time %d => %d\n", i + 1, times[i]); + printf("Trigg time %d => %ud\n", i + 1, times[i]); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-18 10:47:12
|
Revision: 194 http://mspsim.svn.sourceforge.net/mspsim/?rev=194&view=rev Author: joxe Date: 2008-03-18 03:47:10 -0700 (Tue, 18 Mar 2008) Log Message: ----------- added cycle-based eventqueue. Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Timer.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/tests/Makefile mspsim/tests/cputest.c Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-17 22:54:11 UTC (rev 193) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-18 10:47:10 UTC (rev 194) @@ -124,6 +124,9 @@ private EventQueue vTimeEventQueue = new EventQueue(); private long nextVTimeEventCycles; + private EventQueue cycleEventQueue = new EventQueue(); + private long nextCycleEventCycles; + public MSP430Core(int type) { // Ignore type for now... @@ -376,25 +379,55 @@ private void executeEvents() { if (cycles >= nextVTimeEventCycles) { if (vTimeEventQueue.nextTime == 0) { - nextEventCycles = cycles + 1000; - return; + nextVTimeEventCycles = cycles + 1000; + } else { + TimeEvent te = vTimeEventQueue.popFirst(); + long now = getTime(); + te.execute(now); + if (vTimeEventQueue.nextTime > 0) { + nextVTimeEventCycles = convertVTime(vTimeEventQueue.nextTime); + } else { + nextVTimeEventCycles = cycles + 1000; + } } - TimeEvent te = vTimeEventQueue.popFirst(); - long now = getTime(); - te.execute(now); - if (vTimeEventQueue.nextTime > 0) { - nextVTimeEventCycles = convertVTime(vTimeEventQueue.nextTime); - nextEventCycles = nextVTimeEventCycles; + } + + if (cycles >= nextCycleEventCycles) { + if (cycleEventQueue.nextTime == 0) { + nextCycleEventCycles = cycles + 1000; + } else { + TimeEvent te = cycleEventQueue.popFirst(); + te.execute(cycles); + if (cycleEventQueue.nextTime > 0) { + nextEventCycles = cycleEventQueue.nextTime; + } else { + nextCycleEventCycles = cycles + 1000; + } } - } else { - // Allow 1000 cycles to pass if nothing to do... - nextEventCycles = cycles + 1000; } + + // Pick the one with shortest time in the future. + nextEventCycles = nextCycleEventCycles < nextVTimeEventCycles ? + nextCycleEventCycles : nextVTimeEventCycles; } -// public void scheduleCycleEvent(long cycles, TimeEvent event) { -// } + /** + * Schedules a new Time event using the cycles counter + * @param event + * @param time + */ + public void scheduleCycleEvent(TimeEvent event, long cycles) { + long currentNext = vTimeEventQueue.nextTime; + cycleEventQueue.addEvent(event, cycles); + if (currentNext != cycleEventQueue.nextTime) { + nextCycleEventCycles = cycleEventQueue.nextTime; + if (nextEventCycles > nextCycleEventCycles) { + nextEventCycles = nextCycleEventCycles; + } + } + } + /** * Schedules a new Time event using the virtual time clock @@ -407,8 +440,10 @@ if (currentNext != vTimeEventQueue.nextTime) { // This is only valid when not having a cycle event queue also... // if we have it needs to be checked also! - nextVTimeEventCycles = nextEventCycles = - convertVTime(vTimeEventQueue.nextTime); + nextVTimeEventCycles = convertVTime(vTimeEventQueue.nextTime); + if (nextEventCycles > nextVTimeEventCycles) { + nextEventCycles = nextVTimeEventCycles; + } } } Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-03-17 22:54:11 UTC (rev 193) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-03-18 10:47:10 UTC (rev 194) @@ -599,8 +599,6 @@ // Trigger interrupts that are up for triggering! triggerInterrupts(); - -// System.out.println("Writer: timer ctr = " + Utils.hex16(counter)); return 1000 + cycles; } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-17 22:54:11 UTC (rev 193) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-18 10:47:10 UTC (rev 194) @@ -49,6 +49,7 @@ 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; @@ -223,12 +224,14 @@ stats.addMonitor(radio); stats.addMonitor(cpu); -// cpu.scheduleTimeEventMillis(new TimeEvent(0) { -// public void execute(long t) { -// System.out.println("SkyNode: a second elapsed (wall time): " + t + " millis: " + SkyNode.this.cpu.getTimeMillis()); -// SkyNode.this.cpu.scheduleTimeEventMillis(this, 1000.0); -// } -// }, 1000.0); + cpu.scheduleCycleEvent(new TimeEvent(0) { + public void execute(long t) { + System.out.println("SkyNode: 1000000 cycles elapsed: " + t + " " + + SkyNode.this.cpu.getTimeMillis()); + // schedule at planned time + 1000000 + SkyNode.this.cpu.scheduleCycleEvent(this, time + 1000000); + } + }, 1000000); // TODO: remove this test... radio.setPacketListener(new PacketListener() { Modified: mspsim/tests/Makefile =================================================================== --- mspsim/tests/Makefile 2008-03-17 22:54:11 UTC (rev 193) +++ mspsim/tests/Makefile 2008-03-18 10:47:10 UTC (rev 194) @@ -10,7 +10,8 @@ .SUFFIXES: -MCU=msp430x149 +#MCU=msp430x149 +MCU=msp430x1611 ### Compiler definitions CC = msp430-gcc Modified: mspsim/tests/cputest.c =================================================================== --- mspsim/tests/cputest.c 2008-03-17 22:54:11 UTC (rev 193) +++ mspsim/tests/cputest.c 2008-03-18 10:47:10 UTC (rev 194) @@ -41,6 +41,7 @@ #include <signal.h> #include <stdio.h> #include <string.h> +#include <io.h> /* From Adams test-suite */ #define TEST(...) if(__VA_ARGS__) { \ @@ -68,6 +69,20 @@ static int caseID = 0; +/*---------------------------------------------------------------------------*/ +static int pos = 0; +static unsigned int times[10]; +interrupt(TIMERB1_VECTOR) timerb1 (void) { + if(TBIV == 2) { + if (pos < 10) { + times[pos] = TBR; + pos++; + TBCCR1 = TBCCR1 + 100; + } + } +} +/*---------------------------------------------------------------------------*/ + static void initTest() { caseID = 0; } @@ -267,6 +282,37 @@ printf("output finished...\n"); } +static void testTimer() { + int i; + pos = 0; + dint(); + /* Select SMCLK (2.4576MHz), clear TAR; This makes the rtimer count + the number of processor cycles executed by the CPU. */ + //TBCTL = TBSSEL1 | TBCLR; + /* Select ACLK 32768Hz clock, divide by 1 (was ID_8 previously) */ + TBCTL = TBSSEL0 | TBCLR | ID_0; + + /* CCR1 interrupt enabled, interrupt occurs when timer equals CCR1. */ + TBCCTL1 = CCIE; + + /* Start Timer_B in continuous mode. */ + TBCTL |= MC1; + + TBR = 0; + TBCCR1 = 100; + + /* Enable interrupts. */ + eint(); + + while (pos < 10) { + printf("waiting for timer...%d\n", pos); + } + + for (i = 0; i < pos; i++) { + printf("Trigg time %d => %d\n", i + 1, times[i]); + } +} + /*--------------------------------------------------------------------------*/ int @@ -284,6 +330,7 @@ testFunctions(); testModulo(); testUSART(); + testTimer(); /* printf("PROFILE\n"); */ printf("EXIT\n"); return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-17 22:54:23
|
Revision: 193 http://mspsim.svn.sourceforge.net/mspsim/?rev=193&view=rev Author: nifi Date: 2008-03-17 15:54:11 -0700 (Mon, 17 Mar 2008) Log Message: ----------- added parsing of redirect commands Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandParser.java Modified: mspsim/se/sics/mspsim/cli/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandParser.java 2008-03-17 21:12:47 UTC (rev 192) +++ mspsim/se/sics/mspsim/cli/CommandParser.java 2008-03-17 22:54:11 UTC (rev 193) @@ -53,6 +53,8 @@ ArrayList<String[]> list = new ArrayList<String[]>(); ArrayList<String> args = new ArrayList<String>(); StringBuilder sb = null; + String redirectCommand = null; + int redirectFile = -1; int state = TEXT; int index = 0; char quote = 0; @@ -103,7 +105,7 @@ } } else { // Start new quote - if (state != TEXT) { + if (state == ARG) { if (sb == null) { args.add(line.substring(index, i)); } else { @@ -116,6 +118,37 @@ quote = c; } break; + case '#': + if (state == TEXT && redirectCommand != null && redirectFile == args.size()) { + redirectCommand += '#'; + } else if (state != QUOTE) { + throw new IllegalArgumentException("illegal character '#'"); + } + break; + case '>': + if (state != QUOTE) { + // Redirection + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + state = TEXT; + } + + if (redirectCommand == null) { + redirectCommand = ">"; + redirectFile = args.size(); + } else if (state == TEXT && redirectFile == args.size()) { + redirectCommand += '>'; + } else { + // Double redirect + throw new IllegalArgumentException("redirected twice"); + } + } + break; case '|': if (state != QUOTE) { // PIPE @@ -131,6 +164,9 @@ if (args.size() == 0) { throw new IllegalArgumentException("empty command"); } + if (redirectCommand != null) { + throw new IllegalArgumentException("pipe can not follow redirection"); + } list.add(args.toArray(new String[args.size()])); args.clear(); } @@ -154,9 +190,19 @@ args.add(sb.append(line.substring(index)).toString()); } } + String redirectFilename = null; + if (redirectCommand != null) { + if (args.size() <= redirectFile) { + throw new IllegalArgumentException("no redirect target"); + } + redirectFilename = args.remove(redirectFile); + } if (args.size() > 0) { list.add(args.toArray(new String[args.size()])); } + if (redirectCommand != null) { + list.add(new String[] { redirectCommand, redirectFilename }); + } return list.toArray(new String[list.size()][]); } @@ -164,7 +210,7 @@ // StringBuilder sb = new StringBuilder(); // for (int i = 0, n = args.length; i < n; i++) { // if (i > 0) sb.append(' '); -// sb.append(args[0]); +// sb.append(args[i]); // } // String[][] list = parseLine(sb.toString()); // for (int j = 0, m = list.length; j < m; j++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-17 21:12:49
|
Revision: 192 http://mspsim.svn.sourceforge.net/mspsim/?rev=192&view=rev Author: joxe Date: 2008-03-17 14:12:47 -0700 (Mon, 17 Mar 2008) Log Message: ----------- added speed control API Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-03-17 21:02:40 UTC (rev 191) +++ mspsim/CHANGE_LOG.txt 2008-03-17 21:12:47 UTC (rev 192) @@ -6,8 +6,11 @@ - implemented better support for statistics (operating mode) - fixed interrupt handling bugs in IOUnit - added API for accessing frequency/channel and output power in CC2420 +- added RSSI support for CC2420 - refactored radio emulation code of ESB platform into a separate TR1001 class - added watch on register, grep, and other commands in CLI +- added redirect to files in CLI +- added speed control API and CLI command (speed) 0.84 Changes: Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-03-17 21:02:40 UTC (rev 191) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-03-17 21:12:47 UTC (rev 192) @@ -50,6 +50,7 @@ private boolean debug = false; private boolean running = false; + private long sleepRate = 50000; // Debug time - measure cycles private long lastCycles = 0; @@ -137,7 +138,9 @@ Thread.sleep(10); } catch (Exception e) { } - nextSleep = cycles + 50000; + // Frequency = 100 * cycles ratio + // Ratio = Frq / 100 + nextSleep = cycles + sleepRate; } // if ((instruction & 0xff80) == CALL) { @@ -285,4 +288,8 @@ public boolean isRunning() { return running; } -} + + public void setSleepRate(long rate) { + sleepRate = rate; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-17 21:02:41
|
Revision: 191 http://mspsim.svn.sourceforge.net/mspsim/?rev=191&view=rev Author: joxe Date: 2008-03-17 14:02:40 -0700 (Mon, 17 Mar 2008) Log Message: ----------- added emulation speed control. 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-03-17 20:39:35 UTC (rev 190) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-17 21:02:40 UTC (rev 191) @@ -47,6 +47,7 @@ import java.util.Iterator; import java.util.regex.Pattern; +import se.sics.mspsim.core.MSP430; import se.sics.mspsim.util.ComponentRegistry; /** @@ -56,7 +57,7 @@ public class MiscCommands implements CommandBundle { Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); - public void setupCommands(ComponentRegistry registry, CommandHandler handler) { + public void setupCommands(final ComponentRegistry registry, CommandHandler handler) { handler.registerCommand("grep", new BasicLineCommand("grep", "<regexp>") { private PrintStream out; private Pattern pattern; @@ -118,7 +119,7 @@ handler.registerCommand("files", new BasicCommand("files", "") { public int executeCommand(CommandContext context) { - for (Iterator iterator = fileTargets.values().iterator(); iterator.hasNext();) { + for (Iterator<FileTarget> iterator = fileTargets.values().iterator(); iterator.hasNext();) { FileTarget type = (FileTarget) iterator.next(); context.out.println(type.getName()); } @@ -126,7 +127,23 @@ } }); + handler.registerCommand("speed", new BasicCommand("speed", "<factor>") { + public int executeCommand(CommandContext context) { + double d = context.getArgumentAsDouble(0); + MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); + if (cpu != null) { + if (d < 0.0) { + System.out.println("Rate needs to be larger than zero"); + } else { + long rate = (long)(25000 * d); + cpu.setSleepRate(rate); + } + } + return 0; + } + }); + handler.registerCommand("exec", new ExecCommand()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-17 20:39:58
|
Revision: 190 http://mspsim.svn.sourceforge.net/mspsim/?rev=190&view=rev Author: joxe Date: 2008-03-17 13:39:35 -0700 (Mon, 17 Mar 2008) Log Message: ----------- added files command to list all open files, and better file handling. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/FileTarget.java mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/FileTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileTarget.java 2008-03-17 20:07:00 UTC (rev 189) +++ mspsim/se/sics/mspsim/cli/FileTarget.java 2008-03-17 20:39:35 UTC (rev 190) @@ -50,10 +50,16 @@ public class FileTarget implements LineListener { FileWriter out; + String name; + public FileTarget(String name) throws IOException { out = new FileWriter(name); + this.name = name; } + public String getName() { + return name; + } /* (non-Javadoc) * @see se.sics.mspsim.cli.LineListener#lineRead(java.lang.String) */ Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-17 20:07:00 UTC (rev 189) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-17 20:39:35 UTC (rev 190) @@ -41,8 +41,10 @@ package se.sics.mspsim.cli; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.PrintStream; import java.util.Hashtable; +import java.util.Iterator; import java.util.regex.Pattern; import se.sics.mspsim.util.ComponentRegistry; @@ -74,16 +76,17 @@ // TODO: this should also be "registered" as a "sink". // probably this should be handled using ">" instead! - handler.registerCommand("file", new BasicLineCommand("file", "<filename>") { + handler.registerCommand(">", new BasicLineCommand(">", "<filename>") { FileTarget ft; public int executeCommand(CommandContext context) { String fileName = context.getArgument(0); ft = fileTargets.get(fileName); if (ft == null) { try { + System.out.println("Creating new file target: " + fileName); ft = new FileTarget(fileName); fileTargets.put(fileName, ft); - } catch (FileNotFoundException e) { + } catch (IOException e) { e.printStackTrace(); } } @@ -103,12 +106,26 @@ String name = context.getArgument(0); FileTarget ft = fileTargets.get(name); if (ft != null) { + context.out.println("Closing file:" + name); + fileTargets.remove(name); ft.close(); + } else { + context.err.println("No file named: " + name + " open"); } return 0; } }); + handler.registerCommand("files", new BasicCommand("files", "") { + public int executeCommand(CommandContext context) { + for (Iterator iterator = fileTargets.values().iterator(); iterator.hasNext();) { + FileTarget type = (FileTarget) iterator.next(); + context.out.println(type.getName()); + } + return 0; + } + }); + handler.registerCommand("exec", new ExecCommand()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-17 20:07:03
|
Revision: 189 http://mspsim.svn.sourceforge.net/mspsim/?rev=189&view=rev Author: joxe Date: 2008-03-17 13:07:00 -0700 (Mon, 17 Mar 2008) Log Message: ----------- changed to FileWriter. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/FileTarget.java Modified: mspsim/se/sics/mspsim/cli/FileTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileTarget.java 2008-03-17 19:35:27 UTC (rev 188) +++ mspsim/se/sics/mspsim/cli/FileTarget.java 2008-03-17 20:07:00 UTC (rev 189) @@ -40,9 +40,7 @@ */ package se.sics.mspsim.cli; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; +import java.io.FileWriter; import java.io.IOException; /** @@ -51,10 +49,9 @@ */ public class FileTarget implements LineListener { - - FileOutputStream out; - public FileTarget(String name) throws FileNotFoundException { - out = new FileOutputStream(name); + FileWriter out; + public FileTarget(String name) throws IOException { + out = new FileWriter(name); } /* (non-Javadoc) @@ -70,7 +67,7 @@ } } else { try { - out.write((line + "\n").getBytes()); + out.write(line + "\n"); } 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-03-17 19:35:29
|
Revision: 188 http://mspsim.svn.sourceforge.net/mspsim/?rev=188&view=rev Author: joxe Date: 2008-03-17 12:35:27 -0700 (Mon, 17 Mar 2008) Log Message: ----------- added filetarget. Added Paths: ----------- mspsim/se/sics/mspsim/cli/FileTarget.java Added: mspsim/se/sics/mspsim/cli/FileTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileTarget.java (rev 0) +++ mspsim/se/sics/mspsim/cli/FileTarget.java 2008-03-17 19:35:27 UTC (rev 188) @@ -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: $ + * + * ----------------------------------------------------------------- + * + * FileTarget + * + * Author : Joakim Eriksson + * Created : 14 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * @author joakim + * + */ +public class FileTarget implements LineListener { + + + FileOutputStream out; + public FileTarget(String name) throws FileNotFoundException { + out = new FileOutputStream(name); + } + + /* (non-Javadoc) + * @see se.sics.mspsim.cli.LineListener#lineRead(java.lang.String) + */ + @Override + public void lineRead(String line) { + if (line == null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + try { + out.write((line + "\n").getBytes()); + } catch (IOException e) { + e.printStackTrace(); + }; + } + } + + public void close() { + try { + out.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-17 19:34:27
|
Revision: 187 http://mspsim.svn.sourceforge.net/mspsim/?rev=187&view=rev Author: joxe Date: 2008-03-17 12:34:12 -0700 (Mon, 17 Mar 2008) Log Message: ----------- fixed kill command and cleanup after exit Modified Paths: -------------- mspsim/se/sics/mspsim/chip/PacketListener.java mspsim/se/sics/mspsim/cli/AsyncCommand.java mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java mspsim/se/sics/mspsim/cli/BasicLineCommand.java mspsim/se/sics/mspsim/cli/CommandContext.java mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/ExecCommand.java mspsim/se/sics/mspsim/cli/LineListener.java mspsim/se/sics/mspsim/cli/LineOutputStream.java mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/OperatingModeListener.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java Modified: mspsim/se/sics/mspsim/chip/PacketListener.java =================================================================== --- mspsim/se/sics/mspsim/chip/PacketListener.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/chip/PacketListener.java 2008-03-17 19:34:12 UTC (rev 187) @@ -27,7 +27,7 @@ * * This file is part of MSPSim. * - * $Id:$ + * $Id$ * * ----------------------------------------------------------------- * Modified: mspsim/se/sics/mspsim/cli/AsyncCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/AsyncCommand.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/AsyncCommand.java 2008-03-17 19:34:12 UTC (rev 187) @@ -36,8 +36,8 @@ * * Author : Joakim Eriksson * Created : 9 mar 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; Modified: mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 9 mar 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; Modified: mspsim/se/sics/mspsim/cli/BasicLineCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/BasicLineCommand.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/BasicLineCommand.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 9 mar 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; Modified: mspsim/se/sics/mspsim/cli/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-17 19:34:12 UTC (rev 187) @@ -10,24 +10,27 @@ private String commandLine; private MapTable mapTable; private int pid = -1; + private boolean exited = false; private Command command; public PrintStream out; public PrintStream err; + private CommandHandler commandHandler; - public CommandContext(MapTable table, String commandLine, String[] args, + public CommandContext(CommandHandler ch, MapTable table, String commandLine, String[] args, int pid, Command command, PrintStream out, PrintStream err) { - this(table, commandLine, args, pid, command); + this(ch, table, commandLine, args, pid, command); setOutput(out, err); } - public CommandContext(MapTable table, String commandLine, String[] args, + public CommandContext(CommandHandler ch,MapTable table, String commandLine, String[] args, int pid, Command command) { this.commandLine = commandLine; this.args = args; this.pid = pid; this.mapTable = table; this.command = command; + this.commandHandler = ch; } void setOutput(PrintStream out, PrintStream err) { @@ -47,13 +50,18 @@ return pid; } + public boolean hasExited() { + return exited; + } + /** * exit needs to be called as soon as the command is completed (or stopped). * @param exitCode - the exit code of the command */ public void exit(int exitCode) { // TODO: Clean up can be done now! - pid = -1; + exited = true; + commandHandler.exit(this, exitCode, pid); } public MapTable getMapTable() { Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-17 19:34:12 UTC (rev 187) @@ -85,7 +85,7 @@ if (i == 0 && cmd instanceof AsyncCommand) { pid = ++pidCounter; } - commands[i] = new CommandContext(mapTable, line, args, pid, cmd); + commands[i] = new CommandContext(this, mapTable, line, args, pid, cmd); if (i > 0) { PrintStream po = new PrintStream(new LineOutputStream((LineListener) commands[i].getCommand())); commands[i - 1].setOutput(po, err); @@ -249,17 +249,35 @@ registerCommand("kill", new BasicCommand("kill a currently executing command", "<process>") { public int executeCommand(CommandContext context) { int pid = context.getArgumentAsInt(0); - for (int i = 0; i < currentAsyncCommands.size(); i++) { - CommandContext[] contexts = currentAsyncCommands.get(i); - CommandContext cmd = contexts[0]; - if (pid == cmd.getPID()) { - context.out.println("Should kill: " + cmd.getCommandName()); - break; - } - } + removePid(pid); return 0; } }); } + public void exit(CommandContext commandContext, int exitCode, int pid) { + if (pid >= 0) { + removePid(pid); + } + } + + private void removePid(int pid) { + System.out.println("Removing pid: " + pid); + for (int i = 0; i < currentAsyncCommands.size(); i++) { + CommandContext[] contexts = currentAsyncCommands.get(i); + CommandContext cmd = contexts[0]; + if (pid == cmd.getPID()) { + for (int j = 0; j < contexts.length; j++) { + Command command = contexts[i].getCommand(); + // Stop any commands that have not yet been stopped... + if (command instanceof AsyncCommand && !contexts[i].hasExited()) { + AsyncCommand ac = (AsyncCommand) command; + ac.stopCommand(contexts[i]); + } + } + currentAsyncCommands.remove(contexts); + break; + } + } + } } Modified: mspsim/se/sics/mspsim/cli/ExecCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/ExecCommand.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/ExecCommand.java 2008-03-17 19:34:12 UTC (rev 187) @@ -33,8 +33,8 @@ * * Author : Joakim Eriksson, Niclas Finne * Created : Sun Mar 09 23:15:36 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; import java.io.BufferedReader; Modified: mspsim/se/sics/mspsim/cli/LineListener.java =================================================================== --- mspsim/se/sics/mspsim/cli/LineListener.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/LineListener.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 8 mar 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; Modified: mspsim/se/sics/mspsim/cli/LineOutputStream.java =================================================================== --- mspsim/se/sics/mspsim/cli/LineOutputStream.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/LineOutputStream.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 8 mar 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,12 +35,14 @@ * * Author : Joakim Eriksson * Created : 9 mar 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.cli; +import java.io.FileNotFoundException; import java.io.PrintStream; +import java.util.Hashtable; import java.util.regex.Pattern; import se.sics.mspsim.util.ComponentRegistry; @@ -50,6 +52,7 @@ * */ public class MiscCommands implements CommandBundle { + Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); public void setupCommands(ComponentRegistry registry, CommandHandler handler) { handler.registerCommand("grep", new BasicLineCommand("grep", "<regexp>") { @@ -69,6 +72,44 @@ } }); + // TODO: this should also be "registered" as a "sink". + // probably this should be handled using ">" instead! + handler.registerCommand("file", new BasicLineCommand("file", "<filename>") { + FileTarget ft; + public int executeCommand(CommandContext context) { + String fileName = context.getArgument(0); + ft = fileTargets.get(fileName); + if (ft == null) { + try { + ft = new FileTarget(fileName); + fileTargets.put(fileName, ft); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + return 0; + } + public void lineRead(String line) { + ft.lineRead(line); + } + public void stopCommand(CommandContext context) { + // Should this do anything? + // Probably depending on the ft's config + } + }); + + handler.registerCommand("fclose", new BasicCommand("fclose", "<filename>") { + public int executeCommand(CommandContext context) { + String name = context.getArgument(0); + FileTarget ft = fileTargets.get(name); + if (ft != null) { + ft.close(); + } + return 0; + } + }); + + handler.registerCommand("exec", new ExecCommand()); } Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/core/Chip.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 17 jan 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.core; import java.util.ArrayList; Modified: mspsim/se/sics/mspsim/core/OperatingModeListener.java =================================================================== --- mspsim/se/sics/mspsim/core/OperatingModeListener.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/core/OperatingModeListener.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 17 jan 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.core; Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-03-17 09:46:42 UTC (rev 186) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-03-17 19:34:12 UTC (rev 187) @@ -35,8 +35,8 @@ * * Author : Joakim Eriksson * Created : 17 jan 2008 - * Updated : $Date:$ - * $Revision:$ + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.util; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |