mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-26 17:27:47 +01:00
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:
parent
39cd2b5fa7
commit
8d50db9f4f
@ -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 ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user