View Javadoc
1   package net.sf.atmodem4j.spsw;
2   
3   /*
4    * #%L
5    * SPSW Java
6    * %%
7    * Copyright (C) 2009 - 2014 atmodem4j
8    * %%
9    * atmodem4j - A serial port socket wrapper- http://atmodem4j.sourceforge.net/
10   * Copyright (C) 2009-2014, atmodem4j.sf.net, and individual contributors as indicated
11   * by the @authors tag. See the copyright.txt in the distribution for a
12   * full listing of individual contributors.
13   * 
14   * This is free software; you can redistribute it and/or modify it
15   * under the terms of the GNU General Public License as
16   * published by the Free Software Foundation; either version 3 of
17   * the License, or (at your option) any later version.
18   * 
19   * This software is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22   * Lesser General Public License for more details.
23   * 
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this software; if not, write to the Free
26   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28   * #L%
29   */
30  
31  import java.io.IOException;
32  
33  /**
34   *
35   * @author scream3r
36   */
37  public class GenericWinSerialPortSocket extends AbstractSerialPortSocket {
38  
39  
40      /**
41       * The file descriptor or handle for this Port
42       */
43      private long fd = -1;
44  
45      public GenericWinSerialPortSocket(String portName) {
46          super(portName);
47      }
48  
49      @Override
50      protected native void open(String portName, int type) throws IOException;
51  
52      /**
53       * Close port
54       */
55      protected native void close0() throws IOException;
56  
57      @Override
58      public native boolean isCTS();
59  
60      @Override
61      public native boolean isDSR();
62  
63      @Override
64      public native boolean isIncommingRI();
65      
66      @Override
67      public native void setRTS(boolean value) throws IOException;
68  
69      @Override
70      public native void setDTR(boolean value) throws IOException;
71  
72      @Override
73      public native void sendXON() throws IOException;
74  
75      @Override
76      public native void sendXOFF() throws IOException;
77  
78      @Override
79      public native void setXONChar(char c) throws IOException;
80  
81      @Override
82      public native void setXOFFChar(char c) throws IOException;
83  
84      @Override
85      protected native int readSingle() throws IOException;
86  
87      /**
88       * Read data from port
89       *
90       * @param b the data to be written
91       * @param off the start offset in the data
92       * @param len the number of bytes that are written
93       * @exception IOException If an I/O error has occurred.
94       */
95      @Override
96      protected native int readBytes(byte[] b, int off, int len) throws IOException;
97  
98      @Override
99      protected native void writeSingle(int b) throws IOException;
100 
101     /**
102      * Write data to port
103      *
104      * @param off the start offset in the data.
105      * @param len the number of bytes to write.
106      *
107      */
108     @Override
109     protected native void writeBytes(byte[] b, int off, int len) throws IOException;
110 
111     @Override
112     public native int getInBufferBytesCount() throws IOException;
113 
114     @Override
115     public native int getOutBufferBytesCount() throws IOException;
116 
117     @Override
118     protected native void setFlowControl(int mask) throws IOException;
119 
120     @Override
121     protected native int getFlowControl0() throws IOException;
122 
123     @Override
124     public native void setBreak(boolean value) throws IOException;
125 
126     @Override
127     protected native void setBaudrate(int baudRate) throws IOException;
128 
129     @Override
130     protected native void setDataBits(int value) throws IOException;
131 
132     @Override
133     protected native void setStopBits(int value) throws IOException;
134 
135     @Override
136     protected native void setParity(int parity) throws IOException;
137 
138     @Override
139     protected native int getBaudrate0() throws IOException;
140 
141     @Override
142     protected native int getDataBits0() throws IOException;
143 
144     @Override
145     protected native int getStopBits0() throws IOException;
146 
147     @Override
148     protected native int getParity0() throws IOException;
149 
150     @Override
151     public native char getXONChar() throws IOException;
152 
153     @Override
154     public native char getXOFFChar() throws IOException;
155 
156 }