com.ibutton
Class Access

java.lang.Object
  |
  +--com.ibutton.Access

public class Access
extends java.lang.Object
implements PortAdapter

iButton Pure Java Access Layer that will load other iButton PortAdapter interface class for com.iButton package.


Constructor Summary
Access()
          Constructor declaration
 
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()
          Read a single bit of data from 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()
          Read a single byte of data from 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 ROM Id.
 boolean iBSetup(int portNumber)
          Select the port that hosts the One-Wire adapter, by specifying a port number.
 boolean iBStream(int[] data, int len)
          This method does following operations: Access the current button using fast access Send the provided block of data to the One-Wire bus
 boolean iBStrongAccess()
          Resets the currently selected iButton and verify whether (or not) it is still connected to the One-Wire bus.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Access

public Access()
Constructor declaration
Method Detail

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",...).
Specified by:
SetAdapterType in interface PortAdapter
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

iBSetup

public boolean iBSetup(int portNumber)
Select the port that hosts the One-Wire adapter, by specifying a port number. This method should be called after setAdapterType. If the deviceName string is NULL then the parameter to this function will be used. Otherwise, the parameter is ignored.
Specified by:
iBSetup in interface PortAdapter
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.
Specified by:
iBGndTest in interface PortAdapter
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.
Specified by:
iBDOWCheck in interface PortAdapter
Returns:
'true' if the drivers were loaded or no drivers were required. 'false' 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.
Specified by:
iBKeyOpen in interface PortAdapter
Returns:
'true' if the One-Wire session is acquired.

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.
Specified by:
iBKeyClose in interface PortAdapter
Returns:
'true' if the One-Wire session is released

iBFirst

public boolean iBFirst()
Find the first iButton on the One-Wire bus.
Specified by:
iBFirst in interface PortAdapter
Returns:
'true' if an iButton is found and the ROM ID is in the internal buffer. 'false' if no iButton is on the bus. A subsequent call to iBROMData will return the ROM ID of the found device.

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.
Specified by:
iBNext in interface PortAdapter
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.
Specified by:
iBAccess in interface PortAdapter
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.
Specified by:
iBFastAccess in interface PortAdapter
Returns:
true if any iButton responded. False otherwise.

iBStrongAccess

public boolean iBStrongAccess()
Resets the currently selected iButton and verify whether (or not) it is still connected to the One-Wire bus.
Specified by:
iBStrongAccess in interface PortAdapter
Returns:
true if the iButton is connected.

iBROMData

public int[] iBROMData()
Retrieve the ROM Id of the currently selected iButton.
Specified by:
iBROMData in interface PortAdapter
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 ROM Id. This method is usually used prior to calling Access();
Specified by:
iBROMData in interface PortAdapter
Parameters:
romId - - the ROM Id to be set.
Returns:
true if the ROM Id buffer is set successfully.

iBReset

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

iBDataByte

public int iBDataByte()
Read a single byte of data from the currently selected iButton.
Returns:
Data byte read from the One-Wire bus.

iBDataByte

public int iBDataByte(int databyte)
Read/Write a single byte of data from/to the currently selected iButton.
Specified by:
iBDataByte in interface PortAdapter
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.
Specified by:
iBDataBit in interface PortAdapter
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.

iBDataBit

public boolean iBDataBit()
Read a single bit of data from the currently selected iButton.
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.
Specified by:
iBDataBlock in interface PortAdapter
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.
Specified by:
iBOverdriveOn in interface PortAdapter
Returns:
'true' if no error occurred changing to overdrive

iBOverdriveOff

public boolean iBOverdriveOff()
Shifts the One-Wire bus to normal speed.
Specified by:
iBOverdriveOff in interface PortAdapter
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.
Specified by:
SetAdapter5VTime in interface PortAdapter
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.
Specified by:
Adapter5VPrime in interface PortAdapter
Returns:
'true' if no error occurred priming strong-5volts

Adapter5VPrimeByte

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

Adapter5VCancel

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

Adapter5VActivate

public boolean Adapter5VActivate(int interval)
Activate the strong-5volts operation now. The strong-5volts interval is provided as a parameter.
Specified by:
Adapter5VActivate in interface PortAdapter
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:
Specified by:
iBStream in interface PortAdapter
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.
Specified by:
iBVersion in interface PortAdapter
Returns:
version string.

iBFailReason

public java.lang.String iBFailReason()
Returns the reason for the previous fail.
Specified by:
iBFailReason in interface PortAdapter
Returns:
fail message string.

setAdapterSpeed

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

setAdapterSpeedOptimum

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

SetAdapterSpeed

public boolean SetAdapterSpeed(int baud)
Deprecated. replaced by setAdapterSpeed(int baud).
Attempt to set the data transfer rate of the currently selected port.
Specified by:
SetAdapterSpeed in interface PortAdapter
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
Specified by:
setPortDeviceName in interface PortAdapter
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
Specified by:
releasePort in interface PortAdapter
Returns:
success or failure