j3d.org Code

org.j3d.device.input.polhemus
Class SerialPortDevice

java.lang.Object
  extended byorg.j3d.device.input.polhemus.SerialPortDevice
Direct Known Subclasses:
Polhemus

public abstract class SerialPortDevice
extends java.lang.Object

Representation of a device that uses the serial port for information.

Version:
$Revision: 1.1 $
Author:
Satoshi Konno, Justin Couch

Field Summary
static int DATABITS_5
           
static int DATABITS_6
           
static int DATABITS_7
           
static int DATABITS_8
           
static int PARITY_EVEN
           
static int PARITY_NONE
           
static int PARITY_ODD
           
static int SERIALPORT1
           
static int SERIALPORT2
           
static int SERIALPORT3
           
static int SERIALPORT4
           
static int STOPBITS_1
           
static int STOPBITS_1_5
           
static int STOPBITS_2
           
 
Constructor Summary
protected SerialPortDevice(int device, int baudrate, int dataBits, int stopBits, int parity)
           
protected SerialPortDevice(java.lang.String deviceName, int baudrate, int dataBits, int stopBits, int parity)
           
 
Method Summary
 void close()
          Close the serial port and all associated streams now.
 int nToRead()
          Find out how many bytes are available for reading.
 java.lang.String read(int ndata)
          Read the next ndata bytes from the port, given a maximum timeout of 3000 milliseconds.
 java.lang.String read(int ndata, long timeOut)
           
 void waitData(int nWaitData)
           
 void waitTime(long millis)
          Convenience method to wait for a certain period of time.
 void write(byte[] value, int len)
          Write the given string to the serial port now.
 void write(java.lang.String value)
          Write the given string to the serial port now.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIALPORT1

public static final int SERIALPORT1
See Also:
Constant Field Values

SERIALPORT2

public static final int SERIALPORT2
See Also:
Constant Field Values

SERIALPORT3

public static final int SERIALPORT3
See Also:
Constant Field Values

SERIALPORT4

public static final int SERIALPORT4
See Also:
Constant Field Values

DATABITS_5

public static final int DATABITS_5

DATABITS_6

public static final int DATABITS_6

DATABITS_7

public static final int DATABITS_7

DATABITS_8

public static final int DATABITS_8

STOPBITS_1

public static final int STOPBITS_1

STOPBITS_2

public static final int STOPBITS_2

STOPBITS_1_5

public static final int STOPBITS_1_5

PARITY_NONE

public static final int PARITY_NONE

PARITY_ODD

public static final int PARITY_ODD

PARITY_EVEN

public static final int PARITY_EVEN
Constructor Detail

SerialPortDevice

protected SerialPortDevice(java.lang.String deviceName,
                           int baudrate,
                           int dataBits,
                           int stopBits,
                           int parity)
Parameters:
deviceName - name of the port to open. ex. "COM1", "/dev/ttyd1"
baudrate - baudrate of the port.
dataBits -
stopBits -
parity -

SerialPortDevice

protected SerialPortDevice(int device,
                           int baudrate,
                           int dataBits,
                           int stopBits,
                           int parity)
Parameters:
device - number of the port to open. ex. "COM1", "/dev/ttyd1"
baudrate - baudrate of the port.
dataBits -
stopBits -
parity -
Method Detail

close

public void close()
Close the serial port and all associated streams now.


write

public void write(java.lang.String value)
Write the given string to the serial port now.

Parameters:
value - The value to write

write

public void write(byte[] value,
                  int len)
Write the given string to the serial port now.

Parameters:
value - The value to write
len - The number of bytes to write from the array

read

public java.lang.String read(int ndata,
                             long timeOut)

read

public java.lang.String read(int ndata)
Read the next ndata bytes from the port, given a maximum timeout of 3000 milliseconds.

Parameters:
ndata - The number of bytes to read

nToRead

public int nToRead()
Find out how many bytes are available for reading.


waitData

public void waitData(int nWaitData)

waitTime

public void waitTime(long millis)
Convenience method to wait for a certain period of time.

Parameters:
millis - The number of milliseconds to sleep for

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org