Repository navigation
hostmot2: fix input bounds, divisors and PWM clamping - #4661
sleepybishop wants to merge 14 commits into
Conversation
Use integer ceiling when storing clamped scan rates so the following cycle cannot calculate an out-of-range divisor again. Keep the existing control flow and divisor limit. Test startup and runtime clamps, unchanged valid rates, and repeated cycles across all scan widths with three clock frequencies.
|
Same comment on the test as in #4660. |
| r = hm2->llio->write(hm2->llio, hm2->bspi.instance[i].count_addr, &zero, sizeof(rtapi_u32)); | ||
| if (r < 0) { | ||
| if (r <= 0) { | ||
| HM2_ERR("BSPI: hm2->llio->write failure %s\n", name); | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
llio->write() and llio->read() functions are supposed to return not zero on success and zero on failure.
From hostmot2-lowlevel.h:
// on success these two return TRUE (not zero)
// on failure they return FALSE (0) and set *self->io_error (below) to TRUE
int (*read)(hm2_lowlevel_io_t *self, rtapi_u32 addr, void *buffer, int size);
int (*write)(hm2_lowlevel_io_t *self, rtapi_u32 addr, const void *buffer, int size);Any implementation that does not adhere to this should be fixed.
(same test other places as well)
There was a problem hiding this comment.
Thanks, fixed in 1ca33cf: zero means failure; nonzero means success.
| @@ -0,0 +1,23 @@ | |||
| HostMot2 UART/BSPI and scan-rate software regression tests | |||
There was a problem hiding this comment.
Same comment on the test as with the pktuart code update.
There was a problem hiding this comment.
Removed the standalone harness and build hook.
| buff = ((rtapi_u32)data[c] | ||
| | ((rtapi_u32)data[c+1] << 8) | ||
| | ((rtapi_u32)data[c+2] << 16) | ||
| | ((rtapi_u32)data[c+3] << 24)); |
There was a problem hiding this comment.
Why is the cast necessary?
(several more instances below)
There was a problem hiding this comment.
Kept only the cast before << 24: unsigned char promotes to signed int, so the cast makes that shift unsigned. Restored the original additions.
Split from #4488 as requested. Adds UART/BSPI input and LLIO checks, guards scan-rate and resolver divisors, bounds connector-name access, and fixes RPi3 SPI speed decoding and negative B/C PWM clamping. Existing successful API returns and UART/BSPI
-1errors are preserved.Local builds pass. Hardware coverage remains incomplete.