Fix simulator (#3360)

* fix simulator

* print out halt reason

* option to close simulator after time

* workflow calls it

* test with the bug still present

* ...and fix the bug
This commit is contained in:
Matthew Kennedy 2021-10-17 17:07:25 -07:00 committed by GitHub
parent 4863d5ae71
commit 56afeb17c8
4 changed files with 19 additions and 2 deletions

View File

@ -31,6 +31,10 @@ jobs:
working-directory: ./simulator/
run: bash compile.sh
- name: Run Simulator (10 seconds)
working-directory: ./simulator/
run: ./build/rusefi_simulator 10
- name: Upload built simulator
uses: actions/upload-artifact@v2
with:

View File

@ -92,6 +92,8 @@ void SleepExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, acti
}
void SleepExecutor::cancel(scheduling_s* s) {
chibios_rt::CriticalSectionLocker csl;
if (chVTIsArmedI(&s->timer)) {
chVTResetI(&s->timer);
}

View File

@ -727,7 +727,7 @@
* the system is halted.
*/
#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
printf("chSysHalt\r\n"); \
printf("chSysHalt: %s\r\n", reason); \
exit(-1); \
}

View File

@ -129,10 +129,12 @@ static evhandler_t fhandlers[] = { termination_handler, sd1_handler, sd2_handler
bool verboseMode = true;
static virtual_timer_t exitTimer;
/*------------------------------------------------------------------------*
* Simulator main. *
*------------------------------------------------------------------------*/
int main(void) {
int main(int argc, char** argv) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
@ -143,6 +145,15 @@ int main(void) {
halInit();
chSysInit();
if (argc == 2) {
int timeoutSeconds = atoi(argv[1]);
printf("Running rusEFI simulator for %d seconds, then exiting.\n\n", timeoutSeconds);
chSysLock();
chVTSetI(&exitTimer, MY_US2ST(timeoutSeconds * 1e6), &exit, 0);
chSysUnlock();
}
/*
* Console thread started.
*/