1nqc(1)                      General Commands Manual                     nqc(1)
2
3
4

NAME

6       nqc - A simple C-like language for Lego's RCX programmable brick
7

SYNOPSIS

9       nqc [ options ] [ actions ] [ - | filename ] [ actions ]
10

DESCRIPTION

12       NQC  stands  for  Not Quite C, and is a simple language for programming
13       the LEGO RCX.  The preprocessor and control structures of NQC are  very
14       similar  to C.  NQC is not a general purpose language -- there are many
15       restrictions that stem from limitations of the standard RCX firmware.
16
17       This man page does not attempt to describe the NQC programming language
18       or  the  RCX  API,  merely the options of the nqc command-line program.
19       References to more complete documentation are given at the end of  this
20       man page.
21
22
23       nqc is normally used to process a single source file given as filename.
24       You can also read from stdin by using - instead.  If the filename  ends
25       in  .rcx, it is assumed to be a RCX image file from a previous compile,
26       and will be used as is (for downloading or listing).
27
28

OPTIONS

30       -1     use NQC 1.x compatibility mode.  The RCX  API  changed  signifi‐
31              cantly  with version 2.0.  This flag makes the compiler grok old
32              code.
33
34       -Ttarget
35              generate code and use communications methods for "smart  bricks"
36              other than the RCX.  Currently, can be either CM or Scout.
37
38       -d     download program to the RCX.  When this option is given, code is
39              sent directly over the serial port to the brick  and  no  output
40              file is generated by default.
41
42       -n     prevent   the  standard  nqc.h  file  from  being  automatically
43              included.
44
45       -Dsym[=value]
46              define macro sym as value.
47
48       -E[filename]
49              write compiler errors to filename (or  to  stdout,  if  no  name
50              specified) instead of to stderr.
51
52       -Ipath search  path  for include files.  Multiple directories should be
53              seperated as normal for the platform (under Linux / Unix, that'd
54              be  "").  Can also be set with the NQC_INCLUDE environment vari‐
55              able.
56
57       -L[filename]
58              generate a human-readable bytecode listing to  filename  (or  to
59              stdout) instead of generating a binary file.
60
61       -Ooutfile
62              output code to outfile.  This option causes a file to be written
63              even if -d or -L is also given.  If no  filename  is  specified,
64              the  output  file  will have the same basename as the input file
65              but an extension of .rcx instead of .nqc.
66
67       -Sportname
68              use serial  port  portname.   Under  Linux,  /dev/ttyS0  is  the
69              default.   (This  will differ on other platforms.)  The port can
70              also be specified via the RCX_PORT environment variable, but the
71              command line option takes precedence.
72
73       -Usym  undefine macro sym.
74

ACTIONS

76       Actions look similar to options, but they have some subtle differences.
77       In general, options set up things (such as a  serial  port)  for  later
78       use,  while actions cause something to happen.  Actions are executed in
79       the order that they appear on the command line.  In  addition,  actions
80       appearing  before  the  source  file  happen  before compilation, while
81       actions after the source file happen after compilation.  For historical
82       reasons,  downloading the compiled file (-d) works as an option and not
83       an action.
84
85       -run   run the current program.  This causes the  program  selected  on
86              the RCX to execute.
87
88       -pgm number
89              select  program  number.   This  changes the program slot on the
90              RCX.
91
92       -datalog
93              get the datalog from the RCX and print it to stdout.
94
95       -datalog-full
96              same as -datalog but with more verbose output.
97
98       -near  set the IR port to short-range mode.
99
100       -far   set the IR port to long-range mode.
101
102       -watch time
103              set the RCX's clock to the specified time.  If you use now, then
104              the host's current time is used.
105
106       -firmware filename
107              downloads  the  firmware  to  the RCX.  You'll need the official
108              Lego RCX firmware from the CD-ROM -- the  current  (and  so  far
109              only) file is called firm0309.lgo.  This will probably be neces‐
110              sary the first time you use your RCX,  and  whenever  it's  been
111              without batteries for more than a few minutes.
112
113       -firmfast filename
114              same  as -firmware, but at quad speed.  Requires the tower to be
115              in near mode (see -near).   If you have trouble getting the fast
116              download  to  work,  please  revert  to  the  older (and slower)
117              method.
118
119       -sleep timeout
120              set RCX auto-shutoff timeout, in minutes.
121
122       -msg number
123              send IR message to RCX. The brick will respond to this  just  as
124              it would a communication from another RCX.
125
126       -raw data
127              send an arbitrary packet to the RCX and print the reply (if any)
128              to stdout.  The data should be a  hexadecimal  string,  with  no
129              spaces,  zero-padded  so that it is an even number of characters
130              (although it may be an odd number of  bytes).  For  example,  to
131              read  the contents of variable 1, you could use -raw 120001. The
132              bytecodes for raw messages can be found on web sites that  docu‐
133              ment the RCX protocol.
134
135       -remote value repeat
136              send a repeating remote command to the RCX.
137
138       -clear erase all programs and datalog from the RCX.
139

ENVIRONMENT VARIABLES

141       RCX_PORT
142              sets the default serial port.  See the -S option.
143
144       NQC_OPTIONS
145              specifies  extra  options  to be inserted into the command line.
146              For example, setting NQC_OPTIONS to -TScout would cause  nqc  to
147              target the Scout by default.
148
149       NQC_INCLUDE
150              specifies  additional  paths  to  search for include files.  See
151              also the -I option.
152

EXAMPLES

154       To compile foo.nqc, download the bytecode to program  slot  three,  and
155       make the RCX start executing it immediately:
156
157           nqc -d -pgm 3 foo.nqc -run
158
159       To just compile bar.nqc, resulting in bar.rcx:
160
161           nqc bar.nqc
162
163       To download bar.rcx to the RCX:
164
165           nqc -d bar.rcx
166
167       To  set  the  IR tower to short-range mode and download the firmware at
168       high speed:
169
170           nqc -near -firmfast firm0309.lgo
171
172       To compile /usr/doc/nqc-2.1.0/test.nqc and print the resulting bytecode
173       listing to the screen in human-readable format:
174
175           nqc -L /usr/doc/nqc-2.1.0/test.nqc
176
177       (This should result in the following output under nqc 2.1.0:
178
179           *** Task 0 = main
180           000 pwr        ABC, 7                13 07 02 07
181           004 dir        ABC, Fwd              e1 87
182           006 InType     0, Switch             32 00 01
183           009 InMode     0, Boolean            42 00 20
184           012 out        A, On                 21 81
185           014 chkl       1 != Input(0), 14     95 82 09 01 00 00 fa ff
186           022 plays      0                     51 00
187           024 out        A, Off                21 41
188
189       )
190

FILES

192       Older  versions  of  nqc  required a seperate rcx.nqh or rcx2.nqh file.
193       This is now integrated into the binary and no longer necessary, but for
194       reference,  rcx2.nqh  is  included with the package.  (If you installed
195       the RPM, try /usr/doc/nqc-2.1.0/rcx2.nqh).
196

SEE ALSO

198       http://www.enteract.com/~dbaum/nqc/
199              The main Not Quite C web site.  You'll definitely want  to  look
200              here.   Notably,  you'll  find the NQC Programmer's Guide, which
201              covers the NQC language itself.
202
203       http://www.crynwr.com/lego-robotics/
204              A great site for alternative RCX / Mindstorms development.
205
206       http://graphics.stanford.edu/~kekoa/rcx/
207              Details on the internals of the RCX and the RCX protocol.
208
209       http://www.lugnet.com/robotics/rcx/nqc/
210              Discussion  group  for  NQC.   Also  available   via   NNTP   at
211              lugnet.com.
212
213       http://nqc.mattdm.org/
214              Linux binaries and RPM-format packages for NQC, including source
215              RPMs.  Also has an RPM containing the NQC language documentation
216              from  Dave's  site,  in  case  you'd prefer to have it installed
217              locally.
218

BUGS

220       None known.  But be aware that Scout support is still  preliminary  and
221       may change significantly.
222
224       nqc  is Copyright (C) 1998-2000 David Baum and released under the terms
225       of the Mozilla Public License.  See the documentation included with the
226       program for more details.
227

AUTHOR

229       The  Not  Quite C programming language and the nqc program were written
230       and are maintained by Dave Baum.  Various contributions have been  made
231       by  other  people  --  a  full list of these can be found on Dave's web
232       site.
233
234       This man page was written by Matthew Miller  (mattdm@mattdm.org),  with
235       extremely large amounts of borrowing from other NQC documentation.
236
237
238
239                          Version 2.1 r1: 19 Feb 2000                   nqc(1)
Impressum