DCL Remote Control Patch for brickOS
Aim
The brickOS (formerly legOS) kernel should be extended, so that programs on the RCX can be started and stopped by a program running on a PC. This shouldn't require any changes on the user programs running on the RCX.
Idea
The default handler for LNP packages in the brickOS kernel has to
be extended by two commands: "kill" stops all user programs
(respectively all programs running on a lower priority than
PRIO_HIGHEST!), start X
starts the program no. X.
Because the handler is implemented in the kernel, it is running
during the whole power-on time of the RCX. A disadvantage is that
the kernel has to be recompiled whenever the patch has to be
changed.
Implementation
The implementation can be found in rtm.c
resp.
rtm.h
: rtm_handler(...)
has to be
registered on an arbitrary LNP port (by default it is just called in
the default handler for port 0 - packet_producer(...)
in program.c
). The function copies according messages
in a buffer, so that rtm_thread(...)
can evaluate them
(rtm_start()
, called in kmain.c
starts
only this thread).
Unfortunately we had to change several locations in the kernel,
because the number of running (kernel) threads was still hardcoded
and checked against nb_tasks
. All changes can be found
by searching for CONF_RTM
. But it seems that this has
been changed in current brickOS versions!
Disvantages of this implementation: User threads aren't allowed to run in the highest priority and to change the default handler for port 0. Unfortunately this can't be checked easily.
The patch
rtm.patchRename the (unpatched) brickOS/legOS directory to legOS:
mv legOS-0.2.x legOS
Patch the kernel:
patch -Np0 < rtm.patch