Table of Contents

Class OneWireHost

Namespace
nanoFramework.Device.OneWire
Assembly
nanoFramework.Device.OneWire.dll

Initializes a new instance of the OneWireHost class. Represents a 1-Wire host. The class provides methods that an application can use to interact with the 1-Wire bus and connected devices.

public class OneWireHost : IDisposable
Inheritance
OneWireHost
Implements
Inherited Members
Extension Methods

Constructors

OneWireHost()

Initializes a new instance of the OneWireHost class.

public OneWireHost()

Exceptions

InvalidOperationException

If there is already another instance of the OneWireHost class.

Properties

SerialNumber

SerialNum buffer that is used in the search methods FindFirstDevice(bool, bool) and FindNextDevice(bool, bool).

public byte[] SerialNumber { get; set; }

Property Value

byte[]

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Finalize()

protected override void Finalize()

FindAllDevices()

Find all devices present in 1-Wire Net

public ArrayList FindAllDevices()

Returns

ArrayList

ArrayList with the serial numbers of all devices found.

FindFirstDevice(bool, bool)

Finds the first device on the 1-Wire Net

public bool FindFirstDevice(bool performResetBeforeSearch, bool searchWithAlarmCommand)

Parameters

performResetBeforeSearch bool

TRUE perform reset before search, FALSE do not perform reset before search.

searchWithAlarmCommand bool

TRUE the find alarm command 0xEC is sent instead of the normal search command 0xF0.

Returns

bool

TRUE: when a 1-Wire device was found and it's Serial Number placed in SerialNumber. FALSE: There are no devices on the 1-Wire Net.

FindNextDevice(bool, bool)

The function does a general search. This function continues from the previous search state. The search state can be reset by using the 'FindFirstDevice' function.

public bool FindNextDevice(bool performResetBeforeSearch, bool searchWithAlarmCommand)

Parameters

performResetBeforeSearch bool

TRUE perform reset before search, FALSE do not perform reset before search.

searchWithAlarmCommand bool

TRUE the find alarm command 0xEC is sent instead of the normal search command 0xF0.

Returns

bool

TRUE: when a 1-Wire device was found and it's Serial Number placed in SerialNumber. FALSE: when no new device was found. Either the last search was the last device or there are no devices on the 1-Wire Net.

ReadByte()

Sends 8 bits of read communication to the 1-Wire Net.

public byte ReadByte()

Returns

byte

8 bit read from 1-Wire Net.

TouchBit(bool)

Send 1 bit of communication to the 1-Wire Net and return the result 1 bit read from the 1-Wire Net.
The parameter value least significant bit is used and the least significant bit of the result is the return bit.

public bool TouchBit(bool value)

Parameters

value bool

The least significant bit is the bit to send.

Returns

bool

A 0 or 1 read from value.

TouchByte(byte)

Send 8 bits of communication to the 1-Wire Net and return the result 8 bits read from the 1-Wire Net. The value least significant 8 bits are used and the least significant 8 bits of the result is the return byte.

public byte TouchByte(byte value)

Parameters

value byte

8 bits to send (least significant byte).

Returns

byte

8 bits read from value

TouchReset()

Reset all of the devices on the 1-Wire Net and return the result.

public bool TouchReset()

Returns

bool

TRUE: presence pulse(s) detected, device(s) reset. FALSE: no presence pulses detected.

WriteByte(byte)

Send 8 bits of communication to the 1-Wire Net and verify that the 8 bits read from the 1-Wire Net is the same (write operation).

public byte WriteByte(byte value)

Parameters

value byte

8 bits to send (least significant byte).

Returns

byte

TRUE: bytes written and echo was the same FALSE: echo was not the same