Package com.dalsemi.onewire.adapter
Class DSPortAdapter
java.lang.Object
com.dalsemi.onewire.adapter.DSPortAdapter
- Direct Known Subclasses:
DumbAdapter
,LSerialAdapter
,PDKAdapterUSB
,TMEXAdapter
,USerialAdapter
The abstract base class for all 1-Wire port adapter objects. An
implementation class of this type is therefore independent of the adapter
type. Instances of valid DSPortAdapter's are retrieved from methods in
OneWireAccessProvider
.
The DSPortAdapter methods can be organized into the following categories:
- Information
- Port Selection
- Adapter Capabilities
- 1-Wire Network Semaphore
- 1-Wire Device Discovery
- Selective Search Options
- Search With Automatic 1-Wire Container creation
- Search With NO 1-Wire Container creation
- Manual 1-Wire Container creation
- 1-Wire Network low level access (usually not called directly)
- Device Selection and Presence Detect
- Raw 1-Wire IO
- 1-Wire Speed and Power Selection
- Advanced
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Condition for power state change, after next bit communicationstatic final int
Condition for power state change, after next byte communicationstatic final int
Condition for power state change, immediatestatic final int
Duration used in delivering power to the 1-Wire, current detectstatic final int
Duration used in delivering power to the 1-Wire, 480 usstatic final int
Duration used in delivering power to the 1-Wire, 4 secondstatic final int
Duration used in delivering power to the 1-Wire, 1/2 secondstatic final int
Duration used in delivering power to the 1-Wire, infinitestatic final int
Duration used in delivering power to the 1-Wire, 1 secondstatic final int
Duration used in delivering power to the 1-Wire, smart completestatic final int
Duration used in delivering power to the 1-Wire, 2 secondsstatic final char
1-Wire Network level, (strong pulldown to 0Volts, reset 1-Wire)static final char
1-Wire Network level, normal (weak 5Volt pullup)static final char
1-Wire Network level, (strong 5Volt pullup, used for power delivery)static final char
1-Wire Network level, (strong 12Volt pullup, used to program eprom )static final int
1-Wire Network reset result = alarmstatic final int
1-Wire Network reset result = no presencestatic final int
1-Wire Network reset result = presencestatic final int
1-Wire Network reset result = shortedstatic final int
Speed modes for 1-Wire Network, flexible for long linesstatic final int
Speed modes for 1-Wire Network, hyperdrivestatic final int
Speed modes for 1-Wire Network, overdrivestatic final int
Speed modes for 1-Wire Network, regular -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Detects adapter presence on the selected port.void
assertSelect
(byte[] address) Selects the specified iButton or 1-Wire device by broadcasting its address.void
assertSelect
(long address) Selects the specified iButton or 1-Wire device by broadcasting its address.void
assertSelect
(String address) Selects the specified iButton or 1-Wire device by broadcasting its address.abstract boolean
beginExclusive
(boolean blocking) Gets exclusive use of the 1-Wire to communicate with an iButton or 1-Wire Device.boolean
canBreak()
Returns whether adapter can physically support 0 volt 'break' mode.boolean
Returns whether the adapter can physically support strong 5 volt power mode.boolean
Returns whether the adapter can physically support "smart" strong 5 volt power mode.boolean
canFlex()
Returns whether the adapter can physically support flex speed mode.boolean
Returns whether the adapter can physically support hyperdrive mode.boolean
Returns whether adapter can physically support overdrive mode.boolean
Returns whether adapter can physically support 12 volt power mode.abstract void
dataBlock
(byte[] dataBlock, int off, int len) Sends a block of data and returns the data received in the same array.abstract void
Relinquishes exclusive control of the 1-Wire Network.boolean
Returns true if the given object is the same or equivalent to this DSPortAdapter.void
excludeFamily
(byte[] family) Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices.void
excludeFamily
(int family) Takes an integer family code to avoid when searching for iButtons.abstract boolean
Returnstrue
if the first iButton or 1-Wire device is found on the 1-Wire Network.abstract boolean
Returnstrue
if the next iButton or 1-Wire device is found.abstract void
freePort()
Frees ownership of the selected port, if it is currently owned, back to the system.Retrieves the address of the adapter, if it has one.abstract String
Retrieves the name of the port adapter as a string.Retrieves the version of the adapter.abstract void
getAddress
(byte[] address) Copies the 'current' 1-Wire device address being used by the adapter into the array.long
Gets the 'current' 1-Wire device address being used by the adapter as a long.Gets the 'current' 1-Wire device address being used by the adapter as a String.Returns an enumeration ofOneWireContainer
objects corresponding to all of the iButtons or 1-Wire devices found on the 1-Wire Network.abstract boolean
getBit()
Gets a bit from the 1-Wire Network.abstract void
getBlock
(byte[] arr, int len) Gets a block of data from the 1-Wire Network and write it into the provided array.abstract void
getBlock
(byte[] arr, int off, int len) Gets a block of data from the 1-Wire Network and write it into the provided array.abstract byte[]
getBlock
(int len) Gets a block of data from the 1-Wire Network.abstract int
getByte()
Gets a byte from the 1-Wire Network.abstract String
Retrieves a version string for this class.Constructs aOneWireContainer
object using the current 1-Wire network address.getDeviceContainer
(byte[] address) Constructs aOneWireContainer
object with a user supplied 1-Wire network address.getDeviceContainer
(long address) Constructs aOneWireContainer
object with a user supplied 1-Wire network address.getDeviceContainer
(String address) Constructs aOneWireContainer
object with a user supplied 1-Wire network address.Returns aOneWireContainer
object corresponding to the first iButton or 1-Wire device found on the 1-Wire Network.Returns aOneWireContainer
object corresponding to the next iButton or 1-Wire device found.abstract String
Retrieves the name of the selected port as aString
.abstract Enumeration<String>
Retrieves a list of the platform appropriate port names for this adapter.abstract String
Retrieves a description of the port required by this port adapter.int
getSpeed()
Returns the current data transfer speed on the 1-Wire Network.boolean
isAlarming
(byte[] address) Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state.boolean
isAlarming
(long address) Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state.boolean
isAlarming
(String address) Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state.boolean
isPresent
(byte[] address) Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.boolean
isPresent
(long address) Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.boolean
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.protected boolean
isValidFamily
(byte[] address) Checks to see if the family found is in the desired include group.abstract void
putBit
(boolean bitValue) Sends a bit to the 1-Wire Network.abstract void
putByte
(int byteValue) Sends a byte to the 1-Wire Network.void
registerOneWireContainerClass
(int family, Class<?> OneWireContainerClass) Registers a user providedOneWireContainer
class.abstract int
reset()
Sends a Reset to the 1-Wire Network.boolean
select
(byte[] address) Selects the specified iButton or 1-Wire device by broadcasting its address.boolean
select
(long address) Selects the specified iButton or 1-Wire device by broadcasting its address.boolean
Selects the specified iButton or 1-Wire device by broadcasting its address.abstract boolean
selectPort
(String portName) Specifies a platform appropriate port name for this adapter.abstract void
Sets the 1-Wire Network search to not perform a 1-Wire reset before a search.void
setPowerDuration
(int timeFactor) Sets the duration to supply power to the 1-Wire Network.void
Sets the 1-Wire Network voltage to normal level.void
setProgramPulseDuration
(int timeFactor) Sets the duration for providing a program pulse on the 1-Wire Network.abstract void
Sets the 1-Wire Network search to find all iButtons and 1-Wire devices whether they are in an 'Alarm' state or not and restores the default setting of providing a 1-Wire reset command before each search.abstract void
Sets the 1-Wire Network search to find only iButtons and 1-Wire devices that are in an 'Alarm' state that signals a need for attention.void
setSpeed
(int speed) Sets the new speed of data transfer on the 1-Wire Network.void
Sets the 1-Wire Network voltage to 0 volts.boolean
startPowerDelivery
(int changeCondition) Sets the 1-Wire Network voltage to supply power to a 1-Wire device.boolean
startProgramPulse
(int changeCondition) Sets the 1-Wire Network voltage to eprom programming level.void
Removes any selectivity during a search for iButtons or 1-Wire devices by family type.void
targetFamily
(byte[] family) Takes an array of bytes to use for selectively searching for acceptable family codes.void
targetFamily
(int family) Takes an integer to selectively search for this desired family type.toString()
Returns a string representation of this DSPortAdapter, in the format of "".
-
Field Details
-
SPEED_REGULAR
public static final int SPEED_REGULARSpeed modes for 1-Wire Network, regular- See Also:
-
SPEED_FLEX
public static final int SPEED_FLEXSpeed modes for 1-Wire Network, flexible for long lines- See Also:
-
SPEED_OVERDRIVE
public static final int SPEED_OVERDRIVESpeed modes for 1-Wire Network, overdrive- See Also:
-
SPEED_HYPERDRIVE
public static final int SPEED_HYPERDRIVESpeed modes for 1-Wire Network, hyperdrive- See Also:
-
LEVEL_NORMAL
public static final char LEVEL_NORMAL1-Wire Network level, normal (weak 5Volt pullup)- See Also:
-
LEVEL_POWER_DELIVERY
public static final char LEVEL_POWER_DELIVERY1-Wire Network level, (strong 5Volt pullup, used for power delivery)- See Also:
-
LEVEL_BREAK
public static final char LEVEL_BREAK1-Wire Network level, (strong pulldown to 0Volts, reset 1-Wire)- See Also:
-
LEVEL_PROGRAM
public static final char LEVEL_PROGRAM1-Wire Network level, (strong 12Volt pullup, used to program eprom )- See Also:
-
RESET_NOPRESENCE
public static final int RESET_NOPRESENCE1-Wire Network reset result = no presence- See Also:
-
RESET_PRESENCE
public static final int RESET_PRESENCE1-Wire Network reset result = presence- See Also:
-
RESET_ALARM
public static final int RESET_ALARM1-Wire Network reset result = alarm- See Also:
-
RESET_SHORT
public static final int RESET_SHORT1-Wire Network reset result = shorted- See Also:
-
CONDITION_NOW
public static final int CONDITION_NOWCondition for power state change, immediate- See Also:
-
CONDITION_AFTER_BIT
public static final int CONDITION_AFTER_BITCondition for power state change, after next bit communication- See Also:
-
CONDITION_AFTER_BYTE
public static final int CONDITION_AFTER_BYTECondition for power state change, after next byte communication- See Also:
-
DELIVERY_HALF_SECOND
public static final int DELIVERY_HALF_SECONDDuration used in delivering power to the 1-Wire, 1/2 second- See Also:
-
DELIVERY_ONE_SECOND
public static final int DELIVERY_ONE_SECONDDuration used in delivering power to the 1-Wire, 1 second- See Also:
-
DELIVERY_TWO_SECONDS
public static final int DELIVERY_TWO_SECONDSDuration used in delivering power to the 1-Wire, 2 seconds- See Also:
-
DELIVERY_FOUR_SECONDS
public static final int DELIVERY_FOUR_SECONDSDuration used in delivering power to the 1-Wire, 4 second- See Also:
-
DELIVERY_SMART_DONE
public static final int DELIVERY_SMART_DONEDuration used in delivering power to the 1-Wire, smart complete- See Also:
-
DELIVERY_INFINITE
public static final int DELIVERY_INFINITEDuration used in delivering power to the 1-Wire, infinite- See Also:
-
DELIVERY_CURRENT_DETECT
public static final int DELIVERY_CURRENT_DETECTDuration used in delivering power to the 1-Wire, current detect- See Also:
-
DELIVERY_EPROM
public static final int DELIVERY_EPROMDuration used in delivering power to the 1-Wire, 480 us- See Also:
-
-
Constructor Details
-
DSPortAdapter
public DSPortAdapter()
-
-
Method Details
-
getAdapterName
Retrieves the name of the port adapter as a string. The 'Adapter' is a device that connects to a 'port' that allows one to communicate with an iButton or other 1-Wire device. As example of this is 'DS9097U'.- Returns:
String
representation of the port adapter.
-
getPortTypeDescription
Retrieves a description of the port required by this port adapter. An example of a 'Port' would 'serial communication port'.- Returns:
String
description of the port type required.
-
getClassVersion
Retrieves a version string for this class.- Returns:
- version string
-
getPortNames
Retrieves a list of the platform appropriate port names for this adapter. A port must be selected with the method 'selectPort' before any other communication methods can be used. Using a communication method before 'selectPort' will result in aOneWireException
exception.- Returns:
Enumeration
of typeString
that contains the port names
-
registerOneWireContainerClass
public void registerOneWireContainerClass(int family, Class<?> OneWireContainerClass) throws OneWireException Registers a user providedOneWireContainer
class. Using this method will override the Maxim Integrated Products provided container class when using the getDeviceContainer() method. The registered container state is only stored for the current instance ofDSPortAdapter
, and is not statically shared. TheOneWireContainerClass
must extendcom.dalsemi.onewire.container.OneWireContainer
otherwise aClassCastException
will be thrown. The older duplicate family will be removed from registration when a collision occurs. Passing null as a parameter for theOneWireContainerClass
will result in the removal of any entry associated with the family.- Parameters:
family
- the code of the family type to associate with this class.OneWireContainerClass
- User provided class- Throws:
OneWireException
- IfOneWireContainerClass
is not found.ClassCastException
- If user suppliedOneWireContainer
does not extendcom.dalsemi.onewire.container.OneWireContainer
.
-
selectPort
Specifies a platform appropriate port name for this adapter. Note that even though the port has been selected, it's ownership may be relinquished if it is not currently held in a 'exclusive' block. This class will then try to re-acquire the port when needed. If the port cannot be re-acquired when the exceptionPortInUseException
will be thrown.- Parameters:
portName
- name of the target port, retrieved from getPortNames()- Returns:
true
if the port was acquired,false
if the port is not available.- Throws:
OneWireIOException
- If port does not exist, or unable to communicate with port.OneWireException
- If port does not exist
-
freePort
Frees ownership of the selected port, if it is currently owned, back to the system. This should only be called if the recently selected port does not have an adapter, or at the end of your application's use of the port.- Throws:
OneWireException
- If port does not exist
-
getPortName
Retrieves the name of the selected port as aString
.- Returns:
String
of selected port- Throws:
OneWireException
- if valid port not yet selected
-
adapterDetected
Detects adapter presence on the selected port.- Returns:
true
if the adapter is confirmed to be connected to the selected port,false
if the adapter is not connected.- Throws:
OneWireIOException
OneWireException
-
getAdapterVersion
Retrieves the version of the adapter.- Returns:
String
of the adapter version. It will return "" if the adapter version is not or cannot be known. - Throws:
OneWireIOException
- on a 1-Wire communication error such as no device present. 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
-
getAdapterAddress
Retrieves the address of the adapter, if it has one.- Returns:
String
of the adapter address. It will return "" if the adapter does not have an address. The address is a string representation of an 1-Wire address. - Throws:
OneWireIOException
- on a 1-Wire communication error such as no device present. 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- See Also:
-
canOverdrive
Returns whether adapter can physically support overdrive mode.- Returns:
true
if this port adapter can do OverDrive,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
canHyperdrive
Returns whether the adapter can physically support hyperdrive mode.- Returns:
true
if this port adapter can do HyperDrive,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
canFlex
Returns whether the adapter can physically support flex speed mode.- Returns:
true
if this port adapter can do flex speed,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
canProgram
Returns whether adapter can physically support 12 volt power mode.- Returns:
true
if this port adapter can do Program voltage,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
canDeliverPower
Returns whether the adapter can physically support strong 5 volt power mode.- Returns:
true
if this port adapter can do strong 5 volt mode,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
canDeliverSmartPower
Returns whether the adapter can physically support "smart" strong 5 volt power mode. "smart" power delivery is the ability to deliver power until it is no longer needed. The current drop it detected and power delivery is stopped.- Returns:
true
if this port adapter can do "smart" strong 5 volt mode,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
canBreak
Returns whether adapter can physically support 0 volt 'break' mode.- Returns:
true
if this port adapter can do break,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication error with the adapterOneWireException
- on a setup error with the 1-Wire adapter
-
getAllDeviceContainers
public Enumeration<OneWireContainer> getAllDeviceContainers() throws OneWireIOException, OneWireExceptionReturns an enumeration ofOneWireContainer
objects corresponding to all of the iButtons or 1-Wire devices found on the 1-Wire Network. If no devices are found, then an empty enumeration will be returned. In most cases, all further communication with the device is done through the OneWireContainer.- Returns:
Enumeration
ofOneWireContainer
objects found on the 1-Wire Network.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getFirstDeviceContainer
Returns aOneWireContainer
object corresponding to the first iButton or 1-Wire device found on the 1-Wire Network. If no devices are found, then anull
reference will be returned. In most cases, all further communication with the device is done through theOneWireContainer
.- Returns:
- The first
OneWireContainer
object found on the 1-Wire Network, ornull
if no devices found. - Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getNextDeviceContainer
Returns aOneWireContainer
object corresponding to the next iButton or 1-Wire device found. The previous 1-Wire device found is used as a starting point in the search. If no devices are found, then anull
reference will be returned. In most cases, all further communication with the device is done through theOneWireContainer
.- Returns:
- The next
OneWireContainer
object found on the 1-Wire Network, ornull
if no iButtons found. - Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
findFirstDevice
Returnstrue
if the first iButton or 1-Wire device is found on the 1-Wire Network. If no devices are found, thenfalse
will be returned.- Returns:
true
if an iButton or 1-Wire device is found.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
findNextDevice
Returnstrue
if the next iButton or 1-Wire device is found. The previous 1-Wire device found is used as a starting point in the search. If no more devices are found thenfalse
will be returned.- Returns:
true
if an iButton or 1-Wire device is found.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getAddress
public abstract void getAddress(byte[] address) Copies the 'current' 1-Wire device address being used by the adapter into the array. This address is the last iButton or 1-Wire device found in a search (findNextDevice()...). This method copies into a user generated array to allow the reuse of the buffer. When searching many iButtons on the one wire network, this will reduce the memory burn rate.- Parameters:
address
- An array to be filled with the current iButton address.- See Also:
-
getAddressAsLong
public long getAddressAsLong()Gets the 'current' 1-Wire device address being used by the adapter as a long. This address is the last iButton or 1-Wire device found in a search (findNextDevice()...).- Returns:
long
representation of the iButton address- See Also:
-
getAddressAsString
Gets the 'current' 1-Wire device address being used by the adapter as a String. This address is the last iButton or 1-Wire device found in a search (findNextDevice()...).- Returns:
String
representation of the iButton address- See Also:
-
isPresent
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. This does not affect the 'current' device state information used in searches (findNextDevice...).- Parameters:
address
- device address to verify is present- Returns:
true
if device is present, elsefalse
.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
isPresent
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. This does not affect the 'current' device state information used in searches (findNextDevice...).- Parameters:
address
- device address to verify is present- Returns:
true
if device is present, elsefalse
.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
isPresent
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. This does not affect the 'current' device state information used in searches (findNextDevice...).- Parameters:
address
- device address to verify is present- Returns:
true
if device is present, elsefalse
.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
isAlarming
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. This does not affect the 'current' device state information used in searches (findNextDevice...).- Parameters:
address
- device address to verify is present and alarming- Returns:
true
if device is present and alarming, elsefalse
.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
isAlarming
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. This does not affect the 'current' device state information used in searches (findNextDevice...).- Parameters:
address
- device address to verify is present and alarming- Returns:
true
if device is present and alarming, elsefalse
.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
isAlarming
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. This does not affect the 'current' device state information used in searches (findNextDevice...).- Parameters:
address
- device address to verify is present and alarming- Returns:
true
if device is present and alarming, elsefalse
.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
select
Selects the specified iButton or 1-Wire device by broadcasting its address. This operation is referred to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...). Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).- Parameters:
address
- address of iButton or 1-Wire device to select- Returns:
true
if device address was sent,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
select
Selects the specified iButton or 1-Wire device by broadcasting its address. This operation is referred to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...). Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).- Parameters:
address
- address of iButton or 1-Wire device to select- Returns:
true
if device address was sent,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
select
Selects the specified iButton or 1-Wire device by broadcasting its address. This operation is referred to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...). Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).- Parameters:
address
- address of iButton or 1-Wire device to select- Returns:
true
if device address was sent,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
assertSelect
Selects the specified iButton or 1-Wire device by broadcasting its address. This operation is referred to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...). In addition, this method asserts that the select did find some devices on the 1-Wire net. If no devices were found, a OneWireException is thrown. Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).- Parameters:
address
- address of iButton or 1-Wire device to select- Throws:
OneWireIOException
- on a 1-Wire communication error, or if their are no devices on the 1-Wire net.OneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
assertSelect
Selects the specified iButton or 1-Wire device by broadcasting its address. This operation is referred to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...). In addition, this method asserts that the select did find some devices on the 1-Wire net. If no devices were found, a OneWireException is thrown. Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).- Parameters:
address
- address of iButton or 1-Wire device to select- Throws:
OneWireIOException
- on a 1-Wire communication error, or if their are no devices on the 1-Wire net.OneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
assertSelect
Selects the specified iButton or 1-Wire device by broadcasting its address. This operation is referred to a 'MATCH ROM' operation in the iButton and 1-Wire device data sheets. This does not affect the 'current' device state information used in searches (findNextDevice...). In addition, this method asserts that the select did find some devices on the 1-Wire net. If no devices were found, a OneWireException is thrown. Warning, this does not verify that the device is currently present on the 1-Wire Network (See isPresent).- Parameters:
address
- address of iButton or 1-Wire device to select- Throws:
OneWireIOException
- on a 1-Wire communication error, or if their are no devices on the 1-Wire net.OneWireException
- on a setup error with the 1-Wire adapter- See Also:
-
setSearchOnlyAlarmingDevices
public abstract void setSearchOnlyAlarmingDevices()Sets the 1-Wire Network search to find only iButtons and 1-Wire devices that are in an 'Alarm' state that signals a need for attention. Not all iButton types have this feature. Some that do: DS1994, DS1920, DS2407. This selective searching can be canceled with the 'setSearchAllDevices()' method.- See Also:
-
setNoResetSearch
public abstract void setNoResetSearch()Sets the 1-Wire Network search to not perform a 1-Wire reset before a search. This feature is chiefly used with the DS2409 1-Wire coupler. The normal reset before each search can be restored with the 'setSearchAllDevices()' method. -
setSearchAllDevices
public abstract void setSearchAllDevices()Sets the 1-Wire Network search to find all iButtons and 1-Wire devices whether they are in an 'Alarm' state or not and restores the default setting of providing a 1-Wire reset command before each search. (see setNoResetSearch() method).- See Also:
-
targetAllFamilies
public void targetAllFamilies()Removes any selectivity during a search for iButtons or 1-Wire devices by family type. The unique address for each iButton and 1-Wire device contains a family descriptor that indicates the capabilities of the device. -
targetFamily
public void targetFamily(int family) Takes an integer to selectively search for this desired family type. If this method is used, then no devices of other families will be found by any of the search methods.- Parameters:
family
- the code of the family type to target for searches- See Also:
-
targetFamily
public void targetFamily(byte[] family) Takes an array of bytes to use for selectively searching for acceptable family codes. If used, only devices with family codes in this array will be found by any of the search methods.- Parameters:
family
- array of the family types to target for searches- See Also:
-
excludeFamily
public void excludeFamily(int family) Takes an integer family code to avoid when searching for iButtons. or 1-Wire devices. If this method is used, then no devices of this family will be found by any of the search methods.- Parameters:
family
- the code of the family type NOT to target in searches- See Also:
-
excludeFamily
public void excludeFamily(byte[] family) Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices. If used, then no devices with family codes in this array will be found by any of the search methods.- Parameters:
family
- array of family cods NOT to target for searches- See Also:
-
beginExclusive
Gets exclusive use of the 1-Wire to communicate with an iButton or 1-Wire Device. This method should be used for critical sections of code where a sequence of commands must not be interrupted by communication of threads with other iButtons, and it is permissible to sustain a delay in the special case that another thread has already been granted exclusive access and this access has not yet been relinquished.It can be called through the OneWireContainer class by the end application if they want to ensure exclusive use. If it is not called around several methods then it will be called inside each method.
- Parameters:
blocking
-true
if want to block waiting for exclusive access to the adapter- Returns:
true
if blocking was false and a exclusive session with the adapter was acquired- Throws:
OneWireException
- on a setup error with the 1-Wire adapter
-
endExclusive
public abstract void endExclusive()Relinquishes exclusive control of the 1-Wire Network. This command dynamically marks the end of a critical section and should be used when exclusive control is no longer needed. -
putBit
Sends a bit to the 1-Wire Network.- Parameters:
bitValue
- the bit value to send to the 1-Wire Network.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getBit
Gets a bit from the 1-Wire Network.- Returns:
- the bit value received from the the 1-Wire Network.
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
putByte
Sends a byte to the 1-Wire Network.- Parameters:
byteValue
- the byte value to send to the 1-Wire Network.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getByte
Gets a byte from the 1-Wire Network.- Returns:
- the byte value received from the the 1-Wire Network.
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getBlock
Gets a block of data from the 1-Wire Network.- Parameters:
len
- length of data bytes to receive- Returns:
- the data received from the 1-Wire Network.
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getBlock
Gets a block of data from the 1-Wire Network and write it into the provided array.- Parameters:
arr
- array in which to write the received byteslen
- length of data bytes to receive- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
getBlock
public abstract void getBlock(byte[] arr, int off, int len) throws OneWireIOException, OneWireException Gets a block of data from the 1-Wire Network and write it into the provided array.- Parameters:
arr
- array in which to write the received bytesoff
- offset into the array to startlen
- length of data bytes to receive- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
dataBlock
public abstract void dataBlock(byte[] dataBlock, int off, int len) throws OneWireIOException, OneWireException Sends a block of data and returns the data received in the same array. This method is used when sending a block that contains reads and writes. The 'read' portions of the data block need to be pre-loaded with 0xFF's. It starts sending data from the index at offset 'off' for length 'len'.- Parameters:
dataBlock
- array of data to transfer to and from the 1-Wire Network.off
- offset into the array of data to startlen
- length of data to send / receive starting at 'off'- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
reset
Sends a Reset to the 1-Wire Network.- Returns:
- the result of the reset. Potential results are:
- 0 (RESET_NOPRESENCE) no devices present on the 1-Wire Network.
- 1 (RESET_PRESENCE) normal presence pulse detected on the 1-Wire Network indicating there is a device present.
- 2 (RESET_ALARM) alarming presence pulse detected on the 1-Wire Network indicating there is a device present and it is in the alarm condition. This is only provided by the DS1994/DS2404 devices.
- 3 (RESET_SHORT) indicates 1-Wire appears shorted. This can be transient conditions in a 1-Wire Network. Not all adapter types can detect this condition.
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
setPowerDuration
Sets the duration to supply power to the 1-Wire Network. This method takes a time parameter that indicates the program pulse length when the method startPowerDelivery().Note: to avoid getting an exception, use the canDeliverPower() and canDeliverSmartPower() method to check it's availability.
- Parameters:
timeFactor
-- 0 (DELIVERY_HALF_SECOND) provide power for 1/2 second.
- 1 (DELIVERY_ONE_SECOND) provide power for 1 second.
- 2 (DELIVERY_TWO_SECONDS) provide power for 2 seconds.
- 3 (DELIVERY_FOUR_SECONDS) provide power for 4 seconds.
- 4 (DELIVERY_SMART_DONE) provide power until the the device is no longer drawing significant power.
- 5 (DELIVERY_INFINITE) provide power until the setPowerNormal() method is called.
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
startPowerDelivery
Sets the 1-Wire Network voltage to supply power to a 1-Wire device. This method takes a time parameter that indicates whether the power delivery should be done immediately, or after certain conditions have been met.Note: to avoid getting an exception, use the canDeliverPower() and canDeliverSmartPower() method to check it's availability.
- Parameters:
changeCondition
-- 0 (CONDITION_NOW) operation should occur immediately.
- 1 (CONDITION_AFTER_BIT) operation should be pending execution immediately after the next bit is sent.
- 2 (CONDITION_AFTER_BYTE) operation should be pending execution immediately after next byte is sent.
- Returns:
true
if the voltage change was successful,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
setProgramPulseDuration
Sets the duration for providing a program pulse on the 1-Wire Network. This method takes a time parameter that indicates the program pulse length when the method startProgramPulse().Note: to avoid getting an exception, use the canDeliverPower() method to check it's availability.
- Parameters:
timeFactor
-- 7 (DELIVERY_EPROM) provide program pulse for 480 microseconds
- 5 (DELIVERY_INFINITE) provide power until the setPowerNormal() method is called.
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter
-
startProgramPulse
Sets the 1-Wire Network voltage to eprom programming level. This method takes a time parameter that indicates whether the power delivery should be done immediately, or after certain conditions have been met.Note: to avoid getting an exception, use the canProgram() method to check it's availability.
- Parameters:
changeCondition
-- 0 (CONDITION_NOW) operation should occur immediately.
- 1 (CONDITION_AFTER_BIT) operation should be pending execution immediately after the next bit is sent.
- 2 (CONDITION_AFTER_BYTE) operation should be pending execution immediately after next byte is sent.
- Returns:
true
if the voltage change was successful,false
otherwise.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter or the adapter does not support this operation
-
startBreak
Sets the 1-Wire Network voltage to 0 volts. This method is used rob all 1-Wire Network devices of parasite power delivery to force them into a hard reset.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter or the adapter does not support this operation
-
setPowerNormal
Sets the 1-Wire Network voltage to normal level. This method is used to disable 1-Wire conditions created by startPowerDelivery and startProgramPulse. This method will automatically be called if a communication method is called while an outstanding power command is taking place.- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter or the adapter does not support this operation
-
setSpeed
Sets the new speed of data transfer on the 1-Wire Network.- Parameters:
speed
-- 0 (SPEED_REGULAR) set to normal communication speed
- 1 (SPEED_FLEX) set to flexible communication speed used for long lines
- 2 (SPEED_OVERDRIVE) set to normal communication speed to overdrive
- 3 (SPEED_HYPERDRIVE) set to normal communication speed to hyperdrive
- >3 future speeds
- Throws:
OneWireIOException
- on a 1-Wire communication errorOneWireException
- on a setup error with the 1-Wire adapter or the adapter does not support this operation
-
getSpeed
public int getSpeed()Returns the current data transfer speed on the 1-Wire Network.- Returns:
int
representing the current 1-Wire speed- 0 (SPEED_REGULAR) set to normal communication speed
- 1 (SPEED_FLEX) set to flexible communication speed used for long lines
- 2 (SPEED_OVERDRIVE) set to normal communication speed to overdrive
- 3 (SPEED_HYPERDRIVE) set to normal communication speed to hyperdrive
- >3 future speeds
-
getDeviceContainer
Constructs aOneWireContainer
object with a user supplied 1-Wire network address.- Parameters:
address
- device address with which to create a new container- Returns:
- The
OneWireContainer
object - See Also:
-
getDeviceContainer
Constructs aOneWireContainer
object with a user supplied 1-Wire network address.- Parameters:
address
- device address with which to create a new container- Returns:
- The
OneWireContainer
object - See Also:
-
getDeviceContainer
Constructs aOneWireContainer
object with a user supplied 1-Wire network address.- Parameters:
address
- device address with which to create a new container- Returns:
- The
OneWireContainer
object - See Also:
-
getDeviceContainer
Constructs aOneWireContainer
object using the current 1-Wire network address. The internal state of the port adapter keeps track of the last address found and is able to create container objects from this state.- Returns:
- the
OneWireContainer
object
-
isValidFamily
protected boolean isValidFamily(byte[] address) Checks to see if the family found is in the desired include group.- Returns:
true
if in include group
-
equals
Returns true if the given object is the same or equivalent to this DSPortAdapter. -
toString
Returns a string representation of this DSPortAdapter, in the format of "".
-