LegOS Command Reference 1.0 + epsilon

(for LegOS Version 0.2.4 + epsilon)

The history and development of LegOS as been a feat of amazing ingenuity and engineering prowess. However, documentation for LegOS for the novice user has been difficult to come by since it's inception. This is probably rooted in the fact that from the beginning, this has been an "expert's only" development; developed by hardcore hackers/ programmers/hardware gurus for those with the same inclination. Consequently, much of the documentation available has been through the automatically generated API docs, which are often difficult to wade through.

This document hopes to list and outline the main C (User level) commands available to the LegOS programmer to directly control the RCX via LegOS. This is a distilled down list obtained from the LegOS File Members document. Please consult the LegOS Source Forge Repository as the definitive reference.

Hopefully, when the new Extreme Mindstorms book is available, this document will be made obsolete as we will now have a really professionally written and definitive listing and explanation of the inner workings of LegOS. In the meantime, this is my humble contribution to the LegOS community for giving me such an intriguing new toy to play with.

Dave Chen 10/29/2000

Based on Dave's great work I have added some information on LNP and semaphores that was not so well documented. I'm also trying to upgrade the refernce to version 0.2.6 Tobias Amnell


Display positions
Digit display positions are denumerated from right to left, starting with 0 for the digit right to the running man. Digit 5 is only partially present on the RCXs display.
Native segment masks
In these bitmasks, bit 0 toggles the middle segment. Bit 1 toggles the top right segment, and the remaining segments are denumerated counterclockwise. The dot isn't encoded.

LNP - LegOS Network Protocol

Currently the best documentation on LNP is in Louis Villas LegOS HOWTO.

LNP has two layers, the lower integrity layer provides uncorrupted transmission of messages, the upper adressing layer adds adressing of packages to ports. Arriving packages are handled by packet handlers that the user must provide. A packet handler for adressing layer has the general form
void my_addr_handler(const unsigned char *data, unsigned char length, unsigned char src)
and for the logical level
void my_int_handler(const unsigned char *data, unsigned char length).

Memory Management and String Operations

Motor Control

RCX Button Input


This section was updated by Tobias Amnell since the original author did not write anything here. Semaphores are counters that can be used to guard resources shared between threads. The implementation of semaphores in legOS follows the standard POSIX 1003.1b.


Defined Constants:  LIGHT_RAW_BLACK =  0xffc0 (active light sensor raw black value), LIGHT_RAW_WHITE = 0x5080 (active light sensor raw white value).  LIGHT_MAX = maximum decoded value at LIGHT_RAW_WHITE using the formula SCALED_LIGHT_READING = (147 - (RAW_LIGHT_READING >> 6) / 7).


Task Management


legOS-0.2.4 is released under the Mozilla Public License. Original code copyright 1998-1999 by the authors.
Command Reference copyright 2000 by David C. Chen.