revert change caused by commit 2c7c2c8e until we have a solution.

This reverts the behavior of getNSecs so to always return rtos_get_time_ns(),
like it did before.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
docs: fix bug in documenting port reads + add section on level events with ports.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
scripting: more robust state change scheduling in order to avoid races

When evenTransition comes into a state machine, this may cause re-writing
of the entry/running/exit programs currently being executed, becaues the
event sets these hooks immediately, instead of letting the FSM finish
the current (entry or exit) program.

This patch lets changeState schedule a state change, and makes enterstate/
leavestate effectively do the state change and switch the new state programs in.

Since changeState now only schedules, in a number of places, the executePending()
function needs to be called to effectively execute SM statements.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
scripting: correctly implement asynchronous events in eventTransition

Before this patch, only the last eventTransition of two consecutive ones took effect,
since the event data was shared among all subscribers. This patch makes eventTransition
synchronous again such that each eventTransition evaluates its own data. This requires
some proper locking in the SM.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>