com.dalsemi.onewire.container
Class OneWireContainer37

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
        |
        +--com.dalsemi.onewire.container.OneWireContainer37
All Implemented Interfaces:
PasswordContainer

public class OneWireContainer37
extends OneWireContainer
implements PasswordContainer

1-Wire® container for a 32K bytes of read-only and read/write password protected memory, DS1977. This container encapsulates the functionality of the 1-Wire family type 37 (hex).

Features

Memory

The memory can be accessed through the objects that are returned from the getMemoryBanks method.

The following is a list of the MemoryBank instances that are returned: For examples regarding memory operations,

Version:
1.00, 18 Aug 2003
Author:
jevans
See Also:
PasswordContainer

Field Summary
static byte COPY_SCRATCHPAD_PW_COMMAND
          1-Wire command for Copy Scratchpad With Password
static int PASSWORD_CONTROL_REGISTER
          Address of the Password Control Register.
static int READ_ACCESS_PASSWORD
          Address of Read Access Password.
static byte READ_MEMORY_PW_COMMAND
          1-Wire command for Read Memory With Password
static int READ_ONLY_PWD
           
static byte READ_SCRATCHPAD_COMMAND
          1-Wire command for Read Scratchpad
static byte READ_VERSION
          1-Wire command for getting Read Version
static int READ_WRITE_ACCESS_PASSWORD
          Address of the Read Write Access Password.
static int READ_WRITE_PWD
           
static byte VERIFY_PSW_COMMAND
          1-Wire command for Verifing the Password
static byte WRITE_SCRATCHPAD_COMMAND
          1-Wire command for Write Scratchpad
 
Constructor Summary
OneWireContainer37()
          Creates a new OneWireContainer for communication with a DS1977.
OneWireContainer37(DSPortAdapter sourceAdapter, byte[] newAddress)
          Creates a new OneWireContainer for communication with a DS1977.
OneWireContainer37(DSPortAdapter sourceAdapter, long newAddress)
          Creates a new OneWireContainer for communication with a DS1977.
OneWireContainer37(DSPortAdapter sourceAdapter, String newAddress)
          Creates a new OneWireContainer for communication with a DS1977.
 
Method Summary
 String getAlternateNames()
          Retrieves the alternate Dallas Semiconductor part numbers or names.
 void getContainerReadOnlyPassword(byte[] password, int offset)
          Returns the read password used by this container to read the memory of the device.
 void getContainerReadWritePassword(byte[] password, int offset)
          Returns the read/write password used by this container to read from and write to the memory of the device.
 void getContainerWriteOnlyPassword(byte[] password, int offset)
          Returns the read/write password used by this container to read from and write to the memory of the device.
 String getDescription()
          Gets a short description of the function of this iButton or 1-Wire Device type.
 boolean getDeviceReadOnlyPasswordEnable()
          Tells whether the read only password has been enabled.
 boolean getDeviceReadWritePasswordEnable()
          Tells whether the read/write password has been enabled.
 boolean getDeviceWriteOnlyPasswordEnable()
          Tells whether the write only password has been enabled.
 int getMaxSpeed()
          Returns the maximum speed this iButton device can communicate at.
 Enumeration getMemoryBanks()
          Gets an enumeration of memory bank instances that implement one or more of the following interfaces: MemoryBank, PagedMemoryBank, and OTPMemoryBank.
 String getName()
          Gets the Dallas Semiconductor part number of the iButton or 1-Wire Device as a java.lang.String.
 int getReadOnlyPasswordAddress()
          Retrieves the address the read only password starts
 int getReadOnlyPasswordLength()
          Retrieves the password length for the read-only password.
 int getReadWritePasswordAddress()
          Retrieves the address the read/write password starts
 int getReadWritePasswordLength()
          Retrieves the password length for the read/write password.
 int getWriteOnlyPasswordAddress()
          Retrieves the address the write only password starts
 int getWriteOnlyPasswordLength()
          Retrieves the password length for the write-only password.
 boolean hasReadOnlyPassword()
          Tells whether the device has a read only password.
 boolean hasReadWritePassword()
          Tells whether the device has a read/write password.
 boolean hasSinglePasswordEnable()
          Returns true if this device has the capability to enable one type of password while leaving another type disabled.
 boolean hasWriteOnlyPassword()
          Tells whether the device has a write only password.
 boolean isContainerReadOnlyPasswordSet()
          Returns true if the container's read password has been set.
 boolean isContainerReadWritePasswordSet()
          Returns true if the container's read/write password has been set.
 boolean isContainerWriteOnlyPasswordSet()
          Returns true if the container's read/write password has been set.
 void setContainerReadOnlyPassword(byte[] password, int offset)
          Sets the value of the read password for the container.
 void setContainerReadWritePassword(byte[] password, int offset)
          Sets the value of the read/write password for the container.
 void setContainerWriteOnlyPassword(byte[] password, int offset)
          Sets the value of the read/write password for the container.
 void setDevicePasswordEnable(boolean enableReadOnly, boolean enableReadWrite, boolean enableWriteOnly)
          Enables/disables passwords by writing to the devices password control register.
 void setDevicePasswordEnableAll(boolean enableAll)
          Enables/Disables passwords for this device.
 void setDeviceReadOnlyPassword(byte[] password, int offset)
          Attempts to change the value of the read password in the device's register.
 void setDeviceReadWritePassword(byte[] password, int offset)
          Attempts to change the value of the read/write password in the device's register.
 void setDeviceWriteOnlyPassword(byte[] password, int offset)
          Attempts to change the value of the write only password in the device's register.
 void setSpeedCheck(boolean doSpeedCheck)
          Directs the container to avoid the calls to doSpeed() in methods that communicate with the Thermocron.
 void setupContainer(DSPortAdapter sourceAdapter, byte[] newAddress)
          Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
 void setupContainer(DSPortAdapter sourceAdapter, long newAddress)
          Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
 void setupContainer(DSPortAdapter sourceAdapter, String newAddress)
          Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
 boolean verifyPassword(byte[] password, int offset, int type)
           
 
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, hashCode, isAlarming, isPresent, setSpeed, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

WRITE_SCRATCHPAD_COMMAND

public static final byte WRITE_SCRATCHPAD_COMMAND
1-Wire command for Write Scratchpad

READ_SCRATCHPAD_COMMAND

public static final byte READ_SCRATCHPAD_COMMAND
1-Wire command for Read Scratchpad

COPY_SCRATCHPAD_PW_COMMAND

public static final byte COPY_SCRATCHPAD_PW_COMMAND
1-Wire command for Copy Scratchpad With Password

READ_MEMORY_PW_COMMAND

public static final byte READ_MEMORY_PW_COMMAND
1-Wire command for Read Memory With Password

VERIFY_PSW_COMMAND

public static final byte VERIFY_PSW_COMMAND
1-Wire command for Verifing the Password

READ_VERSION

public static final byte READ_VERSION
1-Wire command for getting Read Version

PASSWORD_CONTROL_REGISTER

public static final int PASSWORD_CONTROL_REGISTER
Address of the Password Control Register.

READ_ACCESS_PASSWORD

public static final int READ_ACCESS_PASSWORD
Address of Read Access Password.

READ_WRITE_ACCESS_PASSWORD

public static final int READ_WRITE_ACCESS_PASSWORD
Address of the Read Write Access Password.

READ_WRITE_PWD

public static final int READ_WRITE_PWD

READ_ONLY_PWD

public static final int READ_ONLY_PWD
Constructor Detail

OneWireContainer37

public OneWireContainer37()
Creates a new OneWireContainer for communication with a DS1977. Note that the method setupContainer(DSPortAdapter,byte[]) must be called to set the correct DSPortAdapter device address.
See Also:
setupContainer(DSPortAdapter,byte[]), OneWireContainer37(DSPortAdapter,byte[]), OneWireContainer37(DSPortAdapter,long), OneWireContainer37(DSPortAdapter,String)

OneWireContainer37

public OneWireContainer37(DSPortAdapter sourceAdapter,
                          byte[] newAddress)
Creates a new OneWireContainer for communication with a DS1977.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton
newAddress - address of this DS1977
See Also:
OneWireContainer37(), OneWireContainer37(DSPortAdapter,long), OneWireContainer37(DSPortAdapter,String)

OneWireContainer37

public OneWireContainer37(DSPortAdapter sourceAdapter,
                          long newAddress)
Creates a new OneWireContainer for communication with a DS1977.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton
newAddress - address of this DS1977
See Also:
OneWireContainer37(), OneWireContainer37(DSPortAdapter,byte[]), OneWireContainer37(DSPortAdapter,String)

OneWireContainer37

public OneWireContainer37(DSPortAdapter sourceAdapter,
                          String newAddress)
Creates a new OneWireContainer for communication with a DS1977.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton
newAddress - address of this DS1977
See Also:
OneWireContainer37(), OneWireContainer37(DSPortAdapter,long), OneWireContainer37(DSPortAdapter,String)
Method Detail

setupContainer

public void setupContainer(DSPortAdapter sourceAdapter,
                           byte[] newAddress)
Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
Overrides:
setupContainer in class OneWireContainer
Parameters:
sourceAdapter - adapter object required to communicate with this iButton
newAddress - address of this 1-Wire device
See Also:
Address

setupContainer

public void setupContainer(DSPortAdapter sourceAdapter,
                           long newAddress)
Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
Overrides:
setupContainer in class OneWireContainer
Parameters:
sourceAdapter - adapter object required to communicate with this iButton
newAddress - address of this 1-Wire device
See Also:
Address

setupContainer

public void setupContainer(DSPortAdapter sourceAdapter,
                           String newAddress)
Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
Overrides:
setupContainer in class OneWireContainer
Parameters:
sourceAdapter - adapter object required to communicate with this iButton
newAddress - address of this 1-Wire device
See Also:
Address

getMemoryBanks

public Enumeration getMemoryBanks()
Gets an enumeration of memory bank instances that implement one or more of the following interfaces: MemoryBank, PagedMemoryBank, and OTPMemoryBank.
Overrides:
getMemoryBanks in class OneWireContainer
Returns:
Enumeration of memory banks

getMaxSpeed

public int getMaxSpeed()
Returns the maximum speed this iButton device can communicate at.
Overrides:
getMaxSpeed in class OneWireContainer
Returns:
maximum speed
See Also:
DSPortAdapter.setSpeed(int)

getName

public String getName()
Gets the Dallas Semiconductor part number of the iButton or 1-Wire Device as a java.lang.String. For example "DS1977".
Overrides:
getName in class OneWireContainer
Returns:
iButton or 1-Wire device name

getAlternateNames

public String getAlternateNames()
Retrieves the alternate Dallas Semiconductor part numbers or names. A 'family' of MicroLAN 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:
the alternate names for this iButton or 1-Wire device

getDescription

public String getDescription()
Gets a short description of the function of this iButton or 1-Wire Device type.
Overrides:
getDescription in class OneWireContainer
Returns:
device description

setSpeedCheck

public void setSpeedCheck(boolean doSpeedCheck)
Directs the container to avoid the calls to doSpeed() in methods that communicate with the Thermocron. To ensure that all parts can talk to the 1-Wire bus at their desired speed, each method contains a call to doSpeed(). However, this is an expensive operation. If a user manages the bus speed in an application, call this method with doSpeedCheck as false. The default behavior is to call doSpeed().
Parameters:
doSpeedCheck - true for doSpeed() to be called before every 1-Wire bus access, false to skip this expensive call
See Also:
OneWireContainer.doSpeed()

getReadOnlyPasswordLength

public int getReadOnlyPasswordLength()
                              throws OneWireException
Retrieves the password length for the read-only password.
Specified by:
getReadOnlyPasswordLength in interface PasswordContainer
Returns:
the read-only password length
Throws:
OneWireException -  

getReadWritePasswordLength

public int getReadWritePasswordLength()
                               throws OneWireException
Retrieves the password length for the read/write password.
Specified by:
getReadWritePasswordLength in interface PasswordContainer
Returns:
the read/write password length
Throws:
OneWireException -  

getWriteOnlyPasswordLength

public int getWriteOnlyPasswordLength()
                               throws OneWireException
Retrieves the password length for the write-only password.
Specified by:
getWriteOnlyPasswordLength in interface PasswordContainer
Returns:
the write-only password length
Throws:
OneWireException -  

getReadOnlyPasswordAddress

public int getReadOnlyPasswordAddress()
                               throws OneWireException
Retrieves the address the read only password starts
Specified by:
getReadOnlyPasswordAddress in interface PasswordContainer
Returns:
the address of the read only password

getReadWritePasswordAddress

public int getReadWritePasswordAddress()
                                throws OneWireException
Retrieves the address the read/write password starts
Specified by:
getReadWritePasswordAddress in interface PasswordContainer
Returns:
the address of the read/write password

getWriteOnlyPasswordAddress

public int getWriteOnlyPasswordAddress()
                                throws OneWireException
Retrieves the address the write only password starts
Specified by:
getWriteOnlyPasswordAddress in interface PasswordContainer
Returns:
the address of the write only password

hasReadOnlyPassword

public boolean hasReadOnlyPassword()
Tells whether the device has a read only password.
Specified by:
hasReadOnlyPassword in interface PasswordContainer
Returns:
if the device has a read only password

hasReadWritePassword

public boolean hasReadWritePassword()
Tells whether the device has a read/write password.
Specified by:
hasReadWritePassword in interface PasswordContainer
Returns:
if the device has a read/write password

hasWriteOnlyPassword

public boolean hasWriteOnlyPassword()
Tells whether the device has a write only password.
Specified by:
hasWriteOnlyPassword in interface PasswordContainer
Returns:
if the device has a write only password

getDeviceReadOnlyPasswordEnable

public boolean getDeviceReadOnlyPasswordEnable()
                                        throws OneWireException
Tells whether the read only password has been enabled.
Specified by:
getDeviceReadOnlyPasswordEnable in interface PasswordContainer
Returns:
the enabled status of the read only password
Throws:
OneWireException -  

getDeviceReadWritePasswordEnable

public boolean getDeviceReadWritePasswordEnable()
                                         throws OneWireException
Tells whether the read/write password has been enabled.
Specified by:
getDeviceReadWritePasswordEnable in interface PasswordContainer
Returns:
the enabled status of the read/write password
Throws:
OneWireException -  

getDeviceWriteOnlyPasswordEnable

public boolean getDeviceWriteOnlyPasswordEnable()
                                         throws OneWireException
Tells whether the write only password has been enabled.
Specified by:
getDeviceWriteOnlyPasswordEnable in interface PasswordContainer
Returns:
the enabled status of the write only password
Throws:
OneWireException -  

hasSinglePasswordEnable

public boolean hasSinglePasswordEnable()
Returns true if this device has the capability to enable one type of password while leaving another type disabled. i.e. if the device has Read-Only password protection and Write-Only password protection, this method indicates whether or not you can enable Read-Only protection while leaving the Write-Only protection disabled.
Specified by:
hasSinglePasswordEnable in interface PasswordContainer
Returns:
true if the device has the capability to enable one type of password while leaving another type disabled.

setDevicePasswordEnableAll

public void setDevicePasswordEnableAll(boolean enableAll)
                                throws OneWireException,
                                       OneWireIOException

Enables/Disables passwords for this device. If the part has more than one type of password (Read-Only, Write-Only, or Read/Write), all passwords will be enabled. This function is equivalent to the following: owc37.setDevicePasswordEnable( owc37.hasReadOnlyPassword(), owc37.hasReadWritePassword(), owc37.hasWriteOnlyPassword() );

For this to be successful, either write-protect passwords must be disabled, or the write-protect password(s) for this container must be set and must match the value of the write-protect password(s) in the device's register.

WARNING: Enabling passwords requires that both the read password and the read/write password be re-written to the part. Before calling this method, you should set the container read password and read/write password values. This will ensure that the correct value is written into the part.

Specified by:
setDevicePasswordEnableAll in interface PasswordContainer
Parameters:
enableAll - if true, all passwords are enabled. Otherwise, all passwords are disabled.

setDeviceReadOnlyPassword

public void setDeviceReadOnlyPassword(byte[] password,
                                      int offset)
                               throws OneWireException,
                                      OneWireIOException
Attempts to change the value of the read password in the device's register. For this to be successful, either passwords must be disabled, or the read/write password for this container must be set and must match the value of the read/write password in the device's register.

WARNING: Setting the read password requires that both the read password and the read/write password be written to the part. Before calling this method, you should set the container read/write password value. This will ensure that the correct value is written into the part.

Specified by:
setDeviceReadOnlyPassword in interface PasswordContainer
Parameters:
password - the new value of 8-byte device read password, to be copied into the devices register.
offset - the offset to start copying the 8 bytes from the array

setDeviceReadWritePassword

public void setDeviceReadWritePassword(byte[] password,
                                       int offset)
                                throws OneWireException,
                                       OneWireIOException
Attempts to change the value of the read/write password in the device's register. For this to be successful, either passwords must be disabled, or the read/write password for this container must be set and must match the current value of the read/write password in the device's register.
Specified by:
setDeviceReadWritePassword in interface PasswordContainer
Parameters:
password - the new value of 8-byte device read/write password, to be copied into the devices register.
offset - the offset to start copying the 8 bytes from the array

setDeviceWriteOnlyPassword

public void setDeviceWriteOnlyPassword(byte[] password,
                                       int offset)
                                throws OneWireException,
                                       OneWireIOException
Attempts to change the value of the write only password in the device's register. For this to be successful, either passwords must be disabled, or the read/write password for this container must be set and must match the current value of the read/write password in the device's register.
Specified by:
setDeviceWriteOnlyPassword in interface PasswordContainer
Parameters:
password - the new value of 8-byte device read/write password, to be copied into the devices register.
offset - the offset to start copying the 8 bytes from the array

setDevicePasswordEnable

public void setDevicePasswordEnable(boolean enableReadOnly,
                                    boolean enableReadWrite,
                                    boolean enableWriteOnly)
                             throws OneWireException,
                                    OneWireIOException

Enables/disables passwords by writing to the devices password control register. For this to be successful, either passwords must be disabled, or the read/write password for this container must be set and must match the current value of the read/write password in the device's register.

WARNING: Enabling passwords requires that both the read password and the read/write password be re-written to the part. Before calling this method, you should set the container read password and read/write password values. This will ensure that the correct value is written into the part.

Specified by:
setDevicePasswordEnable in interface PasswordContainer
Parameters:
enable - if true, device passwords will be enabled. All subsequent read and write operations will require that the passwords for the container are set.

setContainerReadOnlyPassword

public void setContainerReadOnlyPassword(byte[] password,
                                         int offset)
                                  throws OneWireException
Sets the value of the read password for the container. This is the value used by this container to read the memory of the device. If this password does not match the value of the read password in the device's password register, all subsequent read operations will fail.
Specified by:
setContainerReadOnlyPassword in interface PasswordContainer
Parameters:
password - New 8-byte value of container's read password.
offset - Index to start copying the password from the array.

getContainerReadOnlyPassword

public void getContainerReadOnlyPassword(byte[] password,
                                         int offset)
                                  throws OneWireException
Returns the read password used by this container to read the memory of the device.
Specified by:
getContainerReadOnlyPassword in interface PasswordContainer
Parameters:
password - Holds the 8-byte value of container's read password.
offset - Index to start copying the password into the array.

isContainerReadOnlyPasswordSet

public boolean isContainerReadOnlyPasswordSet()
                                       throws OneWireException
Returns true if the container's read password has been set. The return value is not affected by whether or not the read password of the container actually matches the value in the device's password register.
Specified by:
isContainerReadOnlyPasswordSet in interface PasswordContainer
Returns:
true if the container's read password has been set

setContainerReadWritePassword

public void setContainerReadWritePassword(byte[] password,
                                          int offset)
                                   throws OneWireException
Sets the value of the read/write password for the container. This is the value used by this container to read and write to the memory of the device. If this password does not match the value of the read/write password in the device's password register, all subsequent read and write operations will fail.
Specified by:
setContainerReadWritePassword in interface PasswordContainer
Parameters:
password - New 8-byte value of container's read/write password.
offset - Index to start copying the password from the array.

getContainerReadWritePassword

public void getContainerReadWritePassword(byte[] password,
                                          int offset)
                                   throws OneWireException
Returns the read/write password used by this container to read from and write to the memory of the device.
Specified by:
getContainerReadWritePassword in interface PasswordContainer
Parameters:
password - Holds the 8-byte value of container's read/write password.
offset - Index to start copying the password into the array.

isContainerReadWritePasswordSet

public boolean isContainerReadWritePasswordSet()
                                        throws OneWireException
Returns true if the container's read/write password has been set. The return value is not affected by whether or not the read/write password of the container actually matches the value in the device's password register.
Specified by:
isContainerReadWritePasswordSet in interface PasswordContainer
Returns:
true if the container's read/write password has been set.

setContainerWriteOnlyPassword

public void setContainerWriteOnlyPassword(byte[] password,
                                          int offset)
                                   throws OneWireException
Sets the value of the read/write password for the container. This is the value used by this container to read and write to the memory of the device. If this password does not match the value of the read/write password in the device's password register, all subsequent read and write operations will fail.
Specified by:
setContainerWriteOnlyPassword in interface PasswordContainer
Parameters:
password - New 8-byte value of container's read/write password.
offset - Index to start copying the password from the array.

getContainerWriteOnlyPassword

public void getContainerWriteOnlyPassword(byte[] password,
                                          int offset)
                                   throws OneWireException
Returns the read/write password used by this container to read from and write to the memory of the device.
Specified by:
getContainerWriteOnlyPassword in interface PasswordContainer
Parameters:
password - Holds the 8-byte value of container's read/write password.
offset - Index to start copying the password into the array.

isContainerWriteOnlyPasswordSet

public boolean isContainerWriteOnlyPasswordSet()
                                        throws OneWireException
Returns true if the container's read/write password has been set. The return value is not affected by whether or not the read/write password of the container actually matches the value in the device's password register.
Specified by:
isContainerWriteOnlyPasswordSet in interface PasswordContainer
Returns:
true if the container's read/write password has been set.

verifyPassword

public boolean verifyPassword(byte[] password,
                              int offset,
                              int type)
                       throws OneWireException,
                              OneWireIOException


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