Rinsen / OneWire

One Wire via DS2482-100 or DS2482-800 for Windows or Linux based Raspberry Pi IoT solutions
MIT License
33 stars 14 forks source link

Stopwatch is never started in DS2482_100 #10

Open crates-barrels opened 6 years ago

crates-barrels commented 6 years ago

In WaitForOneWireReady(), a new Stopwatch() is created, but never started. As a result, the if-test (stopWatch.ElapsedMilliseconds > 5000) will never evaluate to true: https://github.com/Rinsen/OneWire/blob/a102c234155c33506b28b4c5500c9bdd784c7b11/src/Rinsen.IoT.OneWire/DS2482_100.cs#L329-L337 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): https://github.com/Rinsen/OneWire/blob/a102c234155c33506b28b4c5500c9bdd784c7b11/src/Rinsen.IoT.OneWire/DS2482_100.cs#L313-L321 Also, is the 1 millisecond time-out here not way too short? Or is there a specific reason for this?

Regards

Rinsen commented 6 years ago

There are some fundamental issues with the error handling that should be addressed and this is for sure one of them, thanks for the report!

Also the status handling in the chip is not handled in a good way. As long as I find the time I am planning a new release later this year or in the beginning of next.