1-Wire API for Compact.NET  Version 4.10
PortAdapter Class Referenceabstract

Abstract base class for all 1-Wire Adapter objects. More...

Inherits IDisposable.

Inherited by SerialAdapter, SerialAdapterX, and TMEXLibAdapter.

Public Member Functions

abstract void Dispose ()
 Gets or sets the ISite associated with this component More...
 
abstract bool OpenPort (String PortName)
 Opens the specified port and verifies existance of the adapter More...
 
void FreePort ()
 Closes the port and frees all resources from use More...
 
bool BeginExclusive (bool blocking)
 Obtain exclusive control of this adapter object More...
 
void EndExclusive ()
 Release exclusive control of this adapter object More...
 
abstract OWResetResult Reset ()
 Sends a Reset to the 1-Wire Network. More...
 
abstract void PutBit (bool bitValue)
 Sends a bit to the 1-Wire Network. More...
 
abstract void PutByte (int byteValue)
 Sends a byte to the 1-Wire Network. More...
 
abstract bool GetBit ()
 Gets a bit from the 1-Wire Network. More...
 
abstract int GetByte ()
 Gets a byte from the 1-Wire Network. More...
 
abstract byte [] GetBlock (int len)
 Get a block of data from the 1-Wire Network. More...
 
abstract void GetBlock (byte[] arr, int len)
 Get a block of data from the 1-Wire Network and write it into the provided array. More...
 
abstract void GetBlock (byte[] arr, int off, int len)
 Get a block of data from the 1-Wire Network and write it into the provided array. More...
 
abstract void DataBlock (byte[] data, int offset, int length)
 Sends a block of data and returns the data received in the same array. More...
 
abstract void SetPowerDuration (OWPowerTime powerDur)
 Sets the duration to supply power to the 1-Wire Network. More...
 
abstract bool StartPowerDelivery (OWPowerStart changeCondition)
 Sets the 1-Wire Network voltage to supply power to an iButton device. More...
 
abstract void SetProgramPulseDuration (OWPowerTime pulseDur)
 Sets the duration for providing a program pulse on the 1-Wire Network. More...
 
abstract bool StartProgramPulse (OWPowerStart changeCondition)
 Sets the 1-Wire Network voltage to eprom programming level. More...
 
abstract void StartBreak ()
 Sets the 1-Wire Network voltage to 0 volts. More...
 
abstract void SetPowerNormal ()
 Sets the 1-Wire Network voltage to normal level. More...
 
abstract bool GetFirstDevice (byte[] address, int offset)
 Returns More...
 
abstract bool GetNextDevice (byte[] address, int offset)
 Returns More...
 
abstract bool IsPresent (byte[] address, int offset)
 Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network. More...
 
abstract bool IsAlarming (byte[] address, int offset)
 Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. More...
 
virtual bool SelectDevice (byte[] address, int offset)
 Selects the specified iButton or 1-Wire device by broadcasting its address. More...
 
abstract void SetSearchOnlyAlarmingDevices ()
 Set 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. More...
 
abstract void SetNoResetSearch ()
 Set the 1-Wire Network search to not perform a 1-Wire reset before a search. More...
 
abstract void SetSearchAllDevices ()
 Set 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. More...
 
virtual void TargetAllFamilies ()
 Removes any selectivity during a search for iButtons or 1-Wire devices by family type. More...
 
virtual void TargetFamily (int family)
 Takes an integer to selectively search for this desired family type. More...
 
virtual void TargetFamily (byte[] family)
 Takes an array of bytes to use for selectively searching for acceptable family codes. More...
 
virtual void ExcludeFamily (int family)
 Takes an integer family code to avoid when searching for iButtons. More...
 
virtual void ExcludeFamily (byte[] family)
 Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices. More...
 
override int GetHashCode ()
 Get Hash Code (proxies to .ToString().GetHashCode()) More...
 
override bool Equals (System.Object o)
 Tells if objects are equal (proxies to .ToString().Equals()) More...
 
override string ToString ()
 Returns a string representation of this adapter (i.e. More...
 

Protected Member Functions

abstract void Dispose (bool disposing)
 Dispose's all resources for this object More...
 
virtual void onReset (OWResetResult rslt)
 onReset event, fires event for all listeners More...
 
virtual void onSpeedChange (OWSpeed OldSpeed, OWSpeed NewSpeed)
 onSpeedChange event, fires event for all listeners More...
 
virtual void onDataIO (bool isTransmit, byte[] data)
 onDataIO event, fires for all data IO More...
 
virtual internal bool isValidFamily (byte familyCode)
 Checks to see if the family found is in the desired include group. More...
 

Protected Attributes

internal byte [] exclude = null
 exclude family codes More...
 
internal byte [] include = null
 include family codes More...
 

Properties

abstract OWSpeed Speed [get, set]
 OWSpeed representing current speed of communication on 1-Wire network More...
 
abstract bool CanOverdrive [get]
 Returns whether adapter can physically support overdrive mode. More...
 
abstract bool CanHyperdrive [get]
 Returns whether the adapter can physically support hyperdrive mode. More...
 
abstract bool CanFlex [get]
 Returns whether the adapter can physically support flex speed mode. More...
 
abstract bool CanProgram [get]
 Returns whether adapter can physically support 12 volt power mode. More...
 
abstract bool CanDeliverPower [get]
 Returns whether the adapter can physically support strong 5 volt power mode. More...
 
abstract bool CanDeliverSmartPower [get]
 Returns whether the adapter can physically support "smart" strong 5 volt power mode. More...
 
abstract bool CanBreak [get]
 Returns whether adapter can physically support 0 volt 'break' mode. More...
 
abstract string AdapterName [get]
 The name of this adapter type More...
 
abstract string PortName [get]
 The port name for this adapter type (i.e. More...
 
abstract string PortTypeDescription [get]
 Detailed description for this port type More...
 
abstract System.Collections.IList PortNames [get]
 Collection of valid port names for this port type More...
 

Events

ResetEventHandler ResetEvent
 An event for indicating when a 1-Wire Reset occurs and what the result is. More...
 
SpeedChangeEventHandler SpeedChangeEvent
 An event for indicating when a 1-Wire Reset occurs and what the result is. More...
 
DataIOEventHandler DataIOEvent
 event for indicating when data is transmitted More...
 

Detailed Description

Abstract base class for all 1-Wire Adapter objects.

Member Function Documentation

◆ BeginExclusive()

bool BeginExclusive ( bool  blocking)

Obtain exclusive control of this adapter object

Parameters
blockingif true, blocks until available
Returns
if true, exclusive control has been granted

◆ DataBlock()

abstract void DataBlock ( byte []  data,
int  offset,
int  length 
)
pure 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
dataarray of data to transfer to and from the 1-Wire Network.
offsetoffset into the array of data to start
lengthlength of data to send / receive starting at 'off'

◆ Dispose() [1/2]

abstract void Dispose ( )
pure virtual

Gets or sets the ISite associated with this component

Represents the method that handles the Disposed event of a component.

Dispose's all resources for this object

◆ Dispose() [2/2]

abstract void Dispose ( bool  disposing)
protectedpure virtual

Dispose's all resources for this object

◆ EndExclusive()

void EndExclusive ( )

Release exclusive control of this adapter object

◆ Equals()

override bool Equals ( System.Object  o)

Tells if objects are equal (proxies to .ToString().Equals())

Parameters
o
Returns

◆ ExcludeFamily() [1/2]

virtual void ExcludeFamily ( int  family)
virtual

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

◆ ExcludeFamily() [2/2]

virtual void ExcludeFamily ( byte []  family)
virtual

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

◆ FreePort()

void FreePort ( )

Closes the port and frees all resources from use

◆ GetBit()

abstract bool GetBit ( )
pure virtual

Gets a bit from the 1-Wire Network.

Returns
the bit value recieved from the the 1-Wire Network.

◆ GetBlock() [1/3]

abstract byte [] GetBlock ( int  len)
pure virtual

Get 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.

◆ GetBlock() [2/3]

abstract void GetBlock ( byte []  arr,
int  len 
)
pure virtual

Get 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

◆ GetBlock() [3/3]

abstract void GetBlock ( byte []  arr,
int  off,
int  len 
)
pure virtual

Get 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

◆ GetByte()

abstract int GetByte ( )
pure virtual

Gets a byte from the 1-Wire Network.

Returns
the byte value received from the the 1-Wire Network.

◆ GetFirstDevice()

abstract bool GetFirstDevice ( byte []  address,
int  offset 
)
pure 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.

Parameters
addressdevice address found
offsetoffset into array where address begins
Returns
true
if an iButton or 1-Wire device is found.

◆ GetHashCode()

override int GetHashCode ( )

Get Hash Code (proxies to .ToString().GetHashCode())

Returns

◆ GetNextDevice()

abstract bool GetNextDevice ( byte []  address,
int  offset 
)
pure 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.

Parameters
addressdevice address found
offsetoffset into array where address begins
Returns
true
if an iButton or 1-Wire device is found.

◆ IsAlarming()

abstract bool IsAlarming ( byte []  address,
int  offset 
)
pure virtual

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
addressdevice address to verify is present and alarming
offsetoffset into array where address begins
Returns
true
if device is present and alarming else
false
.

◆ IsPresent()

abstract bool IsPresent ( byte []  address,
int  offset 
)
pure virtual

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
addressdevice address to verify is present
offsetoffset into array where address begins
Returns
true
if device is present else
false
.

◆ isValidFamily()

virtual internal bool isValidFamily ( byte  familyCode)
protectedvirtual

Checks to see if the family found is in the desired include group.

Returns
true
if in include group

◆ onDataIO()

virtual void onDataIO ( bool  isTransmit,
byte []  data 
)
protectedvirtual

onDataIO event, fires for all data IO

Parameters
isTransmitif true, this is a transmit event, otherwise it is echo
dataThe data transmitted or received

◆ onReset()

virtual void onReset ( OWResetResult  rslt)
protectedvirtual

onReset event, fires event for all listeners

Parameters
rsltthe result of the 1-Wire reset

◆ onSpeedChange()

virtual void onSpeedChange ( OWSpeed  OldSpeed,
OWSpeed  NewSpeed 
)
protectedvirtual

onSpeedChange event, fires event for all listeners

Parameters
OldSpeedthe 1-Wire speed before change
NewSpeedthe 1-Wire speed after change

◆ OpenPort()

abstract bool OpenPort ( String  PortName)
pure virtual

Opens the specified port and verifies existance of the adapter

Returns
true if adapter found on specified port

◆ PutBit()

abstract void PutBit ( bool  bitValue)
pure virtual

Sends a bit to the 1-Wire Network.

Parameters
bitValuethe bit value to send to the 1-Wire Network.

◆ PutByte()

abstract void PutByte ( int  byteValue)
pure virtual

Sends a byte to the 1-Wire Network.

Parameters
byteValuethe byte value to send to the 1-Wire Network.

◆ Reset()

abstract OWResetResult Reset ( )
pure virtual

Sends a Reset to the 1-Wire Network.

Returns
the result of the reset.

◆ SelectDevice()

virtual bool SelectDevice ( byte []  address,
int  offset 
)
virtual

Selects the specified iButton or 1-Wire device by broadcasting its address.

This operation is refered 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
addressiButton to select
offsetoffset into array where address begins
Returns
true
if device address was sent,
false
otherwise.

◆ SetNoResetSearch()

abstract void SetNoResetSearch ( )
pure virtual

Set 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.

◆ SetPowerDuration()

abstract void SetPowerDuration ( OWPowerTime  powerDur)
pure virtual

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
powerDurtime factor

◆ SetPowerNormal()

abstract void SetPowerNormal ( )
pure virtual

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

◆ SetProgramPulseDuration()

abstract void SetProgramPulseDuration ( OWPowerTime  pulseDur)
pure virtual

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
pulseDurtime factor

◆ SetSearchAllDevices()

abstract void SetSearchAllDevices ( )
pure virtual

Set 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).

◆ SetSearchOnlyAlarmingDevices()

abstract void SetSearchOnlyAlarmingDevices ( )
pure virtual

Set 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.

◆ StartBreak()

abstract void StartBreak ( )
pure virtual

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.

◆ StartPowerDelivery()

abstract bool StartPowerDelivery ( OWPowerStart  changeCondition)
pure virtual

Sets the 1-Wire Network voltage to supply power to an iButton 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
changeConditionchange condition
Returns
true
if the voltage change was successful,
false
otherwise.

◆ StartProgramPulse()

abstract bool StartProgramPulse ( OWPowerStart  changeCondition)
pure virtual

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
changeConditionchange condition
Returns
true

if the voltage change was successful,

false

otherwise.

OneWireIOException on a 1-Wire communication error

OneWireException on a setup error with the 1-Wire adapter or the adapter does not support this operation

◆ TargetAllFamilies()

virtual void TargetAllFamilies ( )
virtual

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() [1/2]

virtual void TargetFamily ( int  family)
virtual

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

◆ TargetFamily() [2/2]

virtual void TargetFamily ( byte []  family)
virtual

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

◆ ToString()

override string ToString ( )

Returns a string representation of this adapter (i.e.

"DS9097U COM1")

Returns

Member Data Documentation

◆ exclude

internal byte [] exclude = null
protected

exclude family codes

◆ include

internal byte [] include = null
protected

include family codes

Property Documentation

◆ AdapterName

abstract string AdapterName
get

The name of this adapter type

◆ CanBreak

abstract bool CanBreak
get

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

Returns
true
if this port adapter can do break,
false
otherwise.

◆ CanDeliverPower

abstract bool CanDeliverPower
get

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.

◆ CanDeliverSmartPower

abstract bool CanDeliverSmartPower
get

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.

◆ CanFlex

abstract bool CanFlex
get

Returns whether the adapter can physically support flex speed mode.

Returns
true
if this port adapter can do flex speed,
false
otherwise.

◆ CanHyperdrive

abstract bool CanHyperdrive
get

Returns whether the adapter can physically support hyperdrive mode.

Returns
true
if this port adapter can do HyperDrive,
false
otherwise.

◆ CanOverdrive

abstract bool CanOverdrive
get

Returns whether adapter can physically support overdrive mode.

Returns
true
if this port adapter can do OverDrive,
false
otherwise.

◆ CanProgram

abstract bool CanProgram
get

Returns whether adapter can physically support 12 volt power mode.

Returns
true
if this port adapter can do Program voltage,
false
otherwise.

◆ PortName

abstract string PortName
get

The port name for this adapter type (i.e.

COM1, LPT1, etc)

◆ PortNames

abstract System.Collections.IList PortNames
get

Collection of valid port names for this port type

◆ PortTypeDescription

abstract string PortTypeDescription
get

Detailed description for this port type

◆ Speed

abstract OWSpeed Speed
getset

OWSpeed representing current speed of communication on 1-Wire network

Event Documentation

◆ DataIOEvent

DataIOEventHandler DataIOEvent

event for indicating when data is transmitted

◆ ResetEvent

ResetEventHandler ResetEvent

An event for indicating when a 1-Wire Reset occurs and what the result is.

◆ SpeedChangeEvent

SpeedChangeEventHandler SpeedChangeEvent

An event for indicating when a 1-Wire Reset occurs and what the result is.


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