Talk to a board
A line typed at the prompt runs on the board, and what it prints appears in the board’s terminal. Then a line that starts at the prompt moves to the board part way through and finishes there. Nothing is flashed: the board already runs what it needs.
You need: a board set up and open in
its terminal, the command line host, and
two terminals: the board’s, and a prompt in the directory the command
line was built in. You have them when the board’s terminal prints
=== ready, and a prompt answers : 23. The address below is one
board’s; put yours in its place.
1. Read the board’s address
In the board’s terminal, press RESET. About twelve seconds later:
outer: connected, ip 192.168.1.101
=== ready; send OSEN to udp 8888 ===
=== and SLIP-framed OSC on tcp 8889 ===
The first line is the address. Leave this terminal open: it shows what the board prints.
2. A program, sent
In the second terminal, open a prompt and type a block with the board’s address after it:
./o.se -f o.se.osen/osen.ose
> ({ ((2, 3) /o/add) /o/println }, "tcp://192.168.1.101:8889") /o/eval/at
: []
The board’s terminal:
: 5
The block is a bundle of messages. /o/eval/at sent it over TCP, the
board ran it, and the print happened there.
3. A computation, sent
Now a line that does some of its work here and the rest there:
> /count : 41, ("tcp://192.168.1.101:8889") /continue/at, /count : (/count, 1) /o/add, (/count) /o/println
: []
The board’s terminal:
ose: landed, a machine of 1180 bytes -- it runs next
: 42
/count : 41 ran at the prompt. /continue/at packed up the running
line, /count included, and sent it; the add and the print ran on the
board. Ask the prompt for the name now:
> /count
Caught exception: /count is not bound. Did you mean /o/count?
It left with the line.
What happened
- Step 2 sent a program. The board parsed nothing: a block is already the bundle the board runs.
- Step 3 sent the computation itself. Its stack, its names and what was left to do, as one bundle, and the board carried on from where the line had got to.
- The board was not changed. Both lines arrived through the one door every host has; the board ran what it was handed.
If something goes wrong
| what you see | do |
|---|---|
| nothing in the board’s terminal after step 2 | the address is wrong, or the board has restarted onto a new one: read it again in step 1 |
connection refused |
the board and the laptop are not on the same network, or the network keeps devices apart: a home network or a phone’s hotspot does not |
: 5 prints at the prompt |
the address was missing from the line, so it ran here |
| anything else | press RESET, wait for === ready, and type the line again |
Examples · Microcontroller · Fix a loop that failed on a board · Between hosts