picocalc & xmodem
Recently I acquired a picocalc, a portable device that comes with picomite pre-installed. Admittedly, I bought it because it looked cool, and did roughly zero research into what you could actually do with it. The picomite firmware has a MMBasic interpreter, so I figured I would play around with programming on it. Having never programmed in MMBasic (let alone BASIC) before, it took me a while to get the hang of the syntax. The first project I have built on this is a simple paddle game (which took me a much longer time than I care to admit). Here's the source code if interested.
One difficulty I ran into was the lack of access to my github account on the picocalc. I'm used to setting up a local git repo almost immediately after starting any new project or using my "catch all" private repo that I use to track random projects. As a somewhat neurotic person, I will add and commit just about any set of small changes (with helpful commit messages such as "works") on a dev branch about every 2-20 minutes when doing focused work.
A cool feature of the picocalc is that you can connect it to a computer using its usb-c port and communicate serially with that computer using the xmodem protocol. This has allowed me to follow a relatively fun development process:
- Play around with the picocalc, get some simple proof of concept working.
- Send the relevant file(s) from my picocalc to to one of my dev machines (e.g. laptop or computer).
- Add the file(s) to source control on my dev machine.
- Do some quick cleanup / refactoring on my dev machine, maybe implement a feature or two.
- Send the relevant file(s) from my dev machine back to my picocalc.
- Test the updated code. Fix any syntax errors or bugs.
- Repeat process starting at step 2.
This has been a fun blend of getting to play around with the BASIC programming language on a convenient handheld, and also being able to use my dev machine for larger changes (using a more comfortable keyboard and neovim). Also, I can use git. Working on software without source control is insane.
Here's how I do the file transfers.
Picocom & XMODEM
First of all, you have to install picocom. I almost exclusively use ubuntu (the exception being when I'm forced to use something else by higher powers), so all of these steps are what I do on ubuntu 24.
Install picocom (I'd rather not include this, it seems obvious đ ; but here you go)
sudo apt install picocom lrzsz
With your picocalc connected to your dev machine, you then can find the device file by:
# on your dev machine
ls /dev/serial/by-id
This will output whatever serial devices that are connected to your machine. If you see multiple devices after running the above command, you can try disconnecting your picocalc, re-running the command; and whichever device file name is missing is likely your picocalc.
Now that you have the device file name, you can start picocom (with DEVICEPATH being the full path to your serial device):
picocom \
--baud 115200 \
--parity n \
--stopbits 1 \
--flow h \
--receive-cmd "rx -vv" \
--send-cmd "sx -vv" \
DEVICEPATH
For example, this is what I run:
picocom \
--baud 115200\
--parity n \
--stopbits 1 \
--flow h \
--receive-cmd "rx -vv" \
--send-cmd "sx -vv" \
/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
Sometimes I run into weird issues when sending/receiving to/from my picocalc & dev machine. I have found that
changing the --flow h command to --flow n makes it always work.
e.g.
picocom --baud 115200 \
--parity n \
--stopbits 1 \
--flow n \
--receive-cmd "rx -vv" \
--send-cmd "sx -vv" \
/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
The difference between the arg values is --flow h uses hardware flow control
and --flow n uses no flow control. Based on the wikipedia page for flow control, it seems better to have it
than not; but anecdotally I have yet to run into any issues running without flow control.
Now with the picocom terminal connected to our picocalc, we can send and receive files.
Sending files from picocalc to dev machine
On the picocalc enter the following command (replace FILEPATH with the file you want to send from picocalc):
XMODEM SEND FILEPATH
On your dev machine, with picocom open, you can type (and hold) Ctrl+a+r.
You should then see a prompt for file:.
Type in the path FILEPATH you want to save the received file to.
NOTE that you do not have to use the same name as the file you are sending from picocalc.
*** file: FILEPATH
If all worked out, you should then see the file at whatever path you gave the above command.
Sending files from dev machine to picocalc
On your desktop, with picocom open, you can run the send command with âCtrl+a+sâ.
You should see a similar file: prompt as you did when executing the receive command in picocom.
Enter the file path FILEPATH of the file from your filesystem that you want to send to picocalc:
*** file: FILEPATH
On your picocalc run the following (where FILEPATH) is the path you want to save the file to.
XMODEM RECEIVE FILEPATH
Similiarly to the process for sending files from picocalc to dev machine, the receiver does not need to specify the same filename/path as the sender. Whatever file is sent by the sender will get saved as whatever the receiver specifies it should be saved as.
If the above works out, you should now see the file on your picocalc (with whatever path you specified).