1 package net.sf.atmodem4j.spsw;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 import java.io.Closeable;
32 import java.io.IOException;
33 import java.io.InputStream;
34 import java.io.OutputStream;
35 import java.util.Set;
36
37
38
39
40
41 public interface SerialPortSocket extends Closeable {
42
43 public class SerialPortSocketFactory {
44
45 public SerialPortSocket createSerialPortSocket(String portName) {
46 switch (System.getProperty("os.name")) {
47 case "Linux":
48 return new GenericTermiosSerialPortSocket(portName);
49 case "Mac OS":
50 throw new UnsupportedOperationException("Mac OS is currently not supported yet");
51 case "Mac OS X":
52 throw new UnsupportedOperationException("Mac OS X is currently not supported yet");
53 case "Windows 95":
54 return new GenericWinSerialPortSocket(portName);
55 case "Windows 98":
56 return new GenericWinSerialPortSocket(portName);
57 case "Windows Me":
58 return new GenericWinSerialPortSocket(portName);
59 case "Windows NT":
60 return new GenericWinSerialPortSocket(portName);
61 case "Windows 2000":
62 return new GenericWinSerialPortSocket(portName);
63 case "Windows XP":
64 return new GenericWinSerialPortSocket(portName);
65 case "Windows 2003":
66 return new GenericWinSerialPortSocket(portName);
67 case "Windows Vista":
68 return new GenericWinSerialPortSocket(portName);
69 case "Windows 2008":
70 return new GenericWinSerialPortSocket(portName);
71 case "Windows 7":
72 return new GenericWinSerialPortSocket(portName);
73 case "Windows 8":
74 return new GenericWinSerialPortSocket(portName);
75 case "Windows 2012":
76 return new GenericWinSerialPortSocket(portName);
77 case "Windows CE":
78 throw new UnsupportedOperationException("Windows CE is currently not supported yet");
79 case "OS/2":
80 throw new UnsupportedOperationException("OS/2 is currently not supported yet");
81 case "MPE/iX":
82 throw new UnsupportedOperationException("MPE/iX is currently not supported yet");
83 case "HP-UX":
84 throw new UnsupportedOperationException("HP-UX is currently not supported yet");
85 case "AIX":
86 throw new UnsupportedOperationException("AIX is currently not supported yet");
87 case "OS/390":
88 throw new UnsupportedOperationException("OS/390 is currently not supported yet");
89 case "FreeBSD":
90 throw new UnsupportedOperationException("FreeBSD is currently not supported yet");
91 case "Irix":
92 throw new UnsupportedOperationException("Irix is currently not supported yet");
93 case "Digital Unix":
94 throw new UnsupportedOperationException("Digital Unix is currently not supported yet");
95 case "NetWare 4.11":
96 throw new UnsupportedOperationException("NetWare 4.11 is currently not supported yet");
97 case "OSF1":
98 throw new UnsupportedOperationException("OSF1 is currently not supported yet");
99 case "OpenVMS":
100 throw new UnsupportedOperationException("OpenVMS is currently not supported yet");
101 default:
102 throw new RuntimeException("Can't figure out OS: " + System.getProperty("os.name"));
103 }
104 }
105 }
106
107 static SerialPortSocketFactory FACTORY = new SerialPortSocketFactory();
108
109 boolean isClosed();
110
111 boolean isCTS();
112
113 boolean isDSR();
114
115 boolean isIncommingRI();
116
117 InputStream getInputStream() throws IOException;
118
119 OutputStream getOutputStream() throws IOException;
120
121
122
123
124
125
126 String getPortName();
127
128
129
130
131
132
133 boolean isOpen();
134
135
136
137
138
139
140
141
142
143 void openAsIs() throws IOException;
144
145 void openRaw() throws IOException;
146
147 void openTerminal() throws IOException;
148
149 void openModem() throws IOException;
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 void openRaw(Baudrate baudRate, DataBits dataBits, StopBits stopBits, Parity parity, Set<FlowControl> flowControls) throws IOException;
165
166
167
168
169
170
171
172 @Override
173 void close() throws IOException;
174
175
176
177
178
179
180
181
182 void setRTS(boolean value) throws IOException;
183
184
185
186
187
188
189
190
191 void setDTR(boolean value) throws IOException;
192
193
194 void setXONChar(char c) throws IOException;
195
196 void setXOFFChar(char c) throws IOException;
197
198 char getXONChar() throws IOException;
199
200 char getXOFFChar() throws IOException;
201
202 void sendXON() throws IOException;
203
204 void sendXOFF() throws IOException;
205
206
207
208
209
210
211
212
213 int getInBufferBytesCount() throws IOException;
214
215
216
217
218
219
220
221
222
223 int getOutBufferBytesCount() throws IOException;
224
225
226
227
228
229
230
231 void setBreak(boolean value) throws IOException;
232
233 void setFlowControl(Set<FlowControl> flowControls) throws IOException;
234
235 void setBaudrate(Baudrate baudrate) throws IOException;
236
237 void setDataBits(DataBits dataBits) throws IOException;
238
239 void setStopBits(StopBits stopBits) throws IOException;
240
241 void setParity(Parity parity) throws IOException;
242
243 Baudrate getBaudrate() throws IOException;
244
245 DataBits getDatatBits() throws IOException;
246
247 StopBits getStopBits() throws IOException;
248
249 Parity getParity() throws IOException;
250
251 Set<FlowControl> getFlowControl() throws IOException;
252
253 }