Skip to content

Possible fix to wireSearch missing devices. #12

@tekkydave

Description

@tekkydave

Are you aware of a fix provided by Close20 in an answer on:
Stack Exchange

I have applied this fix to a local copy of the library and it seems to solve an issue I was having with 3 devices on the bus.
It worked fine with 2 devices

280E6DB901000059
26F488170100002F

but when I added

1D310A0900000037

It became the only device found

After applying Close20's fixes all 3 devices are found.

I thought I would pass this on in case it is useful to you and others.
Thanks for the library. It's been a great help to me.
Dave

I believe the library linked by Cybergibbons has a bug in

uint8_t OneWire::wireSearch(uint8_t *address)

A discrepancy at i = 0 (bit zero in this library, id_bit_number = 1 in a Maxim example) only follows
the direction = 1 path and fails to find ROM addresses where bit zero = 0 (i.e. even family codes
are missed when mixed devices, some with even and others with odd family codes, are present
on the 1-wire bus).

A fix I have just implemented and appears to work is to modify the library to declare
searchLastDiscrepancy and last_zero as int8_t (not uint8_t), initialise/reset them to -1 (not zero) and,
near the end of the method

if (!last_zero)
searchLastDeviceFlag = 1;


becomes

if (last_zero == -1)
searchLastDeviceFlag = 1;


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions