1-Wire API for .NET Version 4.00
Public Member Functions | Protected Attributes | Static Protected Attributes

NetAdapter Class Reference

Inherits com::dalsemi::onewire::adapter::DSPortAdapter, and com::dalsemi::onewire::adapter::NetAdapterConstants.

List of all members.

Public Member Functions

 NetAdapter ()
 Creates an instance of NetAdapter that isn't connected.
void setSecret (String secret)
 Sets the shared secret for authenticating this NetAdapter with a NetAdapterHost.
void resetSecret ()
 Resets the secret to be the default stored in the onewire.properties file (if there is one), or the default as defined by NetAdapterConstants.
void pingHost () throws OneWireException, OneWireIOException
 Sends a ping to the host, just to keep the connection alive.
boolean adapterDetected () throws OneWireIOException, OneWireException
 Detects adapter presence on the selected port.
String getAdapterName ()
 Retrieves the name of the port adapter as a string.
String getPortTypeDescription ()
 Retrieves a description of the port required by this port adapter.
String getClassVersion ()
 Retrieves a version string for this class.
Enumeration getPortNames ()
 Retrieves a list of the platform appropriate port names for this adapter.
boolean selectPort (String portName) throws OneWireIOException, OneWireException
 Specifies a platform appropriate port name for this adapter.
boolean selectPort (Socket sock) throws OneWireIOException, OneWireException
 New method, unique to NetAdapter.
void freePort () throws OneWireException
 Frees ownership of the selected port, if it is currently owned, back to the system.
String getPortName () throws OneWireException
 Retrieves the name of the selected port as a String.
boolean canOverdrive () throws OneWireIOException, OneWireException
 Returns whether adapter can physically support overdrive mode.
boolean canHyperdrive () throws OneWireIOException, OneWireException
 Returns whether the adapter can physically support hyperdrive mode.
boolean canFlex () throws OneWireIOException, OneWireException
 Returns whether the adapter can physically support flex speed mode.
boolean canProgram () throws OneWireIOException, OneWireException
 Returns whether adapter can physically support 12 volt power mode.
boolean canDeliverPower () throws OneWireIOException, OneWireException
 Returns whether the adapter can physically support strong 5 volt power mode.
boolean canDeliverSmartPower () throws OneWireIOException, OneWireException
 Returns whether the adapter can physically support "smart" strong 5 volt power mode.
boolean canBreak () throws OneWireIOException, OneWireException
 Returns whether adapter can physically support 0 volt 'break' mode.
boolean findFirstDevice () throws OneWireIOException, OneWireException
 Returns true if the first iButton or 1-Wire device is found on the 1-Wire Network.
boolean findNextDevice () throws OneWireIOException, OneWireException
 Returns true if the next iButton or 1-Wire device is found.
void getAddress (byte[] address)
 Copies the 'current' 1-Wire device address being used by the adapter into the array.
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.
void setNoResetSearch ()
 Sets the 1-Wire Network search to not perform a 1-Wire reset before a search.
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.
void targetAllFamilies ()
 Removes any selectivity during a search for iButtons or 1-Wire devices by family type.
void targetFamily (int family)
 Takes an integer to selectively search for this desired family type.
void targetFamily (byte family[])
 Takes an array of bytes to use for selectively searching for acceptable family codes.
void excludeFamily (int family)
 Takes an integer family code to avoid when searching for iButtons.
void excludeFamily (byte family[])
 Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices.
boolean beginExclusive (boolean blocking) throws OneWireException
 Gets exclusive use of the 1-Wire to communicate with an iButton or 1-Wire Device.
void endExclusive ()
 Relinquishes exclusive control of the 1-Wire Network.
int reset () throws OneWireIOException, OneWireException
 Sends a Reset to the 1-Wire Network.
void putBit (boolean bitValue) throws OneWireIOException, OneWireException
 Sends a bit to the 1-Wire Network.
boolean getBit () throws OneWireIOException, OneWireException
 Gets a bit from the 1-Wire Network.
void putByte (int byteValue) throws OneWireIOException, OneWireException
 Sends a byte to the 1-Wire Network.
int getByte () throws OneWireIOException, OneWireException
 Gets a byte from the 1-Wire Network.
byte[] getBlock (int len) throws OneWireIOException, OneWireException
 Gets a block of data from the 1-Wire Network.
void getBlock (byte[] arr, int len) throws OneWireIOException, OneWireException
 Gets a block of data from the 1-Wire Network and write it into the provided array.
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.
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.
void setPowerDuration (int timeFactor) throws OneWireIOException, OneWireException
 Sets the duration to supply power to the 1-Wire Network.
boolean startPowerDelivery (int changeCondition) throws OneWireIOException, OneWireException
 Sets the 1-Wire Network voltage to supply power to a 1-Wire device.
void setProgramPulseDuration (int timeFactor) throws OneWireIOException, OneWireException
 Sets the duration for providing a program pulse on the 1-Wire Network.
boolean startProgramPulse (int changeCondition) throws OneWireIOException, OneWireException
 Sets the 1-Wire Network voltage to eprom programming level.
void startBreak () throws OneWireIOException, OneWireException
 Sets the 1-Wire Network voltage to 0 volts.
void setPowerNormal () throws OneWireIOException, OneWireException
 Sets the 1-Wire Network voltage to normal level.
void setSpeed (int speed) throws OneWireIOException, OneWireException
 Sets the new speed of data transfer on the 1-Wire Network.
int getSpeed ()
 Returns the current data transfer speed on the 1-Wire Network.

Protected Attributes

Integer currentThreadHash = NOT_OWNED
 Keeps hash of current thread for exclusive lock.
Connection conn = EMPTY_CONNECTION
 instance for current connection, defaults to EMPTY
String portNameForReconnect = null
 portName For Reconnecting to Host
byte[] netAdapterSecret = null
 secret for authentication with the server
boolean useCustomSecret = false
 if true, the user used a custom secret
Boolean multicastEnabled = null
 indicates whether or not mulicast is enabled
String multicastGroup = null
 The multicast group to use for NetAdapter Datagram packets.
int datagramPort = -1
 The port to use for NetAdapter Datagram packets.

Static Protected Attributes

static final String UNSPECIFIED_ERROR = "An unspecified error occurred."
 Error message when neither RET_SUCCESS or RET_FAILURE are returned.
static final String COMM_FAILED = "IO Error: "
 Error message when I/O failure occurs.
static final Integer NOT_OWNED = new Integer(0)
 constant for no exclusive lock

Detailed Description

NetAdapter is a network-based DSPortAdapter. It allows for the use of an actual DSPortAdapter which isn't on the local machine, but rather is connected to another device which is reachable via a TCP/IP network connection.

The syntax for the selectPort(String) command is the hostname of the computer which hosts the actual DSPortAdapter and the TCP/IP port that the host is listening on. If the port number is not specified, a default value of 6161 is used. Here are a few examples to illustrate the syntax:

<P?The use of the NetAdapter is virtually identical to the use of any other DSPortAdapter. The only significant changes are the necessity of the 'host' component (see NetAdapterHost) and the discovery of hosts on your network. There are currently two techniques used for discovering all of the hosts: The look-up of each host from the onewire.properties file and the use of multicast sockets for automatic discovery.

In the onewire.properties file, you can add a host to your list of valid hosts by making a NetAdapter.host with an integer to distinguish the hosts. There is no limit on the number of hosts which can appear in this list, but the first one must be numbered '0'. These hosts will then be returned in the list of valid 'ports' from the selectPortNames() method. Note that there do not have to be any servers returned from selectPortNames() for the NetAdapter to be able to connect to them (so it isn't necessary to add these entries for it to function), but applications which allow a user to automatically select an appropriate adapter and a port from a given list will not function properly without it. For example:

The multicast socket technique allows you to automatically discover hosts on your subnet which are listening for multicast packets. By default, the multicast discovery of NetAdapter hosts is disabled. When enabled, the NetAdapter creates a multicast socket and looks for servers every time you call selectPortNames(). This will add a 1 second delay (due to the socket timeout) on calling the method. If you'd like to enable this feature, add the following line to your onewire.properties file:

The port used and the multicast group used for multicast sockets can also be changed. The group however, must fall withing a valid range. For more information about multicast sockets in Java, see the Java tutorial on networking at http://java.sun.com/docs/books/tutorial/. Change the defaults in the onewire.properties file with the following entries:

Once the NetAdapter is connected with a host, a version check is performed followed by a simple authentication step. The authentication is dependent upon a secret shared between the NetAdapter and the host. Both will use a default value, that each will agree with if you don't provide a secret of your own. To set the secret, add the following line to your onewire.properties file:

Optionally, the secret can be specified on a per-host basis by simply adding the secret after the port number followed by a colon. If no port number is specified, a double-colon is required. Here are examples:

All of the above mentioned properties can be set on the command-line as well as being set in the onewire.properties file. To set the properties on the command-line, use the -D option: java -DNetAdapter.Secret="custom secret" myApplication

The following is a list of all parameters that can be set for the NetAdapter, followed by default values where applicable.

If you wanted added security on the communication channel, an SSL socket (or similar custom socket implementation) can be used by circumventing the standard DSPortAdapter's selectPort(String) and using the NetAdapter-specific selectPort(Socket). For example:

    NetAdapter na = new NetAdapter();
    Socket secureSocket = // insert fancy secure socket implementation here
    na.selectPort(secureSocket);
 

 
For information on setting up the host component, see the JavaDocs
 for the NetAdapterHost
 
See also:
NetAdapterHost
Author:
SH
Version:
1.00, 9 Jan 2002

Constructor & Destructor Documentation

Creates an instance of NetAdapter that isn't connected.

Must call selectPort(String); or selectPort(Socket);


Member Function Documentation

boolean adapterDetected ( ) throws OneWireIOException, OneWireException [virtual]

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.
Exceptions:
OneWireIOException
OneWireException

Implements DSPortAdapter.

boolean beginExclusive ( boolean  blocking) throws OneWireException [virtual]

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:
blockingtrue if want to block waiting for an excluse access to the adapter
Returns:
true if blocking was false and a exclusive session with the adapter was aquired
Exceptions:
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

boolean canBreak ( ) throws OneWireIOException, OneWireException

Returns whether adapter can physically support 0 volt 'break' mode.

Returns:
true if this port adapter can do break, false otherwise.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean canDeliverPower ( ) throws OneWireIOException, OneWireException

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.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean canDeliverSmartPower ( ) throws OneWireIOException, OneWireException

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.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean canFlex ( ) throws OneWireIOException, OneWireException

Returns whether the adapter can physically support flex speed mode.

Returns:
true if this port adapter can do flex speed, false otherwise.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean canHyperdrive ( ) throws OneWireIOException, OneWireException

Returns whether the adapter can physically support hyperdrive mode.

Returns:
true if this port adapter can do HyperDrive, false otherwise.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean canOverdrive ( ) throws OneWireIOException, OneWireException

Returns whether adapter can physically support overdrive mode.

Returns:
true if this port adapter can do OverDrive, false otherwise.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean canProgram ( ) throws OneWireIOException, OneWireException

Returns whether adapter can physically support 12 volt power mode.

Returns:
true if this port adapter can do Program voltage, false otherwise.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error with the adapter
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

void dataBlock ( byte[]  dataBlock,
int  off,
int  len 
) throws OneWireIOException, OneWireException [virtual]

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:
dataBlockarray of data to transfer to and from the 1-Wire Network.
offoffset into the array of data to start
lenlength of data to send / receive starting at 'off'
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

void endExclusive ( ) [virtual]

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.

Implements DSPortAdapter.

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:
familythe code of the family type NOT to target in searches
See also:
com.dalsemi.onewire.utils.Address
targetAllFamilies

Reimplemented from DSPortAdapter.

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:
familyarray of family cods NOT to target for searches
See also:
com.dalsemi.onewire.utils.Address
targetAllFamilies

Reimplemented from DSPortAdapter.

boolean findFirstDevice ( ) throws OneWireIOException, OneWireException [virtual]

Returns true if the first iButton or 1-Wire device is found on the 1-Wire Network.

If no devices are found, then false will be returned.

Returns:
true if an iButton or 1-Wire device is found.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

boolean findNextDevice ( ) throws OneWireIOException, OneWireException [virtual]

Returns true 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 then false will be returned.

Returns:
true if an iButton or 1-Wire device is found.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

void freePort ( ) throws OneWireException [virtual]

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.

Exceptions:
OneWireExceptionIf port does not exist

Implements DSPortAdapter.

String getAdapterName ( ) [virtual]

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.

Implements DSPortAdapter.

void getAddress ( byte[]  address) [virtual]

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:
addressAn array to be filled with the current iButton address.
See also:
com.dalsemi.onewire.utils.Address

Implements DSPortAdapter.

boolean getBit ( ) throws OneWireIOException, OneWireException [virtual]

Gets a bit from the 1-Wire Network.

Returns:
the bit value recieved from the the 1-Wire Network.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

byte [] getBlock ( int  len) throws OneWireIOException, OneWireException [virtual]

Gets a block of data from the 1-Wire Network.

Parameters:
lenlength of data bytes to receive
Returns:
the data received from the 1-Wire Network.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

void getBlock ( byte[]  arr,
int  len 
) throws OneWireIOException, OneWireException [virtual]

Gets a block of data from the 1-Wire Network and write it into the provided array.

Parameters:
arrarray in which to write the received bytes
lenlength of data bytes to receive
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

void getBlock ( byte[]  arr,
int  off,
int  len 
) throws OneWireIOException, OneWireException [virtual]

Gets a block of data from the 1-Wire Network and write it into the provided array.

Parameters:
arrarray in which to write the received bytes
offoffset into the array to start
lenlength of data bytes to receive
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

int getByte ( ) throws OneWireIOException, OneWireException [virtual]

Gets a byte from the 1-Wire Network.

Returns:
the byte value received from the the 1-Wire Network.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

String getClassVersion ( ) [virtual]

Retrieves a version string for this class.

Returns:
version string

Implements DSPortAdapter.

String getPortName ( ) throws OneWireException [virtual]

Retrieves the name of the selected port as a String.

Returns:
String of selected port
Exceptions:
OneWireExceptionif valid port not yet selected

Implements DSPortAdapter.

Enumeration getPortNames ( ) [virtual]

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 communcation method before 'selectPort' will result in a OneWireException exception.

Returns:
Enumeration of type String that contains the port names

Implements DSPortAdapter.

String getPortTypeDescription ( ) [virtual]

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.

Implements DSPortAdapter.

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

Reimplemented from DSPortAdapter.

void pingHost ( ) throws OneWireException, OneWireIOException

Sends a ping to the host, just to keep the connection alive.

Although it currently is not implemented on the standard NetAdapterHost, this command is used as a signal to the NetAdapterSim to simulate some amount of time that has run.

void putBit ( boolean  bitValue) throws OneWireIOException, OneWireException [virtual]

Sends a bit to the 1-Wire Network.

Parameters:
bitValuethe bit value to send to the 1-Wire Network.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

void putByte ( int  byteValue) throws OneWireIOException, OneWireException [virtual]

Sends a byte to the 1-Wire Network.

Parameters:
byteValuethe byte value to send to the 1-Wire Network.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

int reset ( ) throws OneWireIOException, OneWireException [virtual]

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) inticates 1-Wire appears shorted. This can be transient conditions in a 1-Wire Network. Not all adapter types can detect this condition.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Implements DSPortAdapter.

boolean selectPort ( Socket  sock) throws OneWireIOException, OneWireException

New method, unique to NetAdapter.

Sets the "port", i.e. the connection to the server via an already established socket connection.

Parameters:
sockSocket connection to NetAdapterHost
Returns:
true if connection to host was successful
Exceptions:
OneWireIOExceptionIf port does not exist, or unable to communicate with port.
OneWireExceptionIf port does not exist
boolean selectPort ( String  portName) throws OneWireIOException, OneWireException [virtual]

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-aquire the port when needed. If the port cannot be re-aquired ehen the exception PortInUseException will be thrown.

Parameters:
portNameAddress to connect this NetAdapter to, in the form of "hostname:port". For example, "shughes.dalsemi.com:6161", where 6161 is the port number to connect to. The use of NetAdapter.DEFAULT_PORT is recommended.
Returns:
true if the port was aquired, false if the port is not available.
Exceptions:
OneWireIOExceptionIf port does not exist, or unable to communicate with port.
OneWireExceptionIf port does not exist

Implements DSPortAdapter.

void setNoResetSearch ( ) [virtual]

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.

Implements DSPortAdapter.

void setPowerDuration ( int  timeFactor) throws OneWireIOException, OneWireException

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.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

void setPowerNormal ( ) throws OneWireIOException, OneWireException

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.

Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter or the adapter does not support this operation

Reimplemented from DSPortAdapter.

void setProgramPulseDuration ( int  timeFactor) throws OneWireIOException, OneWireException

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.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

void setSearchAllDevices ( ) [virtual]

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:
setNoResetSearch

Implements DSPortAdapter.

void setSearchOnlyAlarmingDevices ( ) [virtual]

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

Implements DSPortAdapter.

void setSecret ( String  secret)

Sets the shared secret for authenticating this NetAdapter with a NetAdapterHost.

Parameters:
secretthe new secret for authenticating this client.
void setSpeed ( int  speed) throws OneWireIOException, OneWireException

Sets the new speed of data transfer on the 1-Wire Network.

Parameters:
speed
  • 0 (SPEED_REGULAR) set to normal communciation speed
  • 1 (SPEED_FLEX) set to flexible communciation speed used for long lines
  • 2 (SPEED_OVERDRIVE) set to normal communciation speed to overdrive
  • 3 (SPEED_HYPERDRIVE) set to normal communciation speed to hyperdrive
  • >3 future speeds
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter or the adapter does not support this operation

Reimplemented from DSPortAdapter.

void startBreak ( ) throws OneWireIOException, OneWireException

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.

Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter or the adapter does not support this operation

Reimplemented from DSPortAdapter.

boolean startPowerDelivery ( int  changeCondition) throws OneWireIOException, OneWireException

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.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter

Reimplemented from DSPortAdapter.

boolean startProgramPulse ( int  changeCondition) throws OneWireIOException, OneWireException

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.
Exceptions:
OneWireIOExceptionon a 1-Wire communication error
OneWireExceptionon a setup error with the 1-Wire adapter or the adapter does not support this operation

Reimplemented from DSPortAdapter.

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.

See also:
targetFamily
targetFamily(byte[])
excludeFamily
excludeFamily(byte[])

Reimplemented from DSPortAdapter.

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:
familyarray of the family types to target for searches
See also:
com.dalsemi.onewire.utils.Address
targetAllFamilies

Reimplemented from DSPortAdapter.

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:
familythe code of the family type to target for searches
See also:
com.dalsemi.onewire.utils.Address
targetAllFamilies

Reimplemented from DSPortAdapter.


The documentation for this class was generated from the following file: