LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Wed Jan 24 20:36:34 CET 2007
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/07/01 24:20:36

    Added: jop/java/target/src/common/ejip/jtcpip/test
    TestConnectSingleThread.java
    TestListenRtThread.java TestListenSingleThread.java
    Log:
    move from ejip2 to ejip


    Revision Changes Path
    1.1 jop/java/target/src/common/ejip/jtcpip/test/TestConnectSingleThread.java

    http://www.opencores.org/cvsweb.shtml/jop/java/target/src/common/ejip/jtcpip/test/TestConnectSingleThread.java?rev=1.1&content-type=text/x-cvsweb-markup

    Index: TestConnectSingleThread.java
    ===================================================================
    /*
    * Copyright (c) 2006-2007 Graz University of Technology. 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. The names "Graz University of Technology" and "IAIK of Graz University of
    * Technology" must not be used to endorse or promote products derived from
    * this software without prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED 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 LICENSOR 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.
    */

    package ejip.jtcpip.test;

    import java.io.IOException;

    import util.Dbg;
    import ejip.CS8900;
    import ejip.LinkLayer;
    import ejip.Net;
    import ejip.jtcpip.JtcpipException;
    import ejip.jtcpip.NwLoopThread;
    import ejip.jtcpip.TCP;
    import ejip.jtcpip.TCPConnection;


    /**
    * Single Thread version of active TcpIp protocol.
    * jop is connecting to a server
    *
    * @author Nelson Langkamp
    */

    public class TestConnectSingleThread {
    static Net net;

    static LinkLayer ipLink;

    static NwLoopThread nwlt;

    static TCPConnection conn = null;

    public static void main(String[] args) {

    // init. stuff
    Dbg.initSerWait();
    int[] eth = {0x00, 0x05, 0x02, 0x03, 0x04, 0x07};
    ipLink = CS8900.init(eth , (192 << 24) + (168 << 16) + (0 << 8) + 123);
    Net.linkLayer = ipLink;
    nwlt = NwLoopThread.createInstance(ipLink);
    ejip.jtcpip.UDPConnection.init();
    ejip.jtcpip.TCPConnection.init();
    ejip.jtcpip.Payload.init();
    ejip.jtcpip.TCPOutputStream.init();
    ejip.jtcpip.util.NumFunctions.init();
    ejip.jtcpip.IP.init();
    ejip.Arp.init();

    TCPConnection tmp = null;
    short port = 4444;

    try {
    tmp = TCP.connect("129.168.0.5", port); // send syn flag
    } catch (JtcpipException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    for (;;) { if (tmp.getState() == TCPConnection.STATE_ESTABLISHED) { Dbg.wr("writing"); try { tmp.oStream.write("Hello World\n".getBytes()); } catch (NullPointerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } nwlt.run(); // "NwLoopThread" ipLink.loop(); // "CS8900 Thread" } } } 1.1 jop/java/target/src/common/ejip/jtcpip/test/TestListenRtThread.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/common/ejip/jtcpip/test/TestListenRtThread.java?rev=1.1&content-type=text/x-cvsweb-markup Index: TestListenRtThread.java =================================================================== /* * Copyright (c) 2006-2007 Graz University of Technology. 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. The names "Graz University of Technology" and "IAIK of Graz University of * Technology" must not be used to endorse or promote products derived from * this software without prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED 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 LICENSOR 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. */ package ejip.jtcpip.test; /** * Test passive TcpIP with RtThreads * * @author Nelson Langkamp */ import java.io.IOException; import ejip.CS8900; import ejip.LinkLayer; import ejip.Net; import ejip.jtcpip.NwLoopRtThread; import ejip.jtcpip.TCP; import ejip.jtcpip.TCPConnection; import joprt.RtThread; import util.Dbg; import util.Timer; public class TestListenRtThread { static Net net; static LinkLayer ipLink; static RtThread nwlt; static TCPConnection conn = null; public static void main(String[] args) { Dbg.initSerWait(); // initialize jop to use ip and mac int[] eth = {0x00, 0x05, 0x02, 0x03, 0x04, 0x07}; ipLink = CS8900.init(eth , (192 << 24) + (168 << 16) + (0 << 8) + 123); Net.linkLayer = ipLink; nwlt = NwLoopRtThread.createInstance(ipLink); ejip.jtcpip.UDPConnection.init(); ejip.jtcpip.TCPConnection.init(); ejip.jtcpip.Payload.init(); ejip.jtcpip.TCPOutputStream.init(); ejip.jtcpip.util.NumFunctions.init(); ejip.jtcpip.IP.init(); ejip.Arp.init(); ListenThread listenThread = new ListenThread(8, 10000); // // new RtThread(9, 5000) { // public void run() { // for (;;) { // waitForNextPeriod(); // nwlt.run(); // } // } // }; new RtThread(10, 2500) { public void run() { for (;;) { waitForNextPeriod(); ipLink.loop(); } } }; RtThread.startMission(); // forever(); } private static void forever() { // // just do the WD blink with lowest priority // => if the other threads take to long (*3) there will be a reset // for (;;) { for (int i = 0; i < 10; ++i) { RtThread.sleepMs(50); Timer.wd(); /*- int val = Native.rd(Const.IO_IN); Native.wr(val, Const.IO_LED); */ Timer.loop(); } Timer.wd(); } } } class ListenThread extends RtThread { public ListenThread(int prio, int us) { super(prio, us); // TODO Auto-generated constructor stub } public void run() { TCPConnection conn = null; short port = 44; // while is to be able to open up another connection // after previous was closed while (true) { // TODO: only one connection for now conn = TCP.listen(port, this); // do something for (;;) { // do echo int tmp = 0; while ((tmp = conn.iStream.read()) != -1) { Dbg.wr("input: "); Dbg.wr((char) tmp); Dbg.wr('\n'); // do Echo try { conn.oStream.write(tmp); } catch (IOException e) { e.printStackTrace(); } } if (conn.getState() == TCPConnection.STATE_CLOSE_WAIT || conn.getState() == TCPConnection.STATE_CLOSED) { conn = null; break; } waitForNextPeriod(); } } } } 1.1 jop/java/target/src/common/ejip/jtcpip/test/TestListenSingleThread.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/common/ejip/jtcpip/test/TestListenSingleThread.java?rev=1.1&content-type=text/x-cvsweb-markup Index: TestListenSingleThread.java =================================================================== /* * Copyright (c) 2006-2007 Graz University of Technology. 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. The names "Graz University of Technology" and "IAIK of Graz University of * Technology" must not be used to endorse or promote products derived from * this software without prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED 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 LICENSOR 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. */ package ejip.jtcpip.test; /** * Single Thread version of passive TcpIp. jop is listening for connections * * @author Nelson Langkamp */ import java.io.IOException; import util.Dbg; import ejip.CS8900; import ejip.LinkLayer; import ejip.Net; import ejip.jtcpip.NwLoopThread; import ejip.jtcpip.TCP; import ejip.jtcpip.TCPConnection; public class TestListenSingleThread { static Net net; static LinkLayer ipLink; static NwLoopThread nwlt; static TCPConnection conn = null; public static void main(String[] args) { // init stuff Dbg.initSerWait(); Dbg.wr("Main2"); int[] eth = {0x00, 0x05, 0x02, 0x03, 0x04, 0x07}; ipLink = CS8900.init(eth , (192 << 24) + (168 << 16) + (0 << 8) + 123); Net.linkLayer = ipLink; nwlt = NwLoopThread.createInstance(ipLink); ejip.jtcpip.UDPConnection.init(); ejip.jtcpip.TCPConnection.init(); ejip.jtcpip.Payload.init(); ejip.jtcpip.TCPOutputStream.init(); ejip.jtcpip.util.NumFunctions.init(); ejip.jtcpip.IP.init(); ejip.Arp.init(); boolean once = true; // only write once short port = 44; // FIXME: newConnection sets state to closed?! TCPConnection conn = TCPConnection.newConnection(port); conn.setState(TCPConnection.STATE_LISTEN); if (conn == null) { Dbg.wr("Error Main2: Could not init Connection\n"); return; } for (;;) { if (conn.getState() == TCPConnection.STATE_CLOSED) { conn = TCPConnection.newConnection(port); conn.setState(TCPConnection.STATE_LISTEN); } // TODO: why does the connection go to state close wait? if (conn.getState() == TCPConnection.STATE_CLOSE_WAIT) { conn.close(); conn = TCPConnection.newConnection(port); conn.setState(TCPConnection.STATE_LISTEN); } // reading from input stream int tmp = 0; while ((tmp = conn.iStream.read()) != -1) { Dbg.wr("input: "); Dbg.wr((char) tmp); Dbg.wr('\n'); // do Echo try { conn.oStream.write(tmp); } catch (IOException e) { e.printStackTrace(); } } if (conn.getState() == TCPConnection.STATE_ESTABLISHED) { if (once) { try { conn.oStream.write(104); conn.oStream.write(97); conn.oStream.write(108); conn.oStream.write(108); conn.oStream.write(111); conn.oStream.write(32); conn.oStream.write(119); conn.oStream.write(101); conn.oStream.write(108); conn.oStream.write(116); } catch (IOException e) { e.printStackTrace(); } once = false; } } // if (tmp == null) { // tmp = TCP.listen(port, conn); // if (tmp != null) { // Dbg.wr("CONNECTION\n"); // Dbg.wr("reading\n"); // my_byte = tmp.iStream.read(); // if (my_byte != -1) { // Dbg.wr((char) my_byte); // } // } else { // Dbg.wr("reading\n"); // my_byte = tmp.iStream.read(); // if (my_byte != -1) { // Dbg.wr((char) my_byte); // // } // } // } nwlt.run(); ipLink.loop(); } } }

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.