Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fix to wireSearch missing devices. #12

Open
tekkydave opened this issue Sep 13, 2021 · 0 comments
Open

Possible fix to wireSearch missing devices. #12

tekkydave opened this issue Sep 13, 2021 · 0 comments

Comments

@tekkydave
Copy link

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;


@tekkydave tekkydave changed the title Possible fix to Possible fix to wireSearch missing devices. Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant