💾 Archived View for librehacker.com › gemlog › starlog › 20240404-0.gmi captured on 2024-08-18 at 17:47:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-05-10)
-=-=-=-=-=-=-
I have been wanting to do more microcontroller programming using Zeptoforth, a full-featured, actively-developed Forth which runs on my Rpi Pico:
However, one obstacle has been that Zeptoforth uses a non-standard flow control system based on ACK and NAK bytes. It is a good system, but it is not supported by any of the usual serial communication programs like picocom and minicom. In brief, Zeptoforth receives and processes one line, and then it send an ACK indicating it is ready for more input. If an error occurs while processing the line, like a compile error or a stack underflow, Zeptoforth will send a NAK as well, before sending the ACK. If you try to send multiple lines without respecting the flow control system, it is possible that some of your input will be malformed, or that your code will be broken because some line didn't compile.
The Zeptoforth project includes an IDE called Zeptocomjs which handles this flow control, as well as providing some other nice features like processing INCLUDE directives. However, this JavaScript IDE must be run in a Web browser, which in and of itself is not appealing to me, and also the IDE has no Emacs integration while it is running. To have enjoyable and productive Zeptoforth programming, I felt I needed an Emacs interface.
Consequently, I spent the last few lunch breaks coding a simple system to interact with a Zeptoforth serial connection from Emacs, using proper flow control. I wondered if perhaps the built-in terminal emulator program could be hacked to include this flow control, but I had no idea how to approach that, and I thought a different approach might in the end be more flexible anyway. So, instead I learned how to use the Serial process interface described in the Elisp manual, and then I came up with a filter function to process the Zeptoforth output — setting flags when the ACK or NAK bytes are detected. And I coded some interactive functions to send input — either one line or a region of lines, and some code for keeping track of the buffer and process. There is still more work to be done, but I have enough now to send regions of code and to display raw output. Here is the fledgling repository:
This work © 2024 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.