NQC User Manual. Version 2.0, written by Dave Baum

Similar documents
NQC User Manual. Version 2.2 r1, written by Dave Baum

Not Quite C Compiler version 1.0 b1

Unified Computers & Programming Installation Instructions for Windows

Pod::Usage, pod2usage() - print a usage message from embedded pod documentation

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection

Standard File Pointers

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #47. File Handling

Subcontractors. bc math help for the shell. interactive or programatic can accept its commands from stdin can accept an entire bc program s worth

Output with printf Input. from a file from a command arguments from the command read

Creating a Shell or Command Interperter Program CSCI411 Lab

Binghamton University. CS-220 Spring Includes & Streams

TinyVM: User's Guide

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Table of Contents. 1 TFTP Configuration Commands 1-1 TFTP Client Configuration Commands 1-1 tftp-server acl 1-1 tftp 1-2 tftp ipv6 1-3

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

Classnote for COMS6100

Workshop Swarm robotics Reactive control of LEGO robots with MDL2e. Thomas Schamm

IP address. Subnetting. Ping command in detail. Threads in Python. Sub process in Python

AntiLogReader Command Line Application User Guide

CSE 15L Winter Midterm :) Review

Using lejos communication for games

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

Computers in Engineering Lab #2 Maze Treasure Searching

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts

Lecture 10: Potpourri: Enum / struct / union Advanced Unix #include function pointers

Libgdb. Version 0.3 Oct Thomas Lord

Review of Fundamentals

Ultimate DOS. Command Summary. Gideon Zweijtzer. All work Copyright 2013 by Gideon s Logic Architectures All rights reserved.

XS: Lisp on Lego MindStorms

Programming with MPI

3 PREPROCESSOR. Overview. Listing 3-0. Table 3-0.

lejos NXJ Problem Solving with Robots [PRSOCO601]

Linux shell scripting Getting started *

Lecture Outline. COMP-421 Compiler Design. What is Lex? Lex Specification. ! Lexical Analyzer Lex. ! Lex Examples. Presented by Dr Ioanna Dionysiou

CHAPTER 44. Java Stored Procedures

Data and File Structures Chapter 2. Basic File Processing Operations

Week 5 Lesson 5 02/28/18

Contents Introduction... 1 Specifications... 4 System Architecture... 8 Implementation Results Conclusions... 22

Version 9 of the Icon Compiler. Ralph E. Griswold Department of Computer Science, The University of Arizona

Firmware Reprogramming Guide

GDB QUICK REFERENCE GDB Version 4

CptS 360 (System Programming) Unit 1: Introduction to System Programming

INF3190 Mandatory Assignment:

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017)

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Should you know scanf and printf?

Protocol of data exchange with modem via USB interface Version

MicroBlaze TFTP Server User Guide

Unix/Linux: History and Philosophy

Have examined process Creating program Have developed program Written in C Source code

INTRODUCTION...2 GENERAL INFORMATION...3

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.

Mikrokopter VSM User Guide

Study Guide Processes & Job Control

ACM INTERNATIONAL COLLEGIATE PROGRAMMING CONTEST. California State University, Sacramento s. PC 2 Version 9.6. Judge s Guide

Fisher ROC Plus Serial Driver Help Kepware Technologies

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

Here redirection. Case statement. Advanced Unix Tools Lecture 6 CS214 Spring 2004 Friday March 5, 2004

Goals of this Lecture

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

MPLAB XC8 C Compiler Version 2.00 Release Notes for AVR MCU

I/O Management! Goals of this Lecture!

COMP 2718: Shell Scripts: Part 2. By: Dr. Andrew Vardy

I/O Management! Goals of this Lecture!

stdin, stdout, stderr

Introduction to the shell Part II

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions.

Scripting. More Shell Scripts Loops. Adapted from Practical Unix and Programming Hunter College

This manual is for Libffi, a portable foreign-function interface library. Copyright c 2008, 2010, 2011 Red Hat, Inc. Permission is granted to copy,

5/20/2007. Touring Essential Programs

CS 344/444 Spring 2008 Project 2 A simple P2P file sharing system April 3, 2008 V0.2

Motivation was to facilitate development of systems software, especially OS development.

Lecture 9: Potpourri: Call by reference vs call by value Enum / struct / union Advanced Unix


Part I. UNIX Workshop Series: Quick-Start

18-Sep CSCI 2132 Software Development Lecture 6: Links and Inodes. Faculty of Computer Science, Dalhousie University. Lecture 6 p.

Command-line interpreters

Fragile Reconnaissance Object Processing System

Perle Dial-Out User s Guide

Appendix A. The Preprocessor

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 4 (document version 1.1) Sockets and Server Programming using C

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

Project 1: Snowcast Due: 11:59 PM, Sep 22, 2016

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

More Scripting Todd Kelley CST8207 Todd Kelley 1

Errors During Compilation and Execution Background Information

IAR Assembler Reference Guide

CMPSC 311- Introduction to Systems Programming Module: Build Processing

The Moving Pixel Company DPhyGenCtl CTS Notes -- Doc. Rev /6/15. DPhyGenCtl CTS Notes. - Page i -

CS 11 java track: lecture 1

9.2 Linux Essentials Exam Objectives

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Cobalt Dashboard. Reference Manual

Introduction to Lab 2

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Transcription:

NQC User Manual Version 2.0, written by Dave Baum Introduction NQC stands for Not Quite C, and is a simple language for programming the LEGO RCX. The preprocessor and control structures of NQC are very similar to C. NQC is not a general purpose language - there are many restrictions that stem from limitations of the standard RCX firmware. This document describes how to use the command line version of the NQC compiler. For information about the NQC language and/or the RCX API refer to the NQC Programmer's Gudie. For up-to-date information and documentation for NQC, visit the NQC Web Site at http://www.enteract.com/~dbaum/nqc Usage Invoking NQC without any argument will print the version number and usage information: nqc version 2.0 Copyright (C) 1998,1999 David Baum. All Rights Reserved. Usage: nqc [options] [actions] [ - filename ] [actions] - : read from stdin instead of a source_file Options: -1: use NQC 1.x compatability mode -c: target CyberMaster instead of RCX -d: download program -n: prevent the system file (rcx.nqh) from being included -D<sym>[=<value>] : define macro <sym> -E[<filename>] : write compiler errors to <filename> (or stdout) -I<path>: search <path> for include files -L[<filename>] : generate code listing to <filename> (or stdout) -O<outfile>: specify output file -S<portname>: specify serial port -U<sym>: undefine macro <sym> Actions: -run: run current program -pgm <number>: select program number -datalog -datalog_full: upload datalog -near : set IR to near mode -far : set IR to far mode -watch <time> now : set RCX time

-firmware <filename> : download firmware -sleep <timeout> : set RCX sleep timeout -msg <number> : send IR message to RCX -raw <data> : format data as a packet and send to RCX -clear : erase all programs and datalong in RCX The most typical use of NQC is to compile a source program and download it to the RCX: nqc d your_file Source and Output Files NQC will only accept a single filename for compilation. If '-' is used instead of a filename, stdin is compiled. If a filename ends in.rcx, then it is assumed to be an RCX image file (from a previous compile) and will be used as is (for downloading or listing). NQC will automatically create an output file for you if all of the following conditions are met: You are compiling a file (not stdin) Neither -d or -L have been specified -O has not been used. In this case the output file is named the same as the input file, but with an extension of ".rcx" instead of ".nqc". If the -O option is used and a source file (or stdin) is compiled, then the output file is generated even if -d or -L are used. Preprocessor Options NQC always searches the current directory for include files. Additional directories may be specified using either the NQC_INCLUDE environment variable or the I option. Multiple I options may be specified. Searching is done in the following order: Current Directory Directory specified by NQC_INCLUDE (if any)

Directories specified by I options (if any) When specifying additional include directories, you must include the proper directory separator, for example under Windows you might do something like this to add C:\NQC to the include search path: nqc IC:\NQC\ foo.nqc Most of the RCX API is defined in a special include file named "rcx.nqh". This file is stored within the compiler itself and is usually included automatically before any compilation. The -n option disables this feature and compiles the source file without the RCX API being defined. Two other preprocessor options are available: -Dsymbol[=value] defines symbol in the preprocessor -Usymbol removes symbol s definition Serial Ports The default serial port used by NQC is system dependent: Windows: COM1 Macintosh: modem port Linux: /dev/ttys0 This default can be overridden either by setting the system environment variable RCX_PORT, or by using the S option on the command line. If both are specified, the command line option takes precedence. Miscellaneous Options The c option makes NQC compatible with CyberMaster. This has several effects: Defines the compile time symbol CM (instead of RCX) Targets CyberMaster during compilation (different task/subroutine limits, etc.) Uses the CyberMaster serial protocol for downloading instead of the

The d option can be used to automatically download the compiled file to the RCX. Compiler error messages are normally reported to stderr. If you want to redirect these messages, use the E option. If you specify a filename (e.g. Eerror_file) the messages will be redirected into a file. If no filename is specified (e.g. E) then the errors will be placed on stdout instead of stderr. A program listing may be generated by using the L option. If a filename is specified (e.g. Llist_file), then the listing is written to the named file. Otherwise the listing is written to stdout. The -1 option make NQC compatible with version 1.3 of the NQC compiler. This includes some changes in syntax as well as the 1.3 APIs for the RCX. Actions Actions look similar to options, but they have some subtle differences. In general, options setup things (such as a serial port) for later use, while actions cause something to happen. Actions are executed in the order that they appear on the command line. In addition, actions appearing before the source file happen before compilation, while actions after the source file happen after compilation. For historical reasons, downloading the compiled file is treated as an option and not an action. For example, if you want to compile and download foo.nqc to program slot #2 and run it after downloading, you d use the following command: nqc d pgm 2 foo.nqc run Note that the d option appears before any actions. The pgm action must appear before the source file, otherwise the program change would happen after the program was downloaded. Finally, the run action appears at the end of the line so that the program is started after download is complete A complete list of appears below:

Action -run -pgm number -datalog -datalog_full -near -far -watch time -firmware file -sleep timeout -msg number -raw data -clear Meaning Run the currently selected program. Select a program number on the RCX. Upload the RCX s datalog and print it to stdout Same as -datalog, but with more verbose output Set the RCX s IR mode to short-range set the RCX s IR mode to long-range Set the RCX s clock to the specified time. If now is specified, then the host s current time is used. Download a firmware file to the RCX. Set the auto shutoff timeout (in minutes) for the RCX. Send a message to the RCX. This is useful if you write a program that allows external control via IR messages. Send an arbitrary message to the RCX and print the reply (if any) to stdout. The data should be a hexidecimal string, with no spaces, a zero-padded so that it is an even number of characters (although it may be an odd number of bytes). For example, to read the contents of variable 1, you could use -raw 120001. The bytecodes for raw messages can be found on web sites that document the RCX protocol. Erase all programs and any datalog present in the RCX.