From: <jo...@us...> - 2008-03-31 18:12:12
|
Revision: 216 http://mspsim.svn.sourceforge.net/mspsim/?rev=216&view=rev Author: joxe Date: 2008-03-31 11:12:04 -0700 (Mon, 31 Mar 2008) Log Message: ----------- added simple connection between mspsim nodes (not yet working) Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/ui/SerialMon.java Added Paths: ----------- mspsim/se/sics/mspsim/util/NetworkConnection.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-03-31 18:11:13 UTC (rev 215) +++ mspsim/CHANGE_LOG.txt 2008-03-31 18:12:04 UTC (rev 216) @@ -14,6 +14,7 @@ - added event system for cycle based events - fixed timer (A/B) to be event driven instead of tick driven - fixed bugs in interrupt handling of timer system +- added argument management and -nogui parameter 0.84 Changes: Modified: mspsim/se/sics/mspsim/ui/SerialMon.java =================================================================== --- mspsim/se/sics/mspsim/ui/SerialMon.java 2008-03-31 18:11:13 UTC (rev 215) +++ mspsim/se/sics/mspsim/ui/SerialMon.java 2008-03-31 18:12:04 UTC (rev 216) @@ -55,7 +55,7 @@ public class SerialMon implements KeyListener, USARTListener { private static final String PREFIX = " > "; - + private static final int MAX_LINES = 200; private String name; private JFrame window; private USART usart; @@ -97,7 +97,7 @@ public void dataReceived(USART source, int data) { if (data == '\n') { - if (lines >= 60) { + if (lines >= MAX_LINES) { int index = text.indexOf('\n'); text = text.substring(index + 1); } else { Added: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java (rev 0) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-03-31 18:12:04 UTC (rev 216) @@ -0,0 +1,210 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * NetworkConnection + * + * Author : Joakim Eriksson + * Created : 31 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.util; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.ArrayList; + +import se.sics.mspsim.chip.PacketListener; + +/** + * @author joakim + * + */ +public class NetworkConnection implements Runnable { + + private final static int DEFAULT_PORT = 4711; + ServerSocket serverSocket = null; + + ArrayList<ConnectionThread> connections = new ArrayList<ConnectionThread>(); + + private PacketListener listener; + + public NetworkConnection() { + if (connect(DEFAULT_PORT)) { + System.out.println("Connected to network..."); + } else { + setupServer(DEFAULT_PORT); + System.out.println("Setup network server..."); + } + } + + // TODO: this should handle several listeners!!! + public void addPacketListener(PacketListener pl) { + listener = pl; + } + + private void setupServer(int port) { + try { + serverSocket = new ServerSocket(port); + System.out.println("setup of server socket finished... "); + new Thread(this).start(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void run() { + System.out.println("Accepting new connections..."); + while (true) { + try { + Socket s = serverSocket.accept(); + System.out.println("New connection accepted..."); + connections.add(new ConnectionThread(s)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + // Data incoming from the network!!! + private void dataReceived(byte[] data, int len) { + int[] buf = new int[len]; + if (listener != null) { + for (int i = 0; i < buf.length; i++) { + buf[i] = data[i]; + } + // Send this data to the transmitter + listener.transmissionStarted(); + listener.transmissionEnded(buf); + } + + if (serverSocket != null) { + dataSent(buf); + } + } + + + byte[] buf = new byte[256]; + + // Data was sent from the radio in the node (or other node) and should + // be sent out to other nodes!!! + public void dataSent(int[] data) { + for (int i = 0; i < data.length; i++) { + buf[i] = (byte) data[i]; + } + ConnectionThread[] cthr = connections.toArray(new ConnectionThread[connections.size()]); + for (int i = 0; i < cthr.length; i++) { + if (cthr[i].isClosed()) { + connections.remove(cthr); + } else { + try { + cthr[i].output.write(buf); + } catch (IOException e) { + e.printStackTrace(); + cthr[i].close(); + } + } + } + } + + private boolean connect(int port) { + try { + Socket socket = new Socket("127.0.0.1", port); + connections.add(new ConnectionThread(socket)); + } catch (UnknownHostException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return false; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return false; + } + return true; + } + + class ConnectionThread implements Runnable { + byte[] buffer = new byte[256]; + + Socket socket; + DataInputStream input; + OutputStream output; + + public ConnectionThread(Socket socket) throws IOException { + this.socket = socket; + input = new DataInputStream(socket.getInputStream()); + output = socket.getOutputStream(); + new Thread(this).start(); + } + + public void close() { + try { + input.close(); + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + } + + public boolean isClosed() { + return socket == null; + } + + @Override + public void run() { + System.out.println("Started connection thread..."); + while (socket != null) { + int len; + try { + len = input.read(); + if (len > 0) { + input.readFully(buffer, 0, len); + System.out.println("Read packet with " + len + " bytes"); + dataReceived(buffer, len); + } + } catch (IOException e) { + e.printStackTrace(); + socket = null; + } + } + } + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-04-22 07:24:11
|
Revision: 248 http://mspsim.svn.sourceforge.net/mspsim/?rev=248&view=rev Author: joxe Date: 2008-04-22 00:23:45 -0700 (Tue, 22 Apr 2008) Log Message: ----------- Added Paths: ----------- mspsim/scripts/ mspsim/scripts/duty.sc Added: mspsim/scripts/duty.sc =================================================================== --- mspsim/scripts/duty.sc (rev 0) +++ mspsim/scripts/duty.sc 2008-04-22 07:23:45 UTC (rev 248) @@ -0,0 +1,8 @@ +echo "#!type line" >#duty +duty 10 "MSP430 Core.active" CC2420.listen CC2420.transmit "Tmote Sky.0" >#duty +echo "#!" +echo "#!set 0 label CPU" >#duty +echo "#!set 1 label Listen" >#duty +echo "#!set 2 label Transmit" >#duty +echo "#!set 3 label LEDS" >#duty +echo "#!title Duty Cycle" >#duty \ No newline at end of file Property changes on: mspsim/scripts/duty.sc ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-05-07 16:52:41
|
Revision: 271 http://mspsim.svn.sourceforge.net/mspsim/?rev=271&view=rev Author: nifi Date: 2008-05-07 09:52:26 -0700 (Wed, 07 May 2008) Log Message: ----------- Eclipse Added Paths: ----------- mspsim/.settings/ mspsim/.settings/org.eclipse.jdt.ui.prefs Added: mspsim/.settings/org.eclipse.jdt.ui.prefs =================================================================== --- mspsim/.settings/org.eclipse.jdt.ui.prefs (rev 0) +++ mspsim/.settings/org.eclipse.jdt.ui.prefs 2008-05-07 16:52:26 UTC (rev 271) @@ -0,0 +1,50 @@ +#Wed May 07 17:48:50 CEST 2008 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.format_source_code=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-06-02 10:38:35
|
Revision: 286 http://mspsim.svn.sourceforge.net/mspsim/?rev=286&view=rev Author: joxe Date: 2008-06-02 03:38:12 -0700 (Mon, 02 Jun 2008) Log Message: ----------- bufix on instruction addressing Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-05-15 19:22:06 UTC (rev 285) +++ mspsim/CHANGE_LOG.txt 2008-06-02 10:38:12 UTC (rev 286) @@ -13,6 +13,8 @@ - added support for file based scripts to the CLI - added configuration system - added connectivity between multiple running mspsim's +- bugfix in instruction emulation thanks to Matt Thompson + (addressing mode - autoincrement byte wrong on PC). 0.90 Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-05-15 19:22:06 UTC (rev 285) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-06-02 10:38:12 UTC (rev 286) @@ -52,6 +52,7 @@ // Try it out with 64 k memory public static final int MAX_MEM = 64*1024; + public static final int MAX_MEM_IO = 0x200; public static final int INTERNAL_IO_SIZE = 3; public static final int PORTS = 6; @@ -73,9 +74,9 @@ // Most HW needs only notify write and clocking, others need also read... // For notify write... - public IOUnit[] memOut = new IOUnit[MAX_MEM]; + public IOUnit[] memOut = new IOUnit[MAX_MEM_IO]; // For notify read... -> which will happen before actual read! - public IOUnit[] memIn = new IOUnit[MAX_MEM]; + public IOUnit[] memIn = new IOUnit[MAX_MEM_IO]; private IOUnit[] ioUnits; private IOUnit[] passiveIOUnits; @@ -86,7 +87,7 @@ private int lastIOUnitPos = INTERNAL_IO_SIZE; - // From the possible interrupt sources - to be able to indicate iserviced. + // From the possible interrupt sources - to be able to indicate is serviced. private IOUnit interruptSource[] = new IOUnit[16]; private int interruptMax = -1; @@ -613,10 +614,11 @@ breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); } - if (memOut[dstAddress] != null) { + if (dstAddress <= 0x200 && memOut[dstAddress] != null) { if (!word) dst &= 0xff; memOut[dstAddress].write(dstAddress, dst, word, cycles); } else { + // TODO: add check for Flash / RAM! memory[dstAddress] = dst & 0xff; if (word) { memory[dstAddress + 1] = (dst >> 8) & 0xff; @@ -797,12 +799,26 @@ dstAddress = readRegister(dstRegister); cycles += 3; break; - case AM_IND_AUTOINC: - dstAddress = readRegister(dstRegister); - writeRegister(dstRegister, dstAddress + (word ? 2 : 1)); - cycles += 3; - break; + // Bugfix suggested by Matt Thompson + case AM_IND_AUTOINC: + if(dstRegister == PC) { + dstAddress = readRegister(PC); + pc += 2; + writeRegister(PC, pc); + cycles += 5; + } else { + dstAddress = readRegister(dstRegister); + writeRegister(dstRegister, dstAddress + (word ? 2 : 1)); + cycles += 3; + } + break; } +// case AM_IND_AUTOINC: +// dstAddress = readRegister(dstRegister); +// writeRegister(dstRegister, dstAddress + (word ? 2 : 1)); +// cycles += 3; +// break; +// } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |