Skip to content

Commit bd39b0a

Browse files
Scheduling: Do not print with interrupts disabled
Serial printing with IRQs disabled is problematic on some Arduino cores, see e.g. arduino/ArduinoCore-samd#472
1 parent dc7428c commit bd39b0a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lmic/oslmic.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,18 @@ void os_runstep (void) {
178178
hal_enableIRQs();
179179
}
180180
if (j) { // run job callback
181-
debug_verbose_printf("Running job %u, cb %u, deadline %t\r\n", (unsigned)j, (unsigned)j->func, (ostime_t)j->deadline);
181+
// Only print when interrupts are enabled, some Arduino cores do
182+
// not handle printing with IRQs disabled
183+
if( (j->flags & OSJOB_FLAG_IRQDISABLED) == 0) {
184+
debug_verbose_printf("Running job %u, cb %u, deadline %t\r\n", (unsigned)j, (unsigned)j->func, (ostime_t)j->deadline);
185+
}
182186
hal_watchcount(30); // max 60 sec
183187
j->func(j);
184188
hal_watchcount(0);
189+
// If we could not print before, at least print after
190+
if( (j->flags & OSJOB_FLAG_IRQDISABLED) != 0) {
191+
debug_verbose_printf("Ran job %u, cb %u, deadline %F\r\n", (unsigned)j, (unsigned)j->func, (ostime_t)j->deadline, 0);
192+
}
185193
}
186194
}
187195

0 commit comments

Comments
 (0)