OldSerialPort.java
     1: //========================================================================================
     2: //  OldSerialPort.java
     3: //    en:Serial port I/O
     4: //    ja:シリアルポート入出力
     5: //  Copyright (C) 2003-2023 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: package xeij;
    14: 
    15: import java.io.*;
    16: 
    17: public class OldSerialPort implements AutoCloseable {
    18: 
    19:   private long wp;
    20:   private SerialInputStream inputStream;
    21:   private SerialOutputStream outputStream;
    22: 
    23:   @Override public native void close () throws IOException;
    24:   public native SerialInputStream getInputStream () throws IOException;
    25:   public native SerialOutputStream getOutputStream () throws IOException;
    26:   public native String getPortName () throws IOException;
    27:   public native final void open (String str) throws IOException;
    28:   public native final void open (int vid, int pid) throws IOException;
    29:   public native void speed (String str) throws IOException;
    30: 
    31:   public class SerialInputStream extends InputStream {
    32:     private long wp;
    33:     @Override public native int available () throws IOException;
    34:     @Override public native void close () throws IOException;
    35:     @Override public native int read () throws IOException;
    36:   }
    37: 
    38:   public class SerialOutputStream extends OutputStream {
    39:     private long wp;
    40:     @Override public native void close () throws IOException;
    41:     @Override public native void write (int b) throws IOException;
    42:   }
    43: 
    44:   public OldSerialPort (String str) throws IOException {
    45:     open (str);
    46:   }
    47:   public OldSerialPort (int vid, int pid) throws IOException {
    48:     open (vid, pid);
    49:   }
    50: 
    51: }