Package com.dalsemi.onewire.container
Class OneWireContainer29
java.lang.Object
com.dalsemi.onewire.container.OneWireContainer
com.dalsemi.onewire.container.OneWireContainer29
- All Implemented Interfaces:
OneWireSensor
,SwitchContainer
1-Wire® container for a Single Addressable Switch, DS2408. This container encapsulates the functionality of the 1-Wire family type 29 (hex)
Features
- Eight channels of programmable I/O with open-drain outputs
- Logic level sensing of the PIO pin can be sensed
- Multiple DS2408's can be identified on a common 1-Wire bus and operated independently.
- Supports 1-Wire Conditional Search command with response controlled by programmable PIO conditions
- Supports Overdrive mode which boosts communication speed up to 142k bits per second.
Usage
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
Reset the activity latchesFields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newOneWireContainer
for communication with a DS2408.OneWireContainer29
(DSPortAdapter sourceAdapter, byte[] newAddress) Creates a newOneWireContainer
for communication with a DS2408.OneWireContainer29
(DSPortAdapter sourceAdapter, long newAddress) Creates a newOneWireContainer
for communication with a DS2408.OneWireContainer29
(DSPortAdapter sourceAdapter, String newAddress) Creates a newOneWireContainer
for communication with a DS2408. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activityConditionalSearch
(byte[] register) Checks if the activity latches are set for Conditional Search and if not sets it.void
andConditionalSearch
(byte[] register) Checks if the 'and' Conditional Search is set and if not sets it.void
Clears the activity latches the next time possible.void
clearPowerOnReset
(byte[] register) Checks if the Power On Reset if on and if so clears it.Retrieves the alternate Maxim Integrated Products part numbers or names.boolean
getChannelMask
(int channel, byte[] register) Retrieves the information if the channel is masked for the Conditional Search.boolean
getChannelPolarity
(int channel, byte[] register) Retrieves the polarity of the channel for the Conditional Search.Gets a short description of the function of this iButton or 1-Wire Device type.boolean
getLatchState
(int channel, byte[] state) Checks the latch state of the indicated channel.boolean
getLevel
(int channel, byte[] state) Checks the sensed level on the indicated channel.int
Returns the maximum speed this iButton or 1-Wire 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
getNumberChannels
(byte[] state) Gets the number of channels supported by this switch.boolean
getSensedActivity
(int channel, byte[] state) Checks if the indicated channel has experienced activity.boolean
getVCC
(byte[] register) Retrieves the state of the VCC pin.boolean
Checks if the channels of this switch support activity sensing.boolean
Checks if the channels of this switch support level sensing.boolean
Checks if the channels of this switch support 'smart on'.boolean
Checks if the channels of this switch are 'high side' switches.boolean
Checks if the channels of this switch require that only one channel is on at any one time.void
orConditionalSearch
(byte[] register) Checks if the 'or' Condition Search is set and if not sets it.void
pioConditionalSearch
(byte[] register) Checks if the 'PIO' Conditional Search is set for input and if not sets it.byte[]
Retrieves the 1-Wire device sensor state.byte[]
Retrieves the 1-Wire device register mask.void
setChannelMask
(int channel, boolean set, byte[] register) Sets the channel passed to the proper state depending on the set parameter for responding to the Conditional Search.void
setChannelPolarity
(int channel, boolean set, byte[] register) Sets the channel passed to the proper state depending on the set parameter for the correct polarity in the Conditional Search.void
setLatchState
(byte set, byte[] state) Sets the latch state for all of the channels.void
setLatchState
(int channel, boolean latchState, boolean doSmart, byte[] state) Sets the latch state of the indicated channel.void
setResetMode
(byte[] register, boolean set) Turns the Reset mode on/off.void
writeDevice
(byte[] state) Writes the 1-Wire device sensor state that have been changed by 'set' methods.void
writeRegister
(byte[] register) Writes the 1-Wire device register mask that have been changed by 'set' methods.Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, hashCode, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer, toString
-
Field Details
-
RESET_ACTIVITY_LATCHES
public static final byte RESET_ACTIVITY_LATCHESReset the activity latches- See Also:
-
-
Constructor Details
-
OneWireContainer29
public OneWireContainer29()Creates a newOneWireContainer
for communication with a DS2408. Note that the methodsetupContainer(com.dalsemi.onewire.adapter.DSPortAdapter,byte[])
must be called to set the correctDSPortAdapter
device address. -
OneWireContainer29
Creates a newOneWireContainer
for communication with a DS2408.- Parameters:
sourceAdapter
- adapter object required to communicate with this 1-Wire devicenewAddress
- address of this DS2408- See Also:
-
OneWireContainer29
Creates a newOneWireContainer
for communication with a DS2408.- Parameters:
sourceAdapter
- adapter object required to communicate with this 1-Wire devicenewAddress
- address of this DS2408- See Also:
-
OneWireContainer29
Creates a newOneWireContainer
for communication with a DS2408.- Parameters:
sourceAdapter
- adapter object required to communicate with this 1-Wire devicenewAddress
- address of this DS2408- See Also:
-
-
Method Details
-
getName
Gets the Maxim Integrated Products part number of the iButton or 1-Wire Device as ajava.lang.String
. For example "DS1992".- Overrides:
getName
in classOneWireContainer
- Returns:
- iButton or 1-Wire device name
-
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:
-
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
-
getMaxSpeed
public int getMaxSpeed()Returns the maximum speed this iButton or 1-Wire device can communicate at.- Overrides:
getMaxSpeed
in classOneWireContainer
- Returns:
- maximum speed
- See Also:
-
getNumberChannels
public int getNumberChannels(byte[] state) Gets the number of channels supported by this switch. Channel specific methods will use a channel number specified by an integer from [0 to (getNumberChannels(byte[])
- 1)]. Note that all devices of the same family will not necessarily have the same number of channels.- Specified by:
getNumberChannels
in interfaceSwitchContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- the number of channels for this device
- See Also:
-
isHighSideSwitch
public boolean isHighSideSwitch()Checks if the channels of this switch are 'high side' switches. This indicates that when 'on' ortrue
, the switch output is connect to the 1-Wire data. If this method returnsfalse
then when the switch is 'on' ortrue
, the switch is connected to ground.- Specified by:
isHighSideSwitch
in interfaceSwitchContainer
- Returns:
true
if the switch is a 'high side' switch,false
if the switch is a 'low side' switch- See Also:
-
hasActivitySensing
public boolean hasActivitySensing()Checks if the channels of this switch support activity sensing. If this method returnstrue
then the methodgetSensedActivity(int,byte[])
can be used.- Specified by:
hasActivitySensing
in interfaceSwitchContainer
- Returns:
true
if channels support activity sensing- See Also:
-
hasLevelSensing
public boolean hasLevelSensing()Checks if the channels of this switch support level sensing. If this method returnstrue
then the methodgetLevel(int,byte[])
can be used.- Specified by:
hasLevelSensing
in interfaceSwitchContainer
- Returns:
true
if channels support level sensing- See Also:
-
hasSmartOn
public boolean hasSmartOn()Checks if the channels of this switch support 'smart on'. Smart on is the ability to turn on a channel such that only 1-Wire device on this channel are awake and ready to do an operation. This greatly reduces the time to discover the device down a branch. If this method returnstrue
then the methodsetLatchState(int,boolean,boolean,byte[])
can be used with thedoSmart
parametertrue
.- Specified by:
hasSmartOn
in interfaceSwitchContainer
- Returns:
true
if channels support 'smart on'- See Also:
-
onlySingleChannelOn
public boolean onlySingleChannelOn()Checks if the channels of this switch require that only one channel is on at any one time. If this method returnstrue
then the methodsetLatchState(int,boolean,boolean,byte[])
will not only affect the state of the given channel but may affect the state of the other channels as well to insure that only one channel is on at a time.- Specified by:
onlySingleChannelOn
in interfaceSwitchContainer
- Returns:
true
if only one channel can be on at a time.- See Also:
-
getLevel
public boolean getLevel(int channel, byte[] state) Checks the sensed level on the indicated channel. To avoid an exception, verify that this switch has level sensing with thehasLevelSensing()
. Level sensing means that the device can sense the logic level on its PIO pin.- Specified by:
getLevel
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
true
if level sensed is 'high' andfalse
if level sensed is 'low'- See Also:
-
getLatchState
public boolean getLatchState(int channel, byte[] state) Checks the latch state of the indicated channel.- Specified by:
getLatchState
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
true
if channel latch is 'on' or conducting andfalse
if channel latch is 'off' and not conducting. Note that the actual output when the latch is 'on' is returned from theisHighSideSwitch()
method.- See Also:
-
getSensedActivity
Checks if the indicated channel has experienced activity. This occurs when the level on the PIO pins changes. To clear the activity that is reported, callclearActivity()
. To avoid an exception, verify that this device supports activity sensing by calling the methodhasActivitySensing()
.- Specified by:
getSensedActivity
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
true
if activity was detected andfalse
if no activity was detected- Throws:
OneWireException
- if this device does not have activity sensing- See Also:
-
clearActivity
Clears the activity latches the next time possible. For example, on a DS2406/07, this happens the next time the status is read withreadDevice()
.- Specified by:
clearActivity
in interfaceSwitchContainer
- Throws:
OneWireException
- if this device does not support activity sensing- See Also:
-
setLatchState
public void setLatchState(int channel, boolean latchState, boolean doSmart, byte[] state) Sets the latch state of the indicated channel. The methodwriteDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
.- Specified by:
setLatchState
in interfaceSwitchContainer
- Parameters:
channel
- channel to execute this operation, in the range [0 to (getNumberChannels(byte[])
- 1)]latchState
-true
to set the channel latch 'on' (conducting) andfalse
to set the channel latch 'off' (not conducting). Note that the actual output when the latch is 'on' is returned from theisHighSideSwitch()
method.doSmart
- If latchState is 'on'/true
then doSmart indicates if a 'smart on' is to be done. To avoid an exception check the capabilities of this device using thehasSmartOn()
method.state
- current state of the device returned fromreadDevice()
- See Also:
-
setLatchState
public void setLatchState(byte set, byte[] state) Sets the latch state for all of the channels. The methodwriteDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
.- Parameters:
set
- the state to set all of the channels, in the range [0 to (getNumberChannels(byte[])
- 1)]state
- current state of the device returned fromreadDevice()
- See Also:
-
readDevice
Retrieves the 1-Wire device sensor state. This state is returned as a byte array. Pass this byte array to the 'get' and 'set' methods. If the device state needs to be changed then call the 'writeDevice' to finalize the changes.- Specified by:
readDevice
in interfaceOneWireSensor
- Returns:
- 1-Wire device sensor state
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
readRegister
Retrieves the 1-Wire device register mask. This register is returned as a byte array. Pass this byte array to the 'get' and 'set' methods. If the device register mask needs to be changed then call the 'writeRegister' to finalize the changes.- Returns:
- 1-Wire device register mask
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
writeDevice
Writes the 1-Wire device sensor state that have been changed by 'set' methods. Only the state registers that changed are updated. This is done by referencing a field information appended to the state data.- Specified by:
writeDevice
in interfaceOneWireSensor
- Parameters:
state
- 1-Wire device sensor state- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
writeRegister
Writes the 1-Wire device register mask that have been changed by 'set' methods.- Parameters:
register
- 1-Wire device sensor state- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
setResetMode
Turns the Reset mode on/off.- Parameters:
set
- if 'TRUE' the reset mode will be set or 'FALSE' to turn it off.- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
getVCC
Retrieves the state of the VCC pin. If the pin is powered 'TRUE' is returned else 'FALSE' is returned if the pin is grounded.- Returns:
true
if VCC is powered andfalse
if it is grounded.- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
clearPowerOnReset
public void clearPowerOnReset(byte[] register) Checks if the Power On Reset if on and if so clears it.- Parameters:
register
- current register for conditional search, which if returned fromreadRegister()
-
orConditionalSearch
public void orConditionalSearch(byte[] register) Checks if the 'or' Condition Search is set and if not sets it.- Parameters:
register
- current register for conditional search, which if returned fromreadRegister()
-
andConditionalSearch
public void andConditionalSearch(byte[] register) Checks if the 'and' Conditional Search is set and if not sets it.- Parameters:
register
- current register for conditional search, which if returned fromreadRegister()
-
pioConditionalSearch
public void pioConditionalSearch(byte[] register) Checks if the 'PIO' Conditional Search is set for input and if not sets it.- Parameters:
register
- current register for conditional search, which if returned fromreadRegister()
-
activityConditionalSearch
public void activityConditionalSearch(byte[] register) Checks if the activity latches are set for Conditional Search and if not sets it.- Parameters:
register
- current register for conditional search, which if returned fromreadRegister()
-
setChannelMask
public void setChannelMask(int channel, boolean set, byte[] register) Sets the channel passed to the proper state depending on the set parameter for responding to the Conditional Search.- Parameters:
channel
- current channel to setset
- whether to turn the channel on/off for Conditional Searchregister
- current register for conditional search, which if returned fromreadRegister()
-
setChannelPolarity
public void setChannelPolarity(int channel, boolean set, byte[] register) Sets the channel passed to the proper state depending on the set parameter for the correct polarity in the Conditional Search.- Parameters:
channel
- current channel to setset
- whether to turn the channel on/off for polarity Conditional Searchregister
- current register for conditional search, which if returned fromreadRegister()
-
getChannelMask
public boolean getChannelMask(int channel, byte[] register) Retrieves the information if the channel is masked for the Conditional Search.- Parameters:
channel
- current channel to setregister
- current register for conditional search, which if returned fromreadRegister()
- Returns:
true
if the channel is masked andfalse
other wise.
-
getChannelPolarity
public boolean getChannelPolarity(int channel, byte[] register) Retrieves the polarity of the channel for the Conditional Search.- Parameters:
channel
- current channel to setregister
- current register for conditional search, which if returned fromreadRegister()
- Returns:
true
if the channel is masked andfalse
other wise.
-