Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
157 kaklik 1
/*
2
    AVRcamVIEW: A PC application to test out the functionallity of the
3
     AVRcam real-time image processing engine.
4
    Copyright (C) 2004    Brent A. Taylor
5
 
6
    This program is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
 
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    General Public License for more details.
15
 
16
    You should have received a copy of the GNU General Public
17
    License along with this program; if not, write to the Free Software
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
20
   For more information on the AVRcamVIEW, please contact:
21
 
22
   taylorba@comcast.net
23
 
24
   or go to www.jrobot.net for more details regarding the system.
25
*/
26
 
27
package avr.connection;
28
 
29
import java.io.*;
30
import java.util.*;
31
import javax.comm.*;
32
 
33
public class SerialParams implements Serializable {
34
 
35
   public static void main(String[] args) {
36
      System.out.println("Flow Control None: " + SerialPort.FLOWCONTROL_NONE);
37
      System.out.println("Flow Control RTSCTS IN: " + SerialPort.FLOWCONTROL_RTSCTS_IN);
38
      System.out.println("Flow Control RTSCTS OUT: " + SerialPort.FLOWCONTROL_RTSCTS_OUT);
39
      System.out.println("Flow Control XON/XOFF IN: " + SerialPort.FLOWCONTROL_XONXOFF_IN);
40
      System.out.println("Flow Control XON/XOFF OUT: " + SerialPort.FLOWCONTROL_XONXOFF_OUT);
41
 
42
      System.out.println("Data Bits 5: " + SerialPort.DATABITS_5);
43
      System.out.println("Data Bits 6: " + SerialPort.DATABITS_6);
44
      System.out.println("Data Bits 7: " + SerialPort.DATABITS_7);
45
      System.out.println("Data Bits 8: " + SerialPort.DATABITS_8);
46
 
47
      System.out.println("Parity Even: " + SerialPort.PARITY_EVEN);
48
      System.out.println("Parity Odd: " + SerialPort.PARITY_ODD);
49
      System.out.println("Parity Mark: " + SerialPort.PARITY_MARK);
50
      System.out.println("Parity Space: " + SerialPort.PARITY_SPACE);
51
      System.out.println("Parity None: " + SerialPort.PARITY_NONE);
52
 
53
      System.out.println("Stop Bits 1: " + SerialPort.STOPBITS_1);
54
      System.out.println("Stop Bits 1.5: " + SerialPort.STOPBITS_1_5);
55
      System.out.println("Stop Bits 2: " + SerialPort.STOPBITS_2);
56
   }
57
 
58
   private int baudRate;
59
   private int dataBits;
60
   private int stopBits;
61
   private int parity;
62
   private int flowControl;
63
 
64
   public SerialParams() {
65
      this(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, SerialPort.FLOWCONTROL_NONE);
66
   }
67
 
68
   public SerialParams(int baudRate, int dataBits,
69
                       int stopBits, int parity, int flowControl) {
70
      this.baudRate = baudRate;
71
      this.dataBits = dataBits;
72
      this.stopBits = stopBits;
73
      this.parity = parity;
74
      this.flowControl = flowControl;
75
   }
76
 
77
   public int getBaudRate() {
78
      return baudRate;
79
   }
80
 
81
   public int getFlowControl() {
82
      return flowControl;
83
   }
84
 
85
   public int getDataBits() {
86
      return dataBits;
87
   }
88
 
89
   public int getParity() {
90
      return parity;
91
   }
92
 
93
   public int getStopBits() {
94
      return stopBits;
95
   }
96
 
97
   public void setStopBits(int stopBits) {
98
      this.stopBits = stopBits;
99
   }
100
 
101
   public void setParity(int parity) {
102
      this.parity = parity;
103
   }
104
 
105
   public void setFlowControl(int flowControl) {
106
      this.flowControl = flowControl;
107
   }
108
 
109
   public void setDataBits(int dataBits) {
110
      this.dataBits = dataBits;
111
   }
112
 
113
   public void setBaudRate(int baudRate) {
114
      this.baudRate = baudRate;
115
   }
116
 
117
   public String toString() {
118
      StringBuffer builder = new StringBuffer("Serial Parameters[");
119
      builder.append("baudrate=").append(baudRate)
120
             .append("databits=").append(dataBits)
121
             .append("stopbits=").append(stopBits)
122
             .append("parity=").append(parity)
123
             .append("flowcontrol=").append(flowControl);
124
      return builder.toString();
125
   }
126
 
127
}