Skip to content
/ nqc Public

NQC (Not Quite C) is a programming language for several Lego MindStorms products, including the RCX, CyberMaster, and Scout. This BrickBot/nqc repo captures updates to the code since NQC 3.1 r6 and is believed to be the most progressed nqc repo. This version includes patches posted to https://sourceforge.net/p/bricxcc/patches/.

License

Notifications You must be signed in to change notification settings

BrickBot/nqc

Repository files navigation

NQC NQC CI

Not Quite C is a simple language with a C-like syntax that can be used to program Lego's RCX programmable brick (from the MindStorms set).

  • If you are just getting started with programming, then graphical environments such as the MindStorms RIS software or RoboLab are probably better choices.
  • If, however, you are a C programmer and prefer typing a few lines to drag-and-drop icon programming, then NQC might be perfect for you.

Tip

For tutorials, examples, reusable libraries, and more, please check out the associated NQC-Libs project.

About

This BrickBot/nqc repo captures changes to the 3.1r6 code as found on BricxCC, including the following patches that were posted by Matthew Sheets to the original SourceForge project site following the release of nqc 3.1r6 but never incorporated:

  1. Added TCP support, facilitating use of NQC with programs such as BrickEmu (an RCX emulator)
  2. Added additional capabilities for specifying the default USB port, including at both compile time using a Make variable and via enhanced command-line argument support
  3. Support Makefile variables DESTDIR and TOOLPREFIX
  4. Enable specifying the default IR tower name in a configuration file
  5. Support using a Make variable to specify the default compile-time port name, instead of having to modify source code files

This release also attempts to build on the jverne/nqc copy, which was maintained to keep NQC building and running on OS X and BSD.

For bug reports about this fork of NQC, please file a GitHub Issue for this project.


WebAssembly Support

A new NQC platform target demonstrated by GitHub user maehw is WebAssembly, which is part of a broader vision. The initial WebNQC implementation only targets WebAssembly (dropping support for Linux, Unix, Windows, and MacOS platforms), but WebAssembly targeting support has now been incorporated into this main repository while preserving the support for other platforms. Additionally, the Makefile has also been updated so that only one command—make—is needed to build from source.

With NQC compiled as WebAssembly bytecode (WASM), it can run in a web browser—without any installation and independent of the machine’s platform (Windows, Linux, Unix, MacOS, etc).


The original README from the NQC project follows:

(Orignal) NQC ReadMe

If you have a problem, PLEASE CHECK THE FAQ:

Send bug reports to bricxcc@comcast.net. Be sure to include details about what platform you are running nqc on and a sample file that demonstrates the bug if possible.

For updates and additional documentation, visit the NQC Web Site

Note to Windows Users

NQC is a command line based tool - normally you run it by typing an appropriate command into an MS-DOS window. There is no GUI for it and if you double-click the nqc.exe file an MS-DOS console will be created for you, NQC will run within it, then since NQC finishes almost immediately, the entire window will disappear.

Some people prefer command line based tools because they allow you to use the text editor of your choice, etc. It also makes for identical behavior under Windows, Mac, and Linux. In order to use the command line version of NQC you'll need to do two things:

  1. Use some sort of text editor (such as Notepad) to edit and save a source file for NQC to compile.

  2. From an MS-DOS window type the appropriate NQC command. Its usually best to either put all of your programs and nqc.exe in the same directory, or make sure the directory containing NQC is in your command path.

If any of the above seem either too confusing or too tedious, then you may want to try the BricxCC which provides a familiar Windows style GUI on top of the standard NQC compiler. You can download BricxCC here:

http://bricxcc.sourceforge.net/

Getting started

Download the appropriate compiler (nqc or nqc.exe) and put it where your shell can find it as a command.

The IR tower should be connected to your modem port (macintosh) or COM1 (Win32/Linux). The IR tower should be set for "near" mode (small triangle). The RCX should also be set for this mode, and firmware must already be downloaded.

Compile and download the test file using the following command line:

`nqc -d test.nqc

The test program assumes there's a motor on output A and a touch sensor on input 1. It turns on the motor and waits for the switch to be pressed, then it turns off the motor and plays a sound.

If you are using a USB tower or a different serial port you will need to specify the port either by adding a -Sx option (where x is the name of the port) to the command line or by setting the RCX_PORT environment variable.

Here are some examples:

USB tower (where supported) nqc -Susb -d test.nqc

Win32 COM2 port: set RCX_PORT=COM2

Win32 USB port: set RCX_PORT=usb

Linux: The syntax for setting environment variables is shell specific. By default nqcc uses "/dev/ttyS0" as the device name for the serial port. If you are using the second serial port, then "/dev/ttyS1" should work. Other device drivers may or may not work depending on if they implement the expected ioctl's to setup the baud rate, parity, etc.

About

NQC (Not Quite C) is a programming language for several Lego MindStorms products, including the RCX, CyberMaster, and Scout. This BrickBot/nqc repo captures updates to the code since NQC 3.1 r6 and is believed to be the most progressed nqc repo. This version includes patches posted to https://sourceforge.net/p/bricxcc/patches/.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published