OW

Library.OW History

Hide minor edits - Show changes to output

Changed line 1 from:
|| border=1 style="border-collapse:collapse" cellpadding=3 width=30%  bgcolor=#f4f4f4
to:
|| border=1 style="border-collapse:collapse" cellpadding=3 width=25%  bgcolor=#f4f4f4
Changed lines 94-97 from:
*'''owReadROM''' - identify a Device
*'''owSkipROM''' - omit addressing
*'''owMatchROM''' - address a specific Device
*'''owSearchROM''' - identify all devices 
to:
*''owReadROM'' - identify a Device
*''owSkipROM'' - omit addressing
*''owMatchROM'' - address a specific Device
*''owSearchROM'' - identify all devices 
Changed lines 118-119 from:
 *[[#RomID]]RomId(8)''' As Byte'''    - device ID
 *[[#Family]]Family '''As Byte'''  - device family
to:
*[[#RomID]]RomId(8)''' As Byte'''    - device ID
*[[#Family]]Family '''As Byte'''  - device family
Changed lines 32-33 from:
*value - Bit value to write
to:
*''value'' - Bit value to write
Changed line 46 from:
*value - Byte value to write.
to:
*''value'' - Byte value to write.
Changed lines 30-31 from:
 Sub WriteBit(value As Bit)
to:
 '''Sub''' WriteBit(value '''As Bit''')
Changed lines 38-39 from:
 Function ReadBit() As Bit
to:
 '''Function''' ReadBit() '''As Bit'''
Changed lines 44-45 from:
 Sub WriteByte(value As Byte)
to:
 '''Sub''' WriteByte(value '''As Byte''')
Changed lines 52-53 from:
 Function ReadByte() As Byte
to:
 '''Function''' ReadByte() '''As Byte'''
Changed lines 58-62 from:
 Sub WriteArray(ByRef array() As Byte, Optional max As Byte = &HFF)

*array - Array of bytes.
*max - Maximum number of byte to write.  Default is the whole array, up to a maximum of 256 bytes.
to:
 '''Sub''' WriteArray('''ByRef''' array() '''As Byte''', '''Optional''' max '''As Byte''' = &HFF)

*''array'' - Array of bytes.
*''max'' - Maximum number of byte to write.  Default is the whole array, up to a maximum of 256 bytes.
Changed lines 67-71 from:
 Function ReadArray(ByRef array() As Byte, Optional max As Byte = &HFF) As Boolean

*array - Byte array to receive the data.
*max - Maximum number of byte to read, up to a maximum of 256 bytes.
to:
 '''Function''' ReadArray('''ByRef''' array() ''As Byte'', '''Optional''' max '''As Byte''' = &HFF) '''As Boolean'''

*''array'' - Byte array to receive the data.
*''max'' - Maximum number of byte to read, up to a maximum of 256 bytes.
Changed lines 76-77 from:
 Function Reset() As Boolean
to:
 '''Function''' Reset() '''As Boolean'''
Deleted line 78:
Changed lines 82-83 from:
 Sub WaitForHigh()
to:
 '''Sub''' WaitForHigh()
Changed lines 88-91 from:
 Function Search(optional cmd As Byte = owSearchROM) As Byte

*cmd - Search command to execute.
to:
 '''Function''' Search('''Optional''' cmd '''As Byte''' = owSearchROM) '''As Byte'''

*''cmd'' - Search command to execute.
Changed lines 94-98 from:
*owReadROM - identify a Device
*owSkipROM - omit addressing
*owMatchROM - address a specific Device
*owSearchROM - identify all devices 
to:
*'''owReadROM''' - identify a Device
*'''owSkipROM''' - omit addressing
*'''owMatchROM''' - address a specific Device
*'''owSearchROM''' - identify all devices 
Changed lines 101-102 from:
 Function Count() As Byte
to:
 ''Function'' Count() '''As Byte'''
Changed lines 107-113 from:
 Event OnSearch(command As Byte, family As Byte, ByRef romID() As Byte, ByRef abort As Boolean)

*command - The command whic is currentky executing.
*family - The device family identifier.
*romID - The unique device identifier.
*abort - Flag to abort the search.  Default is false.
to:
 '''Event''' OnSearch(command ''As Byte'', family '''As Byte''', '''ByRef''' romID()''' As Byte''', '''ByRef''' abort '''As Boolean''')

*''command'' - The command which is currently executing.
*''family'' - The device family identifier.
*''romID'' - The unique device identifier.
*''abort'' - Flag to abort the search.  Default is false.
Changed lines 118-119 from:
 *[[#RomID]]RomId(8) As Byte    - device ID
 *[[#Family]]Family As RomId(0)  - device family
to:
 *[[#RomID]]RomId(8)''' As Byte'''    - device ID
 *[[#Family]]Family '''As Byte'''  - device family
Changed lines 28-29 from:
!!![#WriteBit]]WriteBit
to:
!!![[#WriteBit]]WriteBit
Changed lines 36-37 from:
!!![#ReadBit]]ReadBit
to:
!!![[#ReadBit]]ReadBit
Changed lines 42-43 from:
!!![#WriteByte]]WriteByte
to:
!!![[#WriteByte]]WriteByte
Changed lines 50-51 from:
!!![#ReadByte]]ReadByte
to:
!!![[#ReadByte]]ReadByte
Changed lines 56-57 from:
!!![#WriteArray]]WriteArray
to:
!!![[#WriteArray]]WriteArray
Changed lines 65-66 from:
!!![#ReadArray]]ReadArray
to:
!!![[#ReadArray]]ReadArray
Changed lines 74-75 from:
!!![#Reset]]Reset
to:
!!![[#Reset]]Reset
Changed lines 81-82 from:
!!![#WaitForHigh]]WaitForHigh
to:
!!![[#WaitForHigh]]WaitForHigh
Changed lines 87-88 from:
!!![#Search]]Search
to:
!!![[#Search]]Search
Changed lines 100-101 from:
!!![#Count]]Count
to:
!!![[#Count]]Count
Changed lines 106-107 from:
!!![#OnSearch]]OnSearch
to:
!!![[#OnSearch]]OnSearch
Changed line 117 from:
!!![#Variables]]Module Variables
to:
!!![[#Variables]]Module Variables
Added lines 1-148:
|| border=1 style="border-collapse:collapse" cellpadding=3 width=30%  bgcolor=#f4f4f4
||[[Reference.Modules#Imports | Module Name]]||OW||
||[[Reference.Modules#Imports | Import Name]]||OW||

The following functions and subroutines are available for the One Wire (OW) module.

*[[#WriteBit | WriteBit]]
*[[#ReadBit | ReadBit]]
*[[#WriteByte | WriteByte]]
*[[#ReadByte | ReadByte]]
*[[#WriteArray | WriteArray]]
*[[#ReadArray | ReadArray]]
*[[#Reset | Reset]]
*[[#WaitForHigh | WaitForHigh]]
*[[#Search | Search]]
*[[#Count | Count]]
*[[#OnSearch | OnSearch]]

'''Module Variables'''

*[[#RomID | RomID]]
*[[#Family | Family]]

'''Program Example'''

*[[#Example | Example]]

!!![#WriteBit]]WriteBit

 Sub WriteBit(value As Bit)

*value - Bit value to write

Writes a single bit to the OW data pin.

!!![#ReadBit]]ReadBit

 Function ReadBit() As Bit

Reads and return the state of the OW data pin
 
!!![#WriteByte]]WriteByte

 Sub WriteByte(value As Byte)

*value - Byte value to write.

Writes a byte (LSB first) to the OW data pin.

!!![#ReadByte]]ReadByte

 Function ReadByte() As Byte

Read and return a byte (LSB first) from the OW data pin.
 
!!![#WriteArray]]WriteArray

 Sub WriteArray(ByRef array() As Byte, Optional max As Byte = &HFF)

*array - Array of bytes.
*max - Maximum number of byte to write.  Default is the whole array, up to a maximum of 256 bytes.

Writes an array of bytes To the OW data pin.

!!![#ReadArray]]ReadArray

 Function ReadArray(ByRef array() As Byte, Optional max As Byte = &HFF) As Boolean

*array - Byte array to receive the data.
*max - Maximum number of byte to read, up to a maximum of 256 bytes.

Read an array of bytes from OW data pin - will return true if last CRC Byte resolves to 0.   

!!![#Reset]]Reset

 Function Reset() As Boolean

Resets the OW data pin - returns true if a device is detected.

 
!!![#WaitForHigh]]WaitForHigh

 Sub WaitForHigh()

Wait for the OW data pin to go high

!!![#Search]]Search

 Function Search(optional cmd As Byte = owSearchROM) As Byte

*cmd - Search command to execute.

Searches for devices connected to the OW bus, based on the command value (normally owSearchROM). The function returns the total number of devices found. An optional event handler will be triggered each time a device is found. Available commands are:

*owReadROM - identify a Device
*owSkipROM - omit addressing
*owMatchROM - address a specific Device
*owSearchROM - identify all devices 

!!![#Count]]Count

 Function Count() As Byte

Returns the total number of devices connected to the OW bus.

!!![#OnSearch]]OnSearch

 Event OnSearch(command As Byte, family As Byte, ByRef romID() As Byte, ByRef abort As Boolean)

*command - The command whic is currentky executing.
*family - The device family identifier.
*romID - The unique device identifier.
*abort - Flag to abort the search.  Default is false.

This event is fired when a call to [[#Search | search]] is made.

!!![#Variables]]Module Variables

 *[[#RomID]]RomId(8) As Byte    - device ID
 *[[#Family]]Family As RomId(0)  - device family

!!![[#Example]]Example
=firewing [=
 ' one wire, used for search
Imports OW                         

' the event is triggered each time the OW module is asked to
' perform a search - here we will list all devices connected to
' the one wire bus...
Sub OnDeviceFound(command As Byte, family As Byte, ByRef romID() As Byte, ByRef abort As Boolean) Handles OW.OnSearch
 
  ' display family...
  Console.Write("0x", Hex(family,2)," : ")
 
  ' display unique identifier...
  for index as byte = 0 to ubound(romID)
      Console.Write("0x", Hex(romID(index),2)," ")
  next
  Console.Write(13,10)
End Sub

' display a list of all devices connected to the bus...
sub Main() 
  OW.Search()
end sub
=]