A Minimal Interactive Environment
Posted: Sun Mar 23, 2025 9:18 pm
Once you can communicate with your '02 system via a serial port and are running a monitor (or a Forth or BASIC) via a serial port terminal on a PC, things get awkward.
I am always envious of a Lisp-like environment -- a full-screen editor capable of sending text to the target when desired. This allows for easy code development (editing files) and selectively sending things like Forth definitions or data into the monitor. Luckily, this can be accomplished without an IDE, with GNU screen and a single line of vimscript.
Since I always forget how to do this, I will immortalize the recipe here. Enjoy.
Required:
* GNU screen utility Used as a serial port terminal, but can do so much more...
* vim, my editor of choice, but Emacs or any programmable editor is capable of this...
Strategy:
* Start a named screen session to the target and as a general-purpose terminal.
* Configure vim to send a line of text and scroll down one line, bound to Ctrl-l.
Recipe:
Alter to fit your circumstances. I use 'potato' as the session name, and connect on port /dev/ttyUSB1 at 115200 baud.
Add (as one line) to .vimrc:
Start a screen session:
Make sure you can communicate to your device.
Start vim and enter a few lines of code or whatever you may normally send to your target, put the cursor on the first line, and press Ctrl-l for every line you want sent.
That's all there is to it.
---------------------------------------------
Improve as you need to -- sending entire Forth definitions, or the complete contents of a file is pretty easy. And anything capable of executing a command line can send to your target using the following template:
If you need direct access to the serial port -- maybe to send a binary -- you can detach the screen session with <Ctrl-A><D>, do your business, and reattach with 'screen -r potato'.
I am always envious of a Lisp-like environment -- a full-screen editor capable of sending text to the target when desired. This allows for easy code development (editing files) and selectively sending things like Forth definitions or data into the monitor. Luckily, this can be accomplished without an IDE, with GNU screen and a single line of vimscript.
Since I always forget how to do this, I will immortalize the recipe here. Enjoy.
Required:
* GNU screen utility Used as a serial port terminal, but can do so much more...
* vim, my editor of choice, but Emacs or any programmable editor is capable of this...
Strategy:
* Start a named screen session to the target and as a general-purpose terminal.
* Configure vim to send a line of text and scroll down one line, bound to Ctrl-l.
Recipe:
Alter to fit your circumstances. I use 'potato' as the session name, and connect on port /dev/ttyUSB1 at 115200 baud.
Add (as one line) to .vimrc:
Code: Select all
nnoremap <C-l> :let @a = getline('.')<CR>:call system('screen -x potato -X stuff "' . escape(@a, '\') . '\r"')<CR>:normal! j<CR>
Code: Select all
screen -S potato /dev/ttyUSB0 115200 Start vim and enter a few lines of code or whatever you may normally send to your target, put the cursor on the first line, and press Ctrl-l for every line you want sent.
That's all there is to it.
---------------------------------------------
Improve as you need to -- sending entire Forth definitions, or the complete contents of a file is pretty easy. And anything capable of executing a command line can send to your target using the following template:
Code: Select all
screen -x potato -X stuff "Hello there\r\n"