Skip to content

Commit 284dade

Browse files
authored
Merge pull request #13 from AlexSeferidis/main
Fixed non-initialization of loop indexes in `poll()` function.
2 parents 2c76a96 + 049b607 commit 284dade

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/CSE_ModbusRTU.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ int CSE_ModbusRTU_Server:: poll() {
12781278
uint8_t byteCount = request.getByte (MODBUS_RTU_ADU_DATA_INDEX + 4); // Get the byte count
12791279

12801280
// Now we need to copy the coil data from the request ADU
1281-
for (int i, j = 0; i < byteCount; i++) {
1281+
for (int i = 0, j = 0; i < byteCount; i++) {
12821282
for (int k = 0; ((k < 8) && (j < request.getQuantity())); k++) {
12831283
coilData [j] = (request.getByte (MODBUS_RTU_ADU_DATA_INDEX + 5 + i) >> k) & 0x01;
12841284
j++;
@@ -1331,7 +1331,7 @@ int CSE_ModbusRTU_Server:: poll() {
13311331
uint8_t byteCount = request.getByte (MODBUS_RTU_ADU_DATA_INDEX + 4); // Get the byte count
13321332

13331333
// Now we need to copy the holding register data from the request ADU
1334-
for (int i, j = 0; i < byteCount; i += 2) {
1334+
for (int i = 0, j = 0; i < byteCount; i += 2) {
13351335
holdingRegisterData [j] = request.getWord (MODBUS_RTU_ADU_DATA_INDEX + 5 + i);
13361336
j++;
13371337
}

0 commit comments

Comments
 (0)