Using uLisp from a terminal

As an alternative to using the Serial Monitor in the Arduino IDE you can communicate with uLisp using a serial terminal program. You could also communicate remotely to an Arduino running uLisp using a suitable serial wireless interface.

Version 3.2 of uLisp now includes features to make it more convenient to interact with uLisp from a terminal. There's an integrated line editor, allowing you to delete mistakes during entry, and parenthesis matching to help you keep track of the structure of what you're entering.

The following examples demonstrate this using screen on the Mac, but other terminal programs should behave in a similar way.

Using a terminal

On the Mac you can use the Terminal application, in Applications/Utilities, to provide a serial terminal. First you need to find out the name of the USB port the Arduino is connected to.

  • At the Terminal prompt type:
ls /dev/tty.*

This will display a list of the serial devices:

/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem1411
/dev/tty.Bluetooth-Modem
  • Locate the one that corresponds to the USB port; in this case /dev/tty.usbmodem1411.
  • Give the command:
screen /dev/tty.usbmodem1411 9600

where the second parameter is whatever you found from the previous command, and 9600 specifies the baud rate.

The screen serial terminal should run and show the uLisp prompt:

Terminal1.gif

  • Enter commands at the uLisp prompt; for example:

Terminal2.gif

By default commands are entered as soon as you type the final closing bracket, unless you compiler with the Line editor option described below.

Entering programs

Most terminal emulators such as screen allow you to copy and paste text into the terminal, and this provides a convenient way to enter a Lisp function from a web page, such as the uLisp site, or one you have written in a text editor.

Exiting

To exit from screen:

  • Type ctrl-A ctrl-\ and answer y to the prompt.

Line editor

To get the line editor compile uLisp with the option:

#define lineeditor

uLisp provides an input buffer, allowing you to correct mistakes by pressing the delete key, or typing backspace. The line is not submitted to uLisp until you press enter.

Parenthesis matching

If, in addition, you include the option:

#define vt100

uLisp uses ANSI standard terminal codes to implement parenthesis matching, highlighting matching parentheses in inverse video as you type:

Terminal3.gif

Note that the parenthesis matching assumes a screen width of 80 characters.