From 8f08f361ee887ad904117a35d8d61004b3849b20 Mon Sep 17 00:00:00 2001 From: up-streamer Date: Tue, 12 Nov 2019 05:53:18 -0300 Subject: [PATCH] Fix endless loop in search when there are more than 2 devices on the bus. This fix is for ESP32 and STM32 --- .../nf-overlay/os/hal/src/stm32_onewire/hal_stm32_onewire.c | 2 +- ...e_native_nanoFramework_Devices_OneWire_OneWireController.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/CMSIS-OS/ChibiOS/nf-overlay/os/hal/src/stm32_onewire/hal_stm32_onewire.c b/targets/CMSIS-OS/ChibiOS/nf-overlay/os/hal/src/stm32_onewire/hal_stm32_onewire.c index a01dd88cdf..6df9df438b 100644 --- a/targets/CMSIS-OS/ChibiOS/nf-overlay/os/hal/src/stm32_onewire/hal_stm32_onewire.c +++ b/targets/CMSIS-OS/ChibiOS/nf-overlay/os/hal/src/stm32_onewire/hal_stm32_onewire.c @@ -1012,7 +1012,7 @@ bool oneWireFindNext (bool doReset, bool alarmOnly) } while (romByteIndex < 8); // loop until we have all ROM bytes - if (romBitIndex < (65 || lastcrc8)) + if ((romBitIndex < 65) || (lastcrc8 != 0)) { // search was unsuccessful reset the last discrepancy LastDiscrepancy = 0; diff --git a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/nanoFramework.Devices.OneWire/nf_devices_onewire_native_nanoFramework_Devices_OneWire_OneWireController.cpp b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/nanoFramework.Devices.OneWire/nf_devices_onewire_native_nanoFramework_Devices_OneWire_OneWireController.cpp index 4918457bf4..eb8929e09f 100644 --- a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/nanoFramework.Devices.OneWire/nf_devices_onewire_native_nanoFramework_Devices_OneWire_OneWireController.cpp +++ b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/nanoFramework.Devices.OneWire/nf_devices_onewire_native_nanoFramework_Devices_OneWire_OneWireController.cpp @@ -366,7 +366,7 @@ bool oneWireFindNext (bool doReset, bool alarmOnly) } while (romByteIndex < 8); // loop until we have all ROM bytes - if (romBitIndex < (65 || lastcrc8)) + if ((romBitIndex < 65) || (lastcrc8 != 0)) { // search was unsuccessful reset the last discrepancy LastDiscrepancy = 0;