Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/hal/drivers/mesa-hostmot2/hm2_modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ static unsigned calc_ifdelay(hm2_modbus_inst_t *inst, unsigned baudrate, unsigne
}

// calculation works for baudrates less than ~24 Mbit/s
if(baudrate <= 19200)
if(baudrate > 19200)
return (175u * baudrate + 99999u) / 100000u;
unsigned bits = 1 + 8 + (parity ? 1 : 0) + (stopbits > 1 ? 2 : 1);
return (bits * 35 + 9) / 10; // Bit-times * 3.5 rounded up
return (bits * 35 + 9) / 10; // Ceil of bits in 3.5 characters.
}

//
Expand Down Expand Up @@ -1049,12 +1049,10 @@ static void process(void *arg, long period)
break;
}
if(inst->maxicharbits && HM2_PKTUART_RCR_ICHARBITS_VAL(frsize) > inst->maxicharbits) {
MSG_WARN("%s: warning: reply to command %u had too long inter-character delay (%u > %u), dropping\n",
MSG_WARN("%s: warning: reply to command %u had too long inter-character delay (%u > %u), trying to interpret\n",
inst->name, inst->cmdidx,
HM2_PKTUART_RCR_ICHARBITS_VAL(frsize), inst->maxicharbits);
set_error(inst, ENOMSG);
force_resend(inst);
break;
}
inst->rxdata[0] = 0; // This will fail the parse packet if the read did not resolve
r = hm2_pktuart_queue_read_data(inst->uart, inst->rxdata, HM2_PKTUART_RCR_NBYTES_VAL(frsize));
Expand Down
Loading