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
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to