-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
In WaitForOneWireReady(), a new Stopwatch() is created, but never started. As a result, the if-test (stopWatch.ElapsedMilliseconds > 5000) will never evaluate to true:
OneWire/src/Rinsen.IoT.OneWire/DS2482_100.cs
Lines 329 to 337 in a102c23
| var stopWatch = new Stopwatch(); | |
| do | |
| { | |
| if (stopWatch.ElapsedMilliseconds > 5000) | |
| { | |
| throw new InvalidOperationException("One Wire bus busy for too long"); | |
| } | |
| _i2cDevice.WriteRead(new byte[] { FunctionCommand.SET_READ_POINTER, RegisterSelection.STATUS }, status); | |
| } while (status[0].GetBit(StatusBit.OneWireBusy)); |
This can easily be fixed by changing line 329 to
var stopWatch = Stopwatch.StartNew();
The same issue can be found in this piece of code in ReadStatus(bool setReadPointerToStatus = false):
OneWire/src/Rinsen.IoT.OneWire/DS2482_100.cs
Lines 313 to 321 in a102c23
| var stopWatch = new Stopwatch(); | |
| do | |
| { | |
| if (stopWatch.ElapsedMilliseconds > 1) | |
| { | |
| throw new InvalidOperationException("One Wire bus busy for too long"); | |
| } | |
| _i2cDevice.Read(statusBuffer); | |
| } while (statusBuffer[0].GetBit(StatusBit.OneWireBusy)); |
Also, is the 1 millisecond time-out here not way too short? Or is there a specific reason for this?
Regards