Re: delay() void promisc_cb(uint8_t *buf, uint16_t len)
Posted: Fri Jun 01, 2018 7:22 pm
No - it has nothing to do with 'mixing system calls' with arduino code. Firstly, 'arduino code' : what does that mean? Second, it is absolutely do do with 'mixing' a delay() call inside a callback most likely called from an ISR - delay() can interact with interruts itself (via get time and so forth) which then becomes recursive/problematic and the stack gets upset - you cannot mix things like that together. It's difficult to make a simple explanation, other than 'don't specifically put a delay() call in there. Same goes for yield(), as you shouldn't hold-up ISRs, but otherwise you will most likely be OK, with what I think you mean by 'arduino' code. You still need to know what you are doing however. It would be too simplistic to say that anything will work in this context as each system/function/api call behaves differently and has its own requirements. In other words, just because a system/api call can be compiled does not make it sensible or correct.
I would also refer to my previous post, and ask why would you want a delay in there, what are you trying to do? It is often better to express what you want to do, and then we can provide a solution rather than just explaining interaction issues such as these. In real 'real-time'/event driven programming using something like delay() in a non-preemptive system would be frowned upon.
I would also refer to my previous post, and ask why would you want a delay in there, what are you trying to do? It is often better to express what you want to do, and then we can provide a solution rather than just explaining interaction issues such as these. In real 'real-time'/event driven programming using something like delay() in a non-preemptive system would be frowned upon.