better constraint validation

This commit is contained in:
rusefi 2020-01-19 00:28:58 -05:00
parent b377e1f2f0
commit 2ae53d1681
4 changed files with 15 additions and 3 deletions

View File

@ -2082,7 +2082,7 @@ typedef enum {
CUSTOM_INVALID_ADC = 6720,
CUSTOM_INVALID_MODE_SETTING = 6721,
CUSTOM_ERR_6722 = 6722,
CUSTOM_ERR_TASK_TIMER_OVERFLOW = 6722,
CUSTOM_ERR_6723 = 6723,
CUSTOM_ERR_6724 = 6724,
CUSTOM_ERR_6725 = 6725,

View File

@ -87,6 +87,16 @@ void SingleTimerExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeu
void SingleTimerExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitime_t nt, action_s action) {
ScopePerf perf(PE::SingleTimerExecutorScheduleByTimestamp);
#if EFI_ENABLE_ASSERTS
int deltaTimeUs = nt - getTimeNowNt();
if (deltaTimeUs >= TOO_FAR_INTO_FUTURE) {
// we are trying to set callback for too far into the future. This does not look right at all
firmwareError(CUSTOM_ERR_TASK_TIMER_OVERFLOW, "scheduleByTimestampNt() too far: %d", deltaTimeUs);
return;
}
#endif
scheduleCounter++;
bool alreadyLocked = true;
if (!reentrantFlag) {

View File

@ -82,9 +82,9 @@ void setHardwareUsTimer(int32_t deltaTimeUs) {
if (deltaTimeUs < 2)
deltaTimeUs = 2; // for some reason '1' does not really work
efiAssertVoid(CUSTOM_ERR_6681, deltaTimeUs > 0, "not positive deltaTimeUs");
if (deltaTimeUs >= 10 * US_PER_SECOND) {
if (deltaTimeUs >= TOO_FAR_INTO_FUTURE) {
// we are trying to set callback for too far into the future. This does not look right at all
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareUsTimer() too long: %d", deltaTimeUs);
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareUsTimer() too far: %d", deltaTimeUs);
// let's make this look special and NOT toggle enginePins.debugSetTimer
return;
}

View File

@ -15,6 +15,8 @@ extern "C"
void initMicrosecondTimer(void);
void setHardwareUsTimer(int32_t deltaTimeUs);
#define TOO_FAR_INTO_FUTURE 10 * US_PER_SECOND
#ifdef __cplusplus
}
#endif /* __cplusplus */