From Swordfish Wiki

SwordfishUser: OWSearch

Device = 18F452
Clock = 20

// import modules...
Include "ow.bas"
Include "convert.bas"
Include "usart.bas"

// on find event handler...
Event OnFind()
   Dim Index As Byte
   USART.Write("FAMILY $", HexToStr(SearchFamily,2))
   USART.Write(" ($",HexToStr(SearchID(7),2),")")
   USART.Write(" ($")
   Index = 6
   Repeat
      USART.Write(HexToStr(SearchID(Index),2))
      Dec(Index)
   Until Index = 0
   USART.Write(")",13,10)
End Event

// working variables...
Dim DeviceCount As Byte   

// program start...
SetBaudrate(br19200)
SetPin(PORTC.0)
DeviceCount = Search(owSearchROM, OnFind)
USART.Write(DecToStr(DeviceCount), " device(s) found", 13, 10)

Sample Output

 FAMILY $28 ($1D) ($0000002CDBAE) <- DS18B20
 FAMILY $28 ($3F) ($0000002CD16E) <- DS18B20
 FAMILY $05 ($F1) ($00000019F75D)
 FAMILY $05 ($90) ($0000001A20B7)
 FAMILY $23 ($CA) ($0000005C62EE)
 5 device(s) found
Retrieved from https://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.OWSearch
Page last modified on March 07, 2008, at 05:01 PM