com.dalsemi.onewire.adapter
Class SerialService

com.dalsemi.onewire.adapter.SerialService

public class SerialService


Method Summary
 int available()
           
 boolean beginExclusive(boolean blocking)
          Gets exclusive use of the 1-Wire to communicate with an iButton or 1-Wire Device.
static void CleanUpByThread(Thread t)
          Cleans up the resources used by the thread argument.
 void closePort()
          Close this serial port.
 void endExclusive()
          Relinquishes exclusive control of the 1-Wire Network.
 void flush()
           
 int getBaudRate()
           
 String getPortName()
           
static Enumeration getSerialPortIdentifiers()
           
static SerialService getSerialService(String strComPort)
           
 boolean haveExclusive()
          Check if this thread has exclusive control of the port.
 boolean isDTR()
           
 boolean isPortOpen()
           
 boolean isRTS()
           
 void openPort()
           
 void openPort(com.dalsemi.onewire.adapter.SerialPortEventListener spel)
           
 int read()
           
 int read(byte[] buffer)
           
 int read(byte[] buffer, int offset, int length)
           
 int readWithTimeout(byte[] buffer, int offset, int length)
           
 char[] readWithTimeout(int length)
           
 void sendBreak(int duration)
          Send a break on this serial port
 void serialEvent(com.dalsemi.onewire.adapter.SerialPortEvent spe)
          SerialPortEventListener method.
 void setBaudRate(int baudRate)
           
 void setDTR(boolean newDTR)
           
 void setNotifyOnDataAvailable(boolean notify)
           
 void setRTS(boolean newRTS)
           
 void write(byte[] data)
           
 void write(byte[] data, int offset, int length)
           
 void write(char data)
           
 void write(char[] data)
           
 void write(char[] data, int offset, int length)
           
 void write(int data)
           
 void write(String data)
           
 

Method Detail

CleanUpByThread

public static void CleanUpByThread(Thread t)
Cleans up the resources used by the thread argument. If another thread starts communicating with this port, and then goes away, there is no way to relinquish the port without stopping the process. This method allows other threads to clean up.
Parameters:
thread - that may have used a USerialAdapter

getSerialService

public static SerialService getSerialService(String strComPort)

serialEvent

public void serialEvent(com.dalsemi.onewire.adapter.SerialPortEvent spe)
SerialPortEventListener method. This just calls the notify method on this object, so that all blocking methods are kicked awake whenever a serialEvent occurs.

openPort

public void openPort()
              throws IOException

openPort

public void openPort(com.dalsemi.onewire.adapter.SerialPortEventListener spel)
              throws IOException

setNotifyOnDataAvailable

public void setNotifyOnDataAvailable(boolean notify)

getSerialPortIdentifiers

public static Enumeration getSerialPortIdentifiers()

getPortName

public String getPortName()

isPortOpen

public boolean isPortOpen()

isDTR

public boolean isDTR()

setDTR

public void setDTR(boolean newDTR)

isRTS

public boolean isRTS()

setRTS

public void setRTS(boolean newRTS)

sendBreak

public void sendBreak(int duration)
Send a break on this serial port
Parameters:
duration - - break duration in ms

getBaudRate

public int getBaudRate()

setBaudRate

public void setBaudRate(int baudRate)
                 throws IOException

closePort

public void closePort()
Close this serial port.
Throws:
IOException - - if port is in use by another application

flush

public void flush()
           throws IOException

beginExclusive

public boolean beginExclusive(boolean blocking)
Gets exclusive use of the 1-Wire to communicate with an iButton or 1-Wire Device. This method should be used for critical sections of code where a sequence of commands must not be interrupted by communication of threads with other iButtons, and it is permissible to sustain a delay in the special case that another thread has already been granted exclusive access and this access has not yet been relinquished.

Parameters:
blocking - true if want to block waiting for an excluse access to the adapter
Returns:
true if blocking was false and a exclusive session with the adapter was aquired
Throws:
IOException -  

endExclusive

public void endExclusive()
Relinquishes exclusive control of the 1-Wire Network. This command dynamically marks the end of a critical section and should be used when exclusive control is no longer needed.

haveExclusive

public boolean haveExclusive()
Check if this thread has exclusive control of the port.

available

public int available()
              throws IOException

read

public int read()
         throws IOException

read

public int read(byte[] buffer)
         throws IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException

readWithTimeout

public int readWithTimeout(byte[] buffer,
                           int offset,
                           int length)
                    throws IOException

readWithTimeout

public char[] readWithTimeout(int length)
                       throws IOException

write

public void write(int data)
           throws IOException

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws IOException

write

public void write(byte[] data)
           throws IOException

write

public void write(String data)
           throws IOException

write

public void write(char data)
           throws IOException

write

public void write(char[] data)
           throws IOException

write

public void write(char[] data,
                  int offset,
                  int length)
           throws IOException


Copyright © 1999-2003 Dallas Semiconductor. All Rights Reserved.