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 :)
This commit is contained in:
cserem 2022-07-24 16:52:05 +02:00 committed by GitHub
parent 39cd2b5fa7
commit 8d50db9f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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); 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 ; int i=0 ;
for (auto val : data) { 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 ; return x ;