com.dalsemi.onewire.container
Class OneWireContainer02

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
        |
        +--com.dalsemi.onewire.container.OneWireContainer02

public class OneWireContainer02
extends OneWireContainer

iButton container for iButton family type 02 (hex), DS1991/DS1425.

Version:
0.00, 28 Aug 2000

Field Summary
static byte COPY_SCRATCHPAD_COMMAND
          DS1991 Copy Scratchpad Command
static byte READ_SCRATCHPAD_COMMAND
          DS1991 Read Scratchpad Command
static byte READ_SUBKEY_COMMAND
          DS1991 Read SubKey Command
static byte WRITE_PASSWORD_COMMAND
          DS1991 Write Password Command
static byte WRITE_SCRATCHPAD_COMMAND
          DS1991 Write Scratchpad Command
static byte WRITE_SUBKEY_COMMAND
          DS1991 Write SubKey Command
 
Constructor Summary
OneWireContainer02()
          Constructor OneWireContainer02
OneWireContainer02(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer02(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer02(DSPortAdapter sourceAdapter, java.lang.String newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
 
Method Summary
 void copyScratchpad(int key, byte[] passwd, int blockNum)
          Writes the data from the scratchpad to the specified block or blocks.
 java.lang.String getAlternateNames()
          Retrieve the alternate Dallas Semiconductor part numbers or names.
 java.lang.String getDescription()
          Retrieve a short description of the function of the iButton type.
 java.lang.String getName()
          Retrieve the Dallas Semiconductor part number of the iButton as a string.
 byte[] readScratchpad()
          Reads the entire scratchpad.
 void readSubkey(byte[] data, int key, byte[] passwd)
          Reads the subkey requested with the given key name and password.
 byte[] readSubkey(int key, byte[] passwd)
          Reads the subkey requested with the given key name and password.
 void writePassword(int key, byte[] oldName, byte[] newName, byte[] newPasswd)
          Writes a new identifier and password to the secure subkey iButton
 void writeScratchpad(int addr, byte[] data)
          Writes the data to the scratchpad from the given address.
 void writeSubkey(int key, int addr, byte[] passwd, byte[] data)
          Writes new data to the secure subkey
 
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WRITE_SCRATCHPAD_COMMAND

public static final byte WRITE_SCRATCHPAD_COMMAND
DS1991 Write Scratchpad Command

READ_SCRATCHPAD_COMMAND

public static final byte READ_SCRATCHPAD_COMMAND
DS1991 Read Scratchpad Command

COPY_SCRATCHPAD_COMMAND

public static final byte COPY_SCRATCHPAD_COMMAND
DS1991 Copy Scratchpad Command

WRITE_PASSWORD_COMMAND

public static final byte WRITE_PASSWORD_COMMAND
DS1991 Write Password Command

WRITE_SUBKEY_COMMAND

public static final byte WRITE_SUBKEY_COMMAND
DS1991 Write SubKey Command

READ_SUBKEY_COMMAND

public static final byte READ_SUBKEY_COMMAND
DS1991 Read SubKey Command
Constructor Detail

OneWireContainer02

public OneWireContainer02()
Constructor OneWireContainer02

OneWireContainer02

public OneWireContainer02(DSPortAdapter sourceAdapter,
                          byte[] newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

OneWireContainer02

public OneWireContainer02(DSPortAdapter sourceAdapter,
                          long newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

OneWireContainer02

public OneWireContainer02(DSPortAdapter sourceAdapter,
                          java.lang.String newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device
Method Detail

getName

public java.lang.String getName()
Retrieve the Dallas Semiconductor part number of the iButton as a string. For example 'Crypto iButton' or 'DS1992'.
Overrides:
getName in class OneWireContainer
Returns:
string represetation of the iButton name.

getAlternateNames

public java.lang.String getAlternateNames()
Retrieve the alternate Dallas Semiconductor part numbers or names. A 'family' of 1-Wire Network devices may have more than one part number depending on packaging. There can also be nicknames such as 'Crypto iButton'.
Overrides:
getAlternateNames in class OneWireContainer
Returns:
String representation of the alternate names.

getDescription

public java.lang.String getDescription()
Retrieve a short description of the function of the iButton type.
Overrides:
getDescription in class OneWireContainer
Returns:
String representation of the function description.

writeScratchpad

public void writeScratchpad(int addr,
                            byte[] data)
                     throws OneWireIOException,
                            OneWireException,
                            java.lang.IllegalArgumentException
Writes the data to the scratchpad from the given address.
Parameters:
addr - address to begin writing. Must be between 0x00 and 0x3F.
data - data to write.
Throws:
java.lang.IllegalArgumentException -  
OneWireIOException -  
OneWireException -  

readScratchpad

public byte[] readScratchpad()
                      throws OneWireIOException,
                             OneWireException
Reads the entire scratchpad.
Returns:
byte[] containing the data from the scratchpad; the array will have a length of 64.
Throws:
OneWireIOException -  
OneWireException -  

copyScratchpad

public void copyScratchpad(int key,
                           byte[] passwd,
                           int blockNum)
                    throws OneWireIOException,
                           OneWireException,
                           java.lang.IllegalArgumentException
Writes the data from the scratchpad to the specified block or blocks. Note that the write will erase the data from the scratchpad.
Parameters:
key - subkey being written
passwd - password for the subkey being written
blockNum - number of the block to be copied (see page 7 of the DS1991 data sheet) block 0-7, or 8 to copy all 64 bytes.
Throws:
java.lang.IllegalArgumentException -  
OneWireIOException -  
OneWireException -  

readSubkey

public byte[] readSubkey(int key,
                         byte[] passwd)
                  throws OneWireIOException,
                         OneWireException,
                         java.lang.IllegalArgumentException
Reads the subkey requested with the given key name and password. Note that this method allows for reading from the subkey data only which starts at address 0x10 within a key. It does not allow reading from any earlier address within a key because the device cannot be force to allow reading the password. This is why the subkey number is or-ed with 0x10 in creating the address in bytes 1 and 2 of the sendBlock.
Parameters:
key - number indicating the key to be read: 0, 1, or 2
passwd - password of destination subkey
Returns:
byte[] containing the data from the subkey; the array will have a length of 64, since it includes the key identifier, sent password, and 48 bytes of data.
Throws:
java.lang.IllegalArgumentException -  
OneWireIOException -  
OneWireException -  

readSubkey

public void readSubkey(byte[] data,
                       int key,
                       byte[] passwd)
                throws OneWireIOException,
                       OneWireException,
                       java.lang.IllegalArgumentException
Reads the subkey requested with the given key name and password. Note that this method allows for reading from the subkey data only which starts at address 0x10 within a key. It does not allow reading from any earlier address within a key because the device cannot be force to allow reading the password. This is why the subkey number is or-ed with 0x10 in creating the address in bytes 1 and 2 of the sendBlock.
Parameters:
data - buffer of length 64 into which to write the data
key - number indicating the key to be read: 0, 1, or 2
passwd - password of destination subkey
Throws:
java.lang.IllegalArgumentException -  
OneWireIOException -  
OneWireException -  

writePassword

public void writePassword(int key,
                          byte[] oldName,
                          byte[] newName,
                          byte[] newPasswd)
                   throws OneWireIOException,
                          OneWireException,
                          java.lang.IllegalArgumentException
Writes a new identifier and password to the secure subkey iButton
Parameters:
key - number indicating the key to be read: 0, 1, or 2
oldName - identifier of the key used to confirm the correct key's password to be changed. Must be exactly length 8.
newName - identifier to be used for the key with the new password. Must be exactly length 8.
newPasswd - new password for destination subkey. Must be exactly length 8.
Throws:
java.lang.IllegalArgumentException -  
OneWireIOException -  
OneWireException -  

writeSubkey

public void writeSubkey(int key,
                        int addr,
                        byte[] passwd,
                        byte[] data)
                 throws OneWireIOException,
                        OneWireException,
                        java.lang.IllegalArgumentException
Writes new data to the secure subkey
Parameters:
key - number indicating the key to be written: 0, 1, or 2
addr - address to start writing at ( 0x00 to 0x3F )
passwd - passwird for the subkey
data - data to be written
Throws:
java.lang.IllegalArgumentException -  
OneWireIOException -  
OneWireException -