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 GenericTermiosSerialPortSocket extends AbstractSerialPortSocket {
38  
39      /**
40       * The file descriptor or handle for this Port
41       */
42      private int fd = -1;
43  
44      public GenericTermiosSerialPortSocket(String portName) {
45          super(portName);
46      }
47  
48      @Override
49      protected native void open(String portName, int type) throws IOException;
50  
51      /**
52       * Close port
53       */
54      @Override
55      protected native void close0() throws IOException;
56  
57      @Override
58      public native boolean isCTS();
59  
60      public native boolean isRTS();
61  
62      @Override
63      public native boolean isDSR();
64  
65      public native boolean isDTR();
66  
67      @Override
68      public native boolean isIncommingRI();
69  
70      @Override
71      public native void setRTS(boolean value) throws IOException;
72  
73      @Override
74      public native void setDTR(boolean value) throws IOException;
75  
76      @Override
77      public native void setXONChar(char c) throws IOException;
78  
79      @Override
80      public native void setXOFFChar(char c) throws IOException;
81  
82      @Override
83      protected native int readSingle() throws IOException;
84  
85      /**
86       * Read data from port
87       *
88       * @param b the data to be written
89       * @param off the start offset in the data
90       * @param len the number of bytes that are written
91       * @exception IOException If an I/O error has occurred.
92       */
93      @Override
94      protected native int readBytes(byte[] b, int off, int len) throws IOException;
95  
96      @Override
97      protected native void writeSingle(int b) throws IOException;
98  
99      /**
100      * Write data to port
101      *
102      * @param off the start offset in the data.
103      * @param len the number of bytes to write.
104      *
105      */
106      @Override
107    protected native void writeBytes(byte[] b, int off, int len) throws IOException;
108 
109     @Override
110     public native int getInBufferBytesCount() throws IOException;
111 
112     @Override
113     public native int getOutBufferBytesCount() throws IOException;
114 
115     @Override
116     protected native void setFlowControl(int mask) throws IOException;
117 
118     @Override
119     protected native int getFlowControl0() throws IOException;
120 
121     @Override
122     public native void setBreak(boolean value) throws IOException;
123 
124     @Override
125     protected native void setBaudrate(int baudRate) throws IOException;
126 
127     @Override
128     protected native void setDataBits(int value) throws IOException;
129 
130     @Override
131     protected native void setStopBits(int value) throws IOException;
132 
133     @Override
134     protected native void setParity(int parity) throws IOException;
135 
136     @Override
137     protected native int getBaudrate0() throws IOException;
138 
139     @Override
140     protected native int getDataBits0() throws IOException;
141 
142     @Override
143     protected native int getStopBits0() throws IOException;
144 
145     @Override
146     protected native int getParity0() throws IOException;
147 
148     @Override
149     public native char getXONChar() throws IOException;
150 
151     @Override
152     public native char getXOFFChar() throws IOException;
153 
154     public native void printTermios() throws IOException;
155 
156     @Override
157     public native void sendXON() throws IOException;
158 
159     @Override
160     public native void sendXOFF() throws IOException;
161 }