From 8d50db9f4fc456ea23995d37269acfc11dd22139 Mon Sep 17 00:00:00 2001 From: cserem Date: Sun, 24 Jul 2022 16:52:05 +0200 Subject: [PATCH] Update modbus_controller.rst In the example `i` gets incremented before the loop is over, but it is referenced again. This can cause unexpected resutls if just blindly copy this example. (ask me, how i know :) --- components/sensor/modbus_controller.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/sensor/modbus_controller.rst b/components/sensor/modbus_controller.rst index 68d923363..e5bd03f9f 100644 --- a/components/sensor/modbus_controller.rst +++ b/components/sensor/modbus_controller.rst @@ -134,7 +134,8 @@ This example logs the value as parsed and the raw modbus bytes received for this ESP_LOGI("","Sensor properties: adress = 0x%X, offset = 0x%X value type=%d",item->start_address,item->offset,item->sensor_value_type); int i=0 ; for (auto val : data) { - ESP_LOGI("","data[%d]=0x%02X (%d)",i++ ,data[i],data[i]); + ESP_LOGI("","data[%d]=0x%02X (%d)",i,data[i],data[i]); + i++; } return x ;