Class OneWireContainer37
- All Implemented Interfaces:
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.
- 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
- Implements
- 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.
- Implements
- 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.
- Implements
- See the usage example in
OneWireContainer
to enumerate the MemoryBanks. - See the usage examples in
MemoryBank
andPagedMemoryBank
for bank specific operations.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
1-Wire command for Copy Scratchpad With Passwordstatic final int
Address of the Password Control Register.static final int
Address of Read Access Password.static final byte
1-Wire command for Read Memory With Passwordstatic final int
static final byte
1-Wire command for Read Scratchpadstatic final byte
1-Wire command for getting Read Versionstatic final int
Address of the Read Write Access Password.static final int
protected final byte[]
The current password for readingfrom this device.protected boolean
protected final byte[]
The current password for reading/writing from/to this device.protected boolean
static final byte
1-Wire command for Verifying the Passwordstatic final byte
1-Wire command for Write ScratchpadFields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newOneWireContainer
for communication with a DS1977.OneWireContainer37
(DSPortAdapter sourceAdapter, byte[] newAddress) Creates a newOneWireContainer
for communication with a DS1977.OneWireContainer37
(DSPortAdapter sourceAdapter, long newAddress) Creates a newOneWireContainer
for communication with a DS1977.OneWireContainer37
(DSPortAdapter sourceAdapter, String newAddress) Creates a newOneWireContainer
for communication with a DS1977. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the alternate Maxim Integrated Products 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.Gets a short description of the function of this iButton or 1-Wire Device type.boolean
Tells whether the read only password has been enabled.boolean
Tells whether the read/write password has been enabled.boolean
Tells whether the write only password has been enabled.int
Returns the maximum speed this iButton device can communicate at.Gets an enumeration of memory bank instances that implement one or more of the following interfaces:MemoryBank
,PagedMemoryBank
, andOTPMemoryBank
.getName()
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as ajava.lang.String
.int
Retrieves the address the read only password startsint
Retrieves the password length for the read-only password.int
Retrieves the address the read/write password startsint
Retrieves the password length for the read/write password.int
Retrieves the address the write only password startsint
Retrieves the password length for the write-only password.boolean
Tells whether the device has a read only password.boolean
Tells whether the device has a read/write password.boolean
Returns true if this device has the capability to enable one type of password while leaving another type disabled.boolean
Tells whether the device has a write only password.boolean
Returns true if the container's read password has been set.boolean
Returns true if the container's read/write password has been set.boolean
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
-
Field Details
-
readPassword
protected final byte[] readPasswordThe current password for readingfrom this device. -
readPasswordSet
protected boolean readPasswordSet -
readWritePassword
protected final byte[] readWritePasswordThe current password for reading/writing from/to this device. -
readWritePasswordSet
protected boolean readWritePasswordSet -
WRITE_SCRATCHPAD_COMMAND
public static final byte WRITE_SCRATCHPAD_COMMAND1-Wire command for Write Scratchpad- See Also:
-
READ_SCRATCHPAD_COMMAND
public static final byte READ_SCRATCHPAD_COMMAND1-Wire command for Read Scratchpad- See Also:
-
COPY_SCRATCHPAD_PW_COMMAND
public static final byte COPY_SCRATCHPAD_PW_COMMAND1-Wire command for Copy Scratchpad With Password- See Also:
-
READ_MEMORY_PW_COMMAND
public static final byte READ_MEMORY_PW_COMMAND1-Wire command for Read Memory With Password- See Also:
-
VERIFY_PSW_COMMAND
public static final byte VERIFY_PSW_COMMAND1-Wire command for Verifying the Password- See Also:
-
READ_VERSION
public static final byte READ_VERSION1-Wire command for getting Read Version- See Also:
-
PASSWORD_CONTROL_REGISTER
public static final int PASSWORD_CONTROL_REGISTERAddress of the Password Control Register.- See Also:
-
READ_ACCESS_PASSWORD
public static final int READ_ACCESS_PASSWORDAddress of Read Access Password.- See Also:
-
READ_WRITE_ACCESS_PASSWORD
public static final int READ_WRITE_ACCESS_PASSWORDAddress of the Read Write Access Password.- See Also:
-
READ_WRITE_PWD
public static final int READ_WRITE_PWD- See Also:
-
READ_ONLY_PWD
public static final int READ_ONLY_PWD- See Also:
-
-
Constructor Details
-
OneWireContainer37
public OneWireContainer37()Creates a newOneWireContainer
for communication with a DS1977. Note that the methodsetupContainer(DSPortAdapter,byte[])
must be called to set the correctDSPortAdapter
device address. -
OneWireContainer37
Creates a newOneWireContainer
for communication with a DS1977.- Parameters:
sourceAdapter
- adapter object required to communicate with this iButtonnewAddress
- address of this DS1977- See Also:
-
OneWireContainer37
Creates a newOneWireContainer
for communication with a DS1977.- Parameters:
sourceAdapter
- adapter object required to communicate with this iButtonnewAddress
- address of this DS1977- See Also:
-
OneWireContainer37
Creates a newOneWireContainer
for communication with a DS1977.- Parameters:
sourceAdapter
- adapter object required to communicate with this iButtonnewAddress
- address of this DS1977- See Also:
-
-
Method Details
-
setupContainer
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 classOneWireContainer
- Parameters:
sourceAdapter
- adapter object required to communicate with this iButtonnewAddress
- address of this 1-Wire device- See Also:
-
setupContainer
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 classOneWireContainer
- Parameters:
sourceAdapter
- adapter object required to communicate with this iButtonnewAddress
- address of this 1-Wire device- See Also:
-
setupContainer
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 classOneWireContainer
- Parameters:
sourceAdapter
- adapter object required to communicate with this iButtonnewAddress
- address of this 1-Wire device- See Also:
-
getMemoryBanks
Gets an enumeration of memory bank instances that implement one or more of the following interfaces:MemoryBank
,PagedMemoryBank
, andOTPMemoryBank
.- Overrides:
getMemoryBanks
in classOneWireContainer
- Returns:
Enumeration
of memory banks- See Also:
-
getMaxSpeed
public int getMaxSpeed()Returns the maximum speed this iButton device can communicate at.- Overrides:
getMaxSpeed
in classOneWireContainer
- Returns:
- maximum speed
- See Also:
-
getName
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as ajava.lang.String
. For example "DS1977".- Overrides:
getName
in classOneWireContainer
- Returns:
- iButton or 1-Wire device name
-
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 classOneWireContainer
- Returns:
- the alternate names for this iButton or 1-Wire device
-
getDescription
Gets a short description of the function of this iButton or 1-Wire Device type.- Overrides:
getDescription
in classOneWireContainer
- 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 todoSpeed()
. However, this is an expensive operation. If a user manages the bus speed in an application, call this method withdoSpeedCheck
asfalse
. The default behavior is to calldoSpeed()
.- Parameters:
doSpeedCheck
-true
fordoSpeed()
to be called before every 1-Wire bus access,false
to skip this expensive call- See Also:
-
getReadOnlyPasswordLength
Retrieves the password length for the read-only password.- Specified by:
getReadOnlyPasswordLength
in interfacePasswordContainer
- Returns:
- the read-only password length
- Throws:
OneWireException
-
getReadWritePasswordLength
Retrieves the password length for the read/write password.- Specified by:
getReadWritePasswordLength
in interfacePasswordContainer
- Returns:
- the read/write password length
- Throws:
OneWireException
-
getWriteOnlyPasswordLength
Retrieves the password length for the write-only password.- Specified by:
getWriteOnlyPasswordLength
in interfacePasswordContainer
- Returns:
- the write-only password length
- Throws:
OneWireException
-
getReadOnlyPasswordAddress
Retrieves the address the read only password starts- Specified by:
getReadOnlyPasswordAddress
in interfacePasswordContainer
- Returns:
- the address of the read only password
- Throws:
OneWireException
-
getReadWritePasswordAddress
Retrieves the address the read/write password starts- Specified by:
getReadWritePasswordAddress
in interfacePasswordContainer
- Returns:
- the address of the read/write password
- Throws:
OneWireException
-
getWriteOnlyPasswordAddress
Retrieves the address the write only password starts- Specified by:
getWriteOnlyPasswordAddress
in interfacePasswordContainer
- Returns:
- the address of the write only password
- Throws:
OneWireException
-
hasReadOnlyPassword
public boolean hasReadOnlyPassword()Tells whether the device has a read only password.- Specified by:
hasReadOnlyPassword
in interfacePasswordContainer
- 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 interfacePasswordContainer
- 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 interfacePasswordContainer
- Returns:
- if the device has a write only password
-
getDeviceReadOnlyPasswordEnable
Tells whether the read only password has been enabled.- Specified by:
getDeviceReadOnlyPasswordEnable
in interfacePasswordContainer
- Returns:
- the enabled status of the read only password
- Throws:
OneWireException
-
getDeviceReadWritePasswordEnable
Tells whether the read/write password has been enabled.- Specified by:
getDeviceReadWritePasswordEnable
in interfacePasswordContainer
- Returns:
- the enabled status of the read/write password
- Throws:
OneWireException
-
getDeviceWriteOnlyPasswordEnable
Tells whether the write only password has been enabled.- Specified by:
getDeviceWriteOnlyPasswordEnable
in interfacePasswordContainer
- 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 interfacePasswordContainer
- 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 interfacePasswordContainer
- Parameters:
enableAll
- iftrue
, 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 interfacePasswordContainer
- 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 interfacePasswordContainer
- 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 interfacePasswordContainer
- 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 interfacePasswordContainer
- Parameters:
enable
- iftrue
, 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
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 interfacePasswordContainer
- Parameters:
password
- New 8-byte value of container's read password.offset
- Index to start copying the password from the array.- Throws:
OneWireException
-
getContainerReadOnlyPassword
Returns the read password used by this container to read the memory of the device.- Specified by:
getContainerReadOnlyPassword
in interfacePasswordContainer
- 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
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 interfacePasswordContainer
- Returns:
true
if the container's read password has been set- Throws:
OneWireException
-
setContainerReadWritePassword
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 interfacePasswordContainer
- 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
Returns the read/write password used by this container to read from and write to the memory of the device.- Specified by:
getContainerReadWritePassword
in interfacePasswordContainer
- 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
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 interfacePasswordContainer
- Returns:
true
if the container's read/write password has been set.- Throws:
OneWireException
-
setContainerWriteOnlyPassword
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 interfacePasswordContainer
- 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
Returns the read/write password used by this container to read from and write to the memory of the device.- Specified by:
getContainerWriteOnlyPassword
in interfacePasswordContainer
- 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
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 interfacePasswordContainer
- Returns:
true
if the container's read/write password has been set.- Throws:
OneWireException
-
verifyPassword
public boolean verifyPassword(byte[] password, int offset, int type) throws OneWireException, OneWireIOException - Throws:
OneWireException
OneWireIOException
-