Class 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

    • 32K bytes EEPROM organized as pages of 64 bytes.
    • 512-bit scratchpad ensures integrity of data transfer
    • On-chip 16-bit CRC generator

    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:
    • Scratchpad with CRC and Password support
      • Implements MemoryBank, PagedMemoryBank
      • Size 64 starting at physical address 0
      • Features Read/Write not-general-purpose volatile
      • Pages 1 page of length 64 bytes
      • Page Features page-device-CRC
      • Extra information for each page Target address, offset, length 3
      • Supports Copy Scratchpad With Password command
    • Main Memory
      • Implements MemoryBank, PagedMemoryBank
      • Size 32704 starting at physical address 0
      • Features Read/Write general-purpose non-volatile
      • Pages 511 pages of length 64 bytes giving 61 bytes Packet data payload
      • Page Features page-device-CRC
      • Read-Only and Read/Write password if enabled, passwords are required for reading from and writing to the device.
    • Register control
      • Implements MemoryBank, PagedMemoryBank
      • Size 64 starting at physical address 32704
      • Features Read/Write not-general-purpose non-volatile
      • Pages 1 pages of length 64 bytes
      • Page Features page-device-CRC
      • Read-Only and Read/Write password if enabled, passwords are required for reading from and writing to the device.
    For examples regarding memory operations,
    See Also:
    PasswordContainer
    • Field Detail

      • readPassword

        protected final byte[] readPassword
        The current password for readingfrom this device.
      • readPasswordSet

        protected boolean readPasswordSet
      • readWritePassword

        protected final byte[] readWritePassword
        The current password for reading/writing from/to this device.
      • readWritePasswordSet

        protected boolean readWritePasswordSet
      • WRITE_SCRATCHPAD_COMMAND

        public static final byte WRITE_SCRATCHPAD_COMMAND
        1-Wire command for Write Scratchpad
        See Also:
        Constant Field Values
      • READ_SCRATCHPAD_COMMAND

        public static final byte READ_SCRATCHPAD_COMMAND
        1-Wire command for Read Scratchpad
        See Also:
        Constant Field Values
      • COPY_SCRATCHPAD_PW_COMMAND

        public static final byte COPY_SCRATCHPAD_PW_COMMAND
        1-Wire command for Copy Scratchpad With Password
        See Also:
        Constant Field Values
      • READ_MEMORY_PW_COMMAND

        public static final byte READ_MEMORY_PW_COMMAND
        1-Wire command for Read Memory With Password
        See Also:
        Constant Field Values
      • VERIFY_PSW_COMMAND

        public static final byte VERIFY_PSW_COMMAND
        1-Wire command for Verifying the Password
        See Also:
        Constant Field Values
      • READ_VERSION

        public static final byte READ_VERSION
        1-Wire command for getting Read Version
        See Also:
        Constant Field Values
      • PASSWORD_CONTROL_REGISTER

        public static final int PASSWORD_CONTROL_REGISTER
        Address of the Password Control Register.
        See Also:
        Constant Field Values
      • READ_ACCESS_PASSWORD

        public static final int READ_ACCESS_PASSWORD
        Address of Read Access Password.
        See Also:
        Constant Field Values
      • READ_WRITE_ACCESS_PASSWORD

        public static final int READ_WRITE_ACCESS_PASSWORD
        Address of the Read Write Access Password.
        See Also:
        Constant Field Values
    • 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,
                                   java.lang.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
      • getName

        public java.lang.String getName()
        Gets the Maxim Integrated Products 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 java.lang.String getAlternateNames()
        Retrieves the alternate Maxim Integrated Products 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 java.lang.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()
      • 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
      • 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.
        Throws:
        OneWireException
        OneWireIOException
      • 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
        Throws:
        OneWireException
        OneWireIOException
      • 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
        Throws:
        OneWireException
        OneWireIOException
      • 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
        Throws:
        OneWireException
        OneWireIOException
      • 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.
        Throws:
        OneWireException
        OneWireIOException
      • 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.
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException
      • 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
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException
      • 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.
        Throws:
        OneWireException