Skip to content

Commit f3c0cff

Browse files
committed
Improve error message when the mbccb file has the wrong signature.
1 parent c0798d4 commit f3c0cff

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,10 +2161,12 @@ static int load_mbccb(hm2_modbus_inst_t *inst, const char *fname)
21612161
// Done reading, now test format
21622162
static const rtapi_u8 signature[8] = {'M','e','s','a','M','B','0','1'};
21632163
if(memcmp(signature, mbccb->sig, sizeof(signature))) {
2164-
MSG_ERR("%s: error: Invalid signature in mbccb file: '", inst->name);
2164+
char buf[sizeof(mbccb->sig)+1];
21652165
for(unsigned i = 0; i < sizeof(mbccb->sig); i++)
2166-
MSG_ERR("%c", isprint(mbccb->sig[i]) ? mbccb->sig[i] : '?');
2167-
MSG_ERR("', expected 'MesaMB01'\n");
2166+
buf[i] = isprint(mbccb->sig[i]) ? mbccb->sig[i] : '?';
2167+
buf[sizeof(mbccb->sig)] = 0;
2168+
MSG_ERR("%s: error: Invalid signature in mbccb file: '%s' (expected 'MesaMB01')\n", inst->name, buf);
2169+
MSG_ERR("%s: error: Have you compiled the mbccs source into a binary mbccb file using mesambccc?\n", inst->name);
21682170
goto errout;
21692171
}
21702172

@@ -2208,7 +2210,7 @@ static int load_mbccb(hm2_modbus_inst_t *inst, const char *fname)
22082210
goto errout;
22092211
}
22102212

2211-
if(mbccb->icdelay > 0x3fc) {
2213+
if(mbccb->icdelay > 0xff) {
22122214
MSG_ERR("%s: error: Mbccb icdelay %u out of range [0..255]\n", inst->name, mbccb->icdelay);
22132215
goto errout;
22142216
}

0 commit comments

Comments
 (0)