Pasting in long listings on the ESP32


#1

On most uLisp platforms a convenient way of entering a long program is to copy it from a listing, paste it into the Arduino IDE Serial Monitor input field, and press Return to enter it.

For example, you could display this Infinite precision arithmetic program:

http://www.ulisp.com/list?2ADN

Do Select All, Copy, then in the Serial Monitor input field do Paste.

You could use the same technique to enter a Lisp program you are writing in a text editor.

This works on most platforms, apart from ESP32 boards that use the built-in CDC USB interface, due to a limitation of the rate at which they can process the serial input. On those boards, pasting a long listing causes the serial interface to lock up, requiring a reset of the board.

One workaround is to copy and paste a few lines at a time; I’ve found three is a good compromise. However, this is very tedious for a long listing.

I’ve recently found an alternative, which is to use the free CoolTerm terminal program, available for both Mac and Windows. This adds a delay after transferring each line, which gives the ESP32’s built-in USB interface time to catch up with the serial input.

Using CoolTerm

CoolTerm is available for free download from Roger Meier’s site:

Roger Meier’s Freeware

To set it up:

  • Click the Options button in the toolbar.
  • Click the Serial Port tab, and select the board’s serial port from the Port menu:

  • Click the Connect icon in the toolbar, and you should get the uLisp prompt.
  • Copy the listing you want to enter, making sure to include the comment at the top of the listing, and do Paste into the terminal window.

The comment disables echo while the listing is being transferred, which prevents the echo from interfering with the transfer.

You should see the names of the functions being entered into uLisp:

When you’re interacting with uLisp, rather than pasting in a listing, you might find it more convenient to use Line Mode:

  • In Options click the Terminal tab and set the Terminal Mode to Line Mode:

In line mode you can edit the line, in a separate field at the bottom of the terminal window, before pressing Return to enter it.

Note: When using CoolTerm, don’t upload uLisp with the following options enabled:

// #define lineeditor
// #define vt100

CoolTerm has it’s own line editor (and doesn’t work with uLisp’s line editor), and doesn’t have VT100 emulation.


#2

The Minicom terminal emulator for Linux, which comes with most distros, provides a similar transmission delay feature. I’ll give it a try with my Cardputer.


#3

I’ve discovered a better solution for the Mac; iTerm2:

Downloads - iTerm2 - macOS Terminal Replacement

It allows you to run screen, with vt100 emulation which gives you the advantage of a line editor and parenthesis matching, and it has an Edit->Paste Special->Paste Slowly menu option that overcomes the CDC buffer size limitation.

Follow the instructions for running screen here:

Using a terminal

I’ll rewrite that page soon to reflect these options. Please let me know what works on other platforms.


#4

Do you mean that uLisp can be built with both #define vt100 and #define lineeditor for use with terminal emulators that support transfer delays?


#5

Without the #define lineeditor and #define vt100 options uLisp supports a terminal, but your input gets evaluated as soon as you type a matching closing parenthesis.

You can get uLisp to provide a line editor by enabling #define lineeditor. This waits for a Return character before transferring your input, and you can use backspace/delete to edit the line. In the next version of uLisp it will also provide autocomplete, like the Cardputer, PicoCalc, and T-Deck.

In addition, if the terminal is VT100 compatible you can enable #define vt100 and uLisp will then provide parenthesis matching.

Independently of these options, if the terminal provides Paste Slowly or a line delay you can use this to overcome the buffer limitation of the ESP32 boards with hardware USB.

Hope that makes it a bit clearer!


#6

I tried Minicom with uLisp 4.7d (I can’t currently upgrade to later versions) on the Cardputer and pasting long listings works with a delay of 2 ms. The relevant Minicom option is accessible in the terminal settings screen with Ctrl-A T, then press D to set the option Newline tx delay (ms) to 2.

minicom-terminal-settings