---
name: "w1_search"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/w1_search"
---

# w1\_search(9)

Performs a ROM Search & registers any devices found.

## NAME

w1\_search - Performs a ROM Search & registers any devices found.

## SYNOPSIS

**void w1\_search(struct w1\_master \*** *dev***, u8** *search\_type***, w1\_slave\_found\_callback** *cb***);**

## ARGUMENTS

*dev*

The master device to search

*search\_type*

W1\_SEARCH to search all devices, or W1\_ALARM\_SEARCH to return only devices in the alarmed state

*cb*

Function to call when a device is found

## DESCRIPTION

The 1-wire search is a simple binary tree search. For each bit of the address, we read two bits and write one bit. The bit written will put to sleep all devies that don't match that bit. When the two reads differ, the direction choice is obvious. When both bits are 0, we must choose a path to take. When we can scan all 64 bits without having to choose a path, we are done.

See “Application note 187 1-wire search algorithm” at www.maxim-ic.com

## AUTHOR

**David Fries** \<David@Fries.net\>

Author.

## COPYRIGHT
