com.dalsemi.comm
Class NativeComm

java.lang.Object
  |
  +--com.dalsemi.comm.NativeComm

public class NativeComm
extends java.lang.Object

This class contains the interface to the native I/O methods. It acts as a bridge between the JVM and the various I/O drivers registered to the system.


Field Summary
static int PORT_LCD
          Deprecated. The LCD driver is no longer supported.
static int PORT_SERIAL0
          I/O identifier for serial port 0 driver
static int PORT_SERIAL1
          I/O identifier for serial port 1 driver
static int PORT_SERIAL2
          I/O identifier for serial port 2 driver
static int PORT_SERIAL3
          I/O identifier for serial port 3 driver
static int PORT_SERIAL4
          I/O identifier for serial port 4 driver
static int STREAM_STDIN
          Denotes an input stream
static int STREAM_STDOUT
          Denotes an output stream
 
Constructor Summary
NativeComm()
           
 
Method Summary
static int available(int handle)
          Returns the number of bytes available in a driver.
static int close(int handle)
          Closes a previously opened port.
static int ioctl(int handle, byte[] arr, int offset, int length, int timeout)
          Performs a generic ioctl method.
static int open(int port, int stream)
          Opens a port for use.
static int read(int handle, byte[] arr, int timeout, boolean suspend)
          Calls the drivers read method.
static int read(int handle, byte[] arr, int offset, int length, int timeout, boolean suspend)
          Calls the drivers read method.
static void write(int handle, byte[] arr)
          Calls the drivers write method.
static void write(int handle, byte[] arr, int offset, int length)
          Calls the drivers write method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STREAM_STDIN

public static final int STREAM_STDIN
Denotes an input stream

STREAM_STDOUT

public static final int STREAM_STDOUT
Denotes an output stream

PORT_SERIAL0

public static final int PORT_SERIAL0
I/O identifier for serial port 0 driver

PORT_SERIAL1

public static final int PORT_SERIAL1
I/O identifier for serial port 1 driver

PORT_LCD

public static final int PORT_LCD
Deprecated. The LCD driver is no longer supported.

I/O identifier for LCD driver.

PORT_SERIAL2

public static final int PORT_SERIAL2
I/O identifier for serial port 2 driver

PORT_SERIAL3

public static final int PORT_SERIAL3
I/O identifier for serial port 3 driver

PORT_SERIAL4

public static final int PORT_SERIAL4
I/O identifier for serial port 4 driver
Constructor Detail

NativeComm

public NativeComm()
Method Detail

open

public static int open(int port,
                       int stream)
Opens a port for use. Only one stream can be opened at a time. Returns a handle to the driver. For example

int handle = NativeComm.open(NativeComm.PORT_SERIAL0, NativeComm.STREAM_STDIN);

opens an input stream to serial port 0.
Parameters:
port - The port type to open.
stream - The stream type to open.
Returns:
- handle to the opened port.

close

public static int close(int handle)
Closes a previously opened port.
Parameters:
handle - Handle of a previously opened port.
Returns:
Success/Failure(0)

write

public static void write(int handle,
                         byte[] arr)
Calls the drivers write method. Writes from 0 to arr.length.
Parameters:
handle - Stream handle returned from open
arr - Byte array of data.

write

public static void write(int handle,
                         byte[] arr,
                         int offset,
                         int length)
Calls the drivers write method.
Parameters:
handle - Stream handle returned from open.
arr - Byte array to write.
length - Ammount of data to write.

read

public static int read(int handle,
                       byte[] arr,
                       int timeout,
                       boolean suspend)
Calls the drivers read method.
Parameters:
handle - Stream handle to read from
arr - Input Array.
timeout - Number of milliseconds to wait for data.
suspend - true for suspend, false for sleep with timeout.
Returns:
 

read

public static int read(int handle,
                       byte[] arr,
                       int offset,
                       int length,
                       int timeout,
                       boolean suspend)
Calls the drivers read method.
Parameters:
handle - Stream handle to read from
arr - Input Array.
length - Ammount of data to read.
timeout - Number of milliseconds to wait for data.
suspend - true for suspend, false for sleep with timeout.
Returns:
 

ioctl

public static int ioctl(int handle,
                        byte[] arr,
                        int offset,
                        int length,
                        int timeout)
Performs a generic ioctl method. The driver is responsible for the format of the data passed to it.
Parameters:
handle - Stream Handle.
arr - Array of arguments to IOCTL call.
length - Length of array.
timeout - Ignored.
Returns:
 

available

public static int available(int handle)
Returns the number of bytes available in a driver.
Parameters:
handle -  
Returns:
Amount of data available from stream.


Also see:
o TINI 1.16 API, Optional Modules
o TINI Home Page
o 1-Wire API

o JDK 1.1

Last update Wed Jun 8 17:19:36 CDT 2005