Page 204 - The Unofficial Guide to Lego Mindstorms Robots
P. 204

193


          your source code.∗ For example, if you saved the source code above in a file called /projects/HellolegOS.cyou would edit the
          Makefile's TARGET like this:

              TARGET=/projects/HellolegOS

          Then type make at the command line. If everything is installed corr ectly, you'll end up with a HellolegOS.srec file in the
          sa me directory as the source file.

                                   Trouble with  Make

          If you can't make HellolegOS.c, and you' re starting to curse at your computer, ta ke a deep
          breath. legOS has a strong online community; people will help if you ask. The "Online
          Resources" section of this chapter has pointers to helpful sites. One of the best things you
          ca n do is look at LUGNET, http://www.lugnet.com/, and search through the discussion
          group archives for the particular prob lem you're having. There are at least as many
          messages about configuring t he legOS development tools as there are about actually
          p rogramming in legOS.

          If you're using one of the online compilers,just co py the source into  the web page and press the compile button. If there are no
          errors, you will get back an .srec file representing your compiled legO S program.

          Regardless of how th e source file is compiled, you will then need to download th e .srec file to the RCX, using either nqc or
          firmdl.

          When the download is complete, your RCX will display the string "legOS" to indicate that legOS is running. To actually run
          the program yo u just wrote, press the Run button. The display will show "Hello" for a second or so, then show two zeros. The
          le ft number shows the result returned from our main() function. Control has now returned to legOS; you can use the On-
          Off button to switch th e RCX off and on. When the RCX is on, you can press Run again to see the "Hello'' message again.
          Show your friends and family; they will be awed and inspired.

          Function Reference
          Once you've seen one RCX development environment, you've seen them all—to some degree, at least. If you've been reading
          through this book in order, you've probably noticed that NQC and pbFORTH have similar commands but different syntax.
          Likewise, legOS has a set of functions that looks a lot like pbFORTH and

          ∗ Make sure you've edited Makefile.common. The TOOLPREFIX and LEGOS_ROOT lines should point to the appropriate
          directories on your system, as described in the comments. Make sure you put a trailing slash on the LEGOS_ROOT directory.
   199   200   201   202   203   204   205   206   207   208   209