Skip to content

Commit a90a4e6

Browse files
committed
Fix counting registers or the buffer just fills up.
1 parent 9c2ab7e commit a90a4e6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/hal/drivers/mesa-hostmot2/hm2_modbus.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,9 +1472,9 @@ static int build_data_frame(hm2_modbus_inst_t *inst)
14721472
for(unsigned i = 0; i < cc->cmd.cpincnt; i++) {
14731473
// Stuff empty space with zeros.
14741474
// The device must allow writes at the address(es).
1475-
while(regpos != cc->typeptr[i].regofs) {
1475+
while(regpos < cc->typeptr[i].regofs) {
14761476
CHK_RV(ch_append16(cc, 0));
1477-
regpos += 2;
1477+
regpos++;
14781478
}
14791479
switch(cc->typeptr[i].htype) {
14801480
case HAL_BIT:
@@ -1546,6 +1546,7 @@ static int build_data_frame(hm2_modbus_inst_t *inst)
15461546
// Oops...
15471547
break;
15481548
}
1549+
regpos += mtypesize(cc->typeptr[i].mtype);
15491550
p++;
15501551
}
15511552
break;

0 commit comments

Comments
 (0)