com.ibutton
Interface PortAdapter

All Known Implementing Classes:
Access, SerialAdapterSmall

public abstract interface PortAdapter

Interface Port adapter class for com.iButton package.

History:


Method Summary
 boolean Adapter5VActivate(int interval)
          Activate the strong-5volts operation now.
 boolean Adapter5VCancel()
          Cancel the current strong-5volts operation.
 boolean Adapter5VPrime()
          Prime the strong-5volts operation to occur after the next iBDataBit.
 boolean Adapter5VPrimeByte()
          Prime the strong-5volts operation to occur after the next iBDataBit.
 boolean iBAccess()
          Initialize communications with the currently selected iButton.
 boolean iBDataBit(int databit)
          Read/Write a single bit of data from/to the currently selected iButton.
 boolean iBDataBlock(int[] input, int start, int length)
          Read/Write a block of data from/to the currently selected iButton.
 int iBDataByte(int databyte)
          Read/Write a single byte of data from/to the currently selected iButton.
 boolean iBDOWCheck()
          Loads the hardware specific drivers needed to perform One-Wire communications.
 java.lang.String iBFailReason()
          Returns the reason for the previous fail.
 boolean iBFastAccess()
          Resets and initializes communications with the currently selected iButton without verifying that it is still connected to the One-Wire bus.
 boolean iBFirst()
          Find the first iButton on the One-Wire bus.
 boolean iBGndTest()
          Test to see if the One-Wire bus is grounded.
 boolean iBKeyClose()
          Closes a One-Wire communications session on the currently selected port.
 boolean iBKeyOpen()
          Opens a One-Wire communications session on the currently selected port.
 boolean iBNext()
          Find the next iButton on the One-Wire bus in the current enumeration.
 boolean iBOverdriveOff()
          Shifts the One-Wire bus to normal speed.
 boolean iBOverdriveOn()
          Shifts the One-Wire bus to Overdrive speed.
 boolean iBReset()
          Resets communications for all devices on the One-Wire bus.
 int[] iBROMData()
          Retrieve the ROM Id of the currently selected iButton.
 boolean iBROMData(int[] romId)
          Sets the internal ROM Id buffer to the given array.
 boolean iBSetup(int portNumber)
          Select the port that hosts the One-Wire adapter by specifying the port number.
 boolean iBStream(int[] data, int len)
          This method does following operations: Access the current button using fast access.
 boolean iBStrongAccess()
          Verifies that the currently selected iButton is still on the One-Wire bus and resets it.
 java.lang.String iBVersion()
          Returns the version of the iButton library.
 boolean releasePort()
          Release the port handle in javax.comm.
 boolean SetAdapter5VTime(int interval)
          Set the strong-5volts interval time.
 boolean setAdapterSpeed(int baud)
          Attempt to set the data transfer rate of the currently selected port.
 boolean SetAdapterSpeed(int baud)
          Deprecated. replaced by setAdapterSpeed(int baud).
 void setAdapterSpeedOptimum()
          Attempt to set the data transfer rate of the currently selected port to its operating system's optimum baud rate.
 boolean SetAdapterType(int type, java.lang.String ad)
          Sets the adapter type using the type (PORT_TYPE_PARALLEL, PORT_TYPE_SERIAL,...) and a device name ("com1", "/dev/ttya",...).
 void setPortDeviceName(int typeCode, java.lang.String portDevice)
          Set the port device name as a string.
 

Method Detail

iBSetup

public boolean iBSetup(int portNumber)
Select the port that hosts the One-Wire adapter by specifying the port number. The value passed in is ignored if the device name is not null.
Parameters:
portNumber - Port number that the One-Wire adapter is on.
Returns:
'true' if no error occurred setting up the One-Wire port adapter

iBGndTest

public boolean iBGndTest()
Test to see if the One-Wire bus is grounded.
Returns:
true if the bus is not grounded.

iBDOWCheck

public boolean iBDOWCheck()
Loads the hardware specific drivers needed to perform One-Wire communications. May not apply to all PortAdapter implementations.
Returns:
'true' if the drivers were loaded or no drivers were required. 'false'f if could not load the drivers.

iBKeyOpen

public boolean iBKeyOpen()
Opens a One-Wire communications session on the currently selected port. iBKeyClose should be called after the session is complete. iBKeyOpen and iBKeyClose administrate sharing with other devices on the port (i.e. Printers,...). Certain hardware configurations may not allow One-Wire communication before iBKeyOpen is executed.
Returns:
'true' if the One-Wire session is aquired

iBKeyClose

public boolean iBKeyClose()
Closes a One-Wire communications session on the currently selected port. Each call to iBKeyOpen should be followed by a call to iBKeyClose after a data transfer session has been completed.
Returns:
'true' if the One-Wire session is released

iBFirst

public boolean iBFirst()
Find the first iButton on the One-Wire bus.
Returns:
'true' if an iButton is found and the ROM ID is in the internal buffer. 'false' if no iButton is on the bus.

iBNext

public boolean iBNext()
Find the next iButton on the One-Wire bus in the current enumeration. Calling this method again after a false return will restart the iButton enumeration.
Returns:
'true' if an iButton is found and the ROM ID is in the internal buffer. 'false' if the last iButton was the last device in the iButton enumeration.

iBAccess

public boolean iBAccess()
Initialize communications with the currently selected iButton.
Returns:
true if iButton responded. False otherwise.

iBFastAccess

public boolean iBFastAccess()
Resets and initializes communications with the currently selected iButton without verifying that it is still connected to the One-Wire bus.
Returns:
true if any iButton responded. False otherwise.

iBStrongAccess

public boolean iBStrongAccess()
Verifies that the currently selected iButton is still on the One-Wire bus and resets it.
Returns:
true if the iButton is connected.

iBROMData

public int[] iBROMData()
Retrieve the ROM Id of the currently selected iButton.
Returns:
the unique serial number (ROM Id) of the currently selected iButton.

iBROMData

public boolean iBROMData(int[] romId)
Sets the internal ROM Id buffer to the given array. This method is usually followed by a call to access.
Parameters:
romId - the id to be set.
Returns:
true if the internal buffer is changed successfully.

iBReset

public boolean iBReset()
Resets communications for all devices on the One-Wire bus.
Returns:
true if the reset succeeded.

iBDataByte

public int iBDataByte(int databyte)
Read/Write a single byte of data from/to the currently selected iButton.
Parameters:
databyte - Data to be written for write operations. Must be set to 0xFF for Read operations. Lower 8 bits of integer provided used.
Returns:
Data byte read from the One-Wire bus.

iBDataBit

public boolean iBDataBit(int databit)
Read/Write a single bit of data from/to the currently selected iButton.
Parameters:
databit - Data to be written for write operations. Must be set to 1 for Read operations.
Returns:
Data bit read from the One-Wire bus.

iBDataBlock

public boolean iBDataBlock(int[] input,
                           int start,
                           int length)
Read/Write a block of data from/to the currently selected iButton.
Parameters:
input - Data buffer to be written for write operations. All elements must be set to 0xFF for Read operations.
start - Offset of data in input.
length - Length of data to transfer.
Returns:
'true' if no error occurred during the block transfer

iBOverdriveOn

public boolean iBOverdriveOn()
Shifts the One-Wire bus to Overdrive speed.
Returns:
'true' if no error occurred changing to overdrive

iBOverdriveOff

public boolean iBOverdriveOff()
Shifts the One-Wire bus to normal speed.
Returns:
'true' if no error occurred changing to overdrive

SetAdapter5VTime

public boolean SetAdapter5VTime(int interval)
Set the strong-5volts interval time. Strong-5volts is used to provide power to an iButton between communcation.
Parameters:
interval - strong 5 volt interval in microseconds
Returns:
'true' if no error occurred setting the interval.

Adapter5VPrime

public boolean Adapter5VPrime()
Prime the strong-5volts operation to occur after the next iBDataBit.
Returns:
'true' if no error occurred priming strong-5volts

Adapter5VPrimeByte

public boolean Adapter5VPrimeByte()
Prime the strong-5volts operation to occur after the next iBDataBit.
Returns:
'true' if no error occurred priming strong-5volts

Adapter5VCancel

public boolean Adapter5VCancel()
Cancel the current strong-5volts operation.
Returns:
'true' if no error occurred stopping strong-5volts

Adapter5VActivate

public boolean Adapter5VActivate(int interval)
Activate the strong-5volts operation now. is provided as a parameter.
Parameters:
interval - strong 5 volt interval in microseconds
Returns:
'true' if no error occurred activating strong-5volts

iBStream

public boolean iBStream(int[] data,
                        int len)
This method does following operations:
Parameters:
data - Data buffer to be written for write operations. All elements must be set to 0xFF for Read operations.
len - length of data buffer (0.21)
Returns:
'true' if an iButton presence was detected and the data was successfully sent to the One-Wire.

iBVersion

public java.lang.String iBVersion()
Returns the version of the iButton library.
Returns:
version string.

iBFailReason

public java.lang.String iBFailReason()
Returns the reason for the previous fail.
Returns:
fail message string.

setAdapterSpeed

public boolean setAdapterSpeed(int baud)
Attempt to set the data transfer rate of the currently selected port.
Parameters:
baud - Speed desired in bits per second (values depend on adapter type).
Returns:
'true' if adapter speed set correctly

setAdapterSpeedOptimum

public void setAdapterSpeedOptimum()
Attempt to set the data transfer rate of the currently selected port to its operating system's optimum baud rate.

SetAdapterSpeed

public boolean SetAdapterSpeed(int baud)
Deprecated. replaced by setAdapterSpeed(int baud).
Attempt to set the data transfer rate of the currently selected port.
Parameters:
baud - Speed desired in bits per second (values depend on adapter type).
Returns:
'true' if adapter speed set correctly (0.21)

setPortDeviceName

public void setPortDeviceName(int typeCode,
                              java.lang.String portDevice)
Set the port device name as a string. This device name will override the portnumber specified in iBSetup
Parameters:
typeCode - Device port type code. (not always used) (0.23)
portDevice - Device name for the port being accessed. (0.21)

releasePort

public boolean releasePort()
Release the port handle in javax.comm.
Returns:
success or failure.

SetAdapterType

public boolean SetAdapterType(int type,
                              java.lang.String ad)
Sets the adapter type using the type (PORT_TYPE_PARALLEL, PORT_TYPE_SERIAL,...) and a device name ("com1", "/dev/ttya",...).
Parameters:
type - Type of port being accessed.
ad - Device name for the port being accessed.
Returns:
true if the Adapter can be loaded, false otherwise