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

onewire: Implement scan for multiple devices #139

Merged
merged 6 commits into from
Sep 28, 2022
Merged

onewire: Implement scan for multiple devices #139

merged 6 commits into from
Sep 28, 2022

Conversation

jbglaw
Copy link
Contributor

@jbglaw jbglaw commented Sep 27, 2022

The former scan command only worked with a single 1-wire device attached. However, the 1-wire bus is ment as a bus, so there might be several devices connected to the bus. In that case, there is a suggested bus scanning scheme (cf. https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/187.html) that makes clever use of pull-down collisions that will occur in such a situation. This allows to scan for all devices by basically doing a tree search. (The algorithm avoids recursion by using a few house-keeping variables to keep search state while discovering all devices ROM addresses.)

The former `scan` command only worked with a single 1-wire device attached.
However, the 1-wire bus is ment as a bus, so there might be several devices
connected to the bus. In that case, there is a suggested bus scanning scheme
(cf. https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/187.html)
that makes clever use of pull-down collisions that will occur in such a
situation. This allows to scan for all devices by basically doing a tree
search. (The algorithm avoids recursion by using a few house-keeping variables
to keep search state while discovering all devices ROM addresses.)
@bvernoux
Copy link
Member

Very nice contribution !!
I'm checking the code

@bvernoux
Copy link
Member

bvernoux commented Sep 27, 2022

Could you apply astyle (with recent astyle like Astyle 3.1) on final code (using coding style) ?

cd hydrafw/src/hydrabus
astyle.exe -t --style=linux --lineend=linux hydrabus_mode_onewire.c

Copy link
Collaborator

@Baldanos Baldanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good PR, thanks a lot !
I only have 1 one-wire device to test, but it seems to be working perfectly fine.

Just one change about a variable type and I'd happily merge this.

src/hydrabus/hydrabus_mode_onewire.c Outdated Show resolved Hide resolved
src/hydrabus/hydrabus_mode_onewire.c Outdated Show resolved Hide resolved
src/hydrabus/hydrabus_mode_onewire.c Outdated Show resolved Hide resolved
src/hydrabus/hydrabus_mode_onewire.c Show resolved Hide resolved
@Baldanos Baldanos self-assigned this Sep 27, 2022
@jbglaw
Copy link
Contributor Author

jbglaw commented Sep 27, 2022

Could you apply astyle (with recent astyle like Astyle 3.1) on final code (using coding style) ?

cd hydrafw/src/hydrabus
astyle.exe -t --style=linux --lineend=linux hydrabus_mode_onewire.c

Just tried that: This didn't change the new/changed code, but some other unrelated code. (Except the front-indention of the crc constants, which I would keep as-is, as this aligns the ,s...) But I'll push that anyways.

The file was given to `astyle -t --style=linux --lineend=linux hydrabus_mode_onewire.c`.
However, the crc constants array was left untouched to keep the commas aligned.
@jbglaw jbglaw requested review from bvernoux and Baldanos and removed request for bvernoux September 27, 2022 19:48
Copy link
Collaborator

@Baldanos Baldanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one missing change since 74a3033, which breaks compilation.

src/hydrabus/hydrabus_mode_onewire.c Outdated Show resolved Hide resolved
@Baldanos Baldanos merged commit 927dc50 into hydrabus:master Sep 28, 2022
@Baldanos
Copy link
Collaborator

All good to me.

Thanks for your contribution !

@jbglaw jbglaw deleted the jbglaw/onewire-scan branch September 29, 2022 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants