Scan misses slaves when one disappears from the bus

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Scan misses slaves when one disappears from the bus

Arnout Vandecappelle (Essensium/Mind)
 Hi all,

 We have a system where there are many iButton-type devices on a single
1-wire bus, and they are continuously connected to and disconnected from
the bus. We poll the owfs uncached directory to detect when an iButton
is connected.

 Now during stress testing we discovered that when a device is removed from
the bus, it sometimes happen that other devices (that are still connected)
also disappear. Further investigation turned up that the problem is caused
by the "1,1" condition on the bus when the search algorithm [1] is used.
This condition means "No devices participating in search". However, this is
not really true, because we can only get in that situation when there was
a device participating but it disappeared during the search.

 The attached patch solves this by erroring out in the "1,1" condition,
instead of considering the search finished. This corresponds to what
Maxim's application note [1] describes.

 If you all agree that this is the best way to approach it, you can apply
the patch in follow-up.

 Regards,
 Arnout

[1] https://www.maximintegrated.com/en/app-notes/index.mvp/id/187


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

[PATCH] ds2482: treat "no devices respond" as an error

Arnout Vandecappelle (Essensium/Mind)
When the bus is scanned using the triplet search algorithm, the "1,1"
state means that is no further device is present. However, when the
algorithm is properly followed, this should never occur, because either
(a) no device is present at all, so AnyDevices must be anydevice_no, or
(b) the last scanned device encountered no discrepancy ("0,0") for any
    of it bits, and it already set LastDevice to 1 so the scan is
    stopped.

It may in fact occur that the "1,1" state is encountered during a scan:
when a device disappears during the scan. It has reacted to the
previous bit, but now it stopped reacting to the scan. Treating this
situation as an error means that the scan is aborted and can be
retried. Not treating it as an error means that any other devices on
the bus that have not been scanned yet will be forgotten.

Instead of simply returning an error, a possibly better option would
be to just backtrack to the previous discrepancy. I haven't worked out
the details, but I think additional state would have to be kept to make
that possible. Also such a solution should foresee an escape to avoid
endless looping.
---
 module/owlib/src/c/ow_ds2482.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/module/owlib/src/c/ow_ds2482.c b/module/owlib/src/c/ow_ds2482.c
index 97741eb..5de89b4 100644
--- a/module/owlib/src/c/ow_ds2482.c
+++ b/module/owlib/src/c/ow_ds2482.c
@@ -569,9 +569,8 @@ static enum search_status DS2482_next_both(struct device_search *ds, const struc
  }
  if (bits[0] || bits[1] || bits[2]) {
  if (bits[0] && bits[1]) { /* 1,1 */
- /* No devices respond */
- ds->LastDevice = 1;
- return search_done;
+ /* No devices respond, even though they did respond before */
+ return search_error;
  }
  } else { /* 0,0,0 */
  last_zero = bit_number;
--
2.8.0.rc3


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers