Skip to content

Commit

Permalink
Scheduling: Do not print with interrupts disabled
Browse files Browse the repository at this point in the history
Serial printing with IRQs disabled is problematic on some Arduino cores,
see e.g.  arduino/ArduinoCore-samd#472
  • Loading branch information
matthijskooijman committed Feb 12, 2020
1 parent cd4bb62 commit 9c37723
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lmic/oslmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,18 @@ void os_runstep (void) {
hal_enableIRQs();
}
if (j) { // run job callback
debug_verbose_printf("Running job %u, cb %u, deadline %F\r\n", (unsigned)j, (unsigned)j->func, (ostime_t)j->deadline, 0);
// Only print when interrupts are enabled, some Arduino cores do
// not handle printing with IRQs disabled
if( (j->flags & OSJOB_FLAG_IRQDISABLED) == 0) {
debug_verbose_printf("Running job %u, cb %u, deadline %F\r\n", (unsigned)j, (unsigned)j->func, (ostime_t)j->deadline, 0);
}
hal_watchcount(30); // max 60 sec
j->func(j);
hal_watchcount(0);
// If we could not print before, at least print after
if( (j->flags & OSJOB_FLAG_IRQDISABLED) != 0) {
debug_verbose_printf("Ran job %u, cb %u, deadline %F\r\n", (unsigned)j, (unsigned)j->func, (ostime_t)j->deadline, 0);
}
}
}

Expand Down

0 comments on commit 9c37723

Please sign in to comment.