OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [java/] [src/] [edu/] [byu/] [cc/] [plieber/] [fpgaenet/] [examples/] [Simple.java] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
/**
2
 *
3
 */
4
package edu.byu.cc.plieber.fpgaenet.examples;
5
 
6
import java.io.BufferedReader;
7
import java.io.IOException;
8
import java.io.InputStreamReader;
9
import java.net.InetAddress;
10
import java.net.UnknownHostException;
11
 
12
import edu.byu.cc.plieber.fpgaenet.fcp.FCPProtocol;
13
 
14
/**
15
 * @author Peter Lieber
16
 *
17
 */
18
public class Simple {
19
 
20
        /**
21
         * @param args
22
         */
23
        public static void main(String[] args) {
24
                FCPProtocol p = null;
25
                try {
26
                        p = new FCPProtocol();
27
                        p.connect(InetAddress.getByName("10.0.1.42"));
28
                        while (!p.isConnected());
29
                } catch (UnknownHostException e) {
30
                        // TODO Auto-generated catch block
31
                        e.printStackTrace();
32
                } catch (IOException e) {
33
                        // TODO Auto-generated catch block
34
                        e.printStackTrace();
35
                }
36
                BufferedReader ir = new BufferedReader(new InputStreamReader(System.in));
37
 
38
                SimpleInterface sif = new SimpleInterface(p);
39
                String in = "";
40
                System.out.println("Welcome to the Example Design");
41
                mainloop: while (!in.equalsIgnoreCase("quit")) {
42
                        try {
43
                                in = ir.readLine();
44
                        } catch (IOException e) {
45
                                e.printStackTrace();
46
                                in = "quit";
47
                        }
48
                        if (in.toLowerCase().startsWith("w")) {
49
                                String[] tokens = in.split(" ");
50
                                if (tokens.length < 2) {
51
                                        System.out.println("Usage: w <int to write>");
52
                                        continue mainloop;
53
                                }
54
                                int value = Integer.parseInt(tokens[1]);
55
                                sif.setRegister(value);
56
                        }
57
                        else if (in.toLowerCase().startsWith("r")) {
58
                                int value = sif.getRegister();
59
                                System.out.println("Register Value: " + value);
60
                        }
61
                        else if (in.toLowerCase().startsWith("l")) {
62
                                String[] tokens = in.split(" ");
63
                                if (tokens.length < 2) {
64
                                        System.out.println("Usage: l <LED value to write>");
65
                                        continue mainloop;
66
                                }
67
                                byte value = (byte) (Integer.parseInt(tokens[1]) & 0xff);
68
                                sif.setLED(value);
69
                        }
70
                        else if (in.toLowerCase().startsWith("d")) {
71
                                byte value = sif.getDIP();
72
                                System.out.println("DIP Switch Value: " + value);
73
                        }
74
                }
75
                System.out.println("Goodbye!");
76
                System.exit(0);
77
        }
78
 
79
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.