Between hosts
Three things cross between hosts: a bundle of data, a program, and a running machine.
A bundle of data
Any OSC tool can send one to a host’s port. The command line receives on a UDP port it binds; this line waits for one packet, prints its payload and exits:
./o.se -f o.se.osen/osen.ose '/,/s/0.0.0.0' '/,/i/7788' '/!/udp/sock/bind' \
'/!/udp/recv' '/!/drop' '/!/println' '/!/quit'
The board listens on UDP 8888 and answers whoever sent to it; the Python
host’s examples/udp.py --serve 7777 is a responder to try against.
A program
Source, or already parsed: the parsed form needs only a machine at the far end, the source needs osen there too and is smaller on the wire.
- Command line:
/!/loadwith a path takes a.oseor.osenfile, or a shared library; a string of osen arrives as[/,/s/<source>, /!/repl/rep]. - Python:
vm.parse(src)gives the bytes for a socket;ose.program(vm, src)marks them as a program when they define anything;vm.recvtakes bytes in. - Board:
python3 tools/send_osen.py <address> '(1, 2) /o/add, /!/println'sends source to port 8888, as the one-message bundle the board expects. - Max: a message into the object; instantiating
o.se.o.<name>loads<name>.osefrom the search path. - Browser: whatever arrives on the page’s socket lands in the machine’s input.
A running machine
("host:port") /continue/at moves the running program to that address;
the rest of it runs on the far side, and a name it bound before the move
is still bound after it.
Move a program between two shells shows it.
Transports
- UDP — every host but the browser: the command line (
/udp/*, fromo.se.udp), the board (8888 for a program, 8889 for a machine, replies on 8890), Max (udpreceive/udpsend), Python (udp.py). A datagram has a size limit, and a machine can be larger than it; the board’s transport cuts a packet over the limit into/chunkmessages and the board reassembles them. - TCP, SLIP-framed —
o.se.tcpat the command line (/tcp/listen,/tcp/accept,/tcp/connect,/tcp/send,/tcp/recv), and the board’sESP32S3ResumeTCPsketch on 8889. No size limit. -
WebSocket —
tools/ws-bridge.js, a Node program inweb.o.se’stools/, carries datagrams to a browser tab as WebSocket frames and frames back out as datagrams, byte for byte.node tools/ws-bridge.js # udp 9999 in, ws 8080 out node tools/ws-bridge.js --to 192.168.1.101:8889 # and frames back, to there node tools/ws-bridge.js --udp 9999 --ws 8080 --to <host:port>Put
ws://localhost:8080in the page’s socket field and press Connect. One tab at a time. - Serial — the board prints to its console at 115200 baud; no host takes a program over serial.
From → to
| from \ to | command line | Max | browser | board | Python |
|---|---|---|---|---|---|
| command line | machine | program | machine, via the bridge | machine | program |
| Max | program | program | program, via the bridge | program | program |
| browser | machine, via the bridge | program, via the bridge | — | machine, via the bridge | program, via the bridge |
| board | machine | program | machine, via the bridge | machine | program |
| Python | program | program | program | program | program |
| any OSC tool | data | data | data, via the bridge | data | data |
machine: a running machine crosses and continues; program: a bundle that runs at the far end; data: a bundle arrives as data; —: no transport both ends share.
Recipes
- Move a program between two shells
- Send a program to a board
- Send data to the command line
- A program from Python to the browser
- The browser and a board through the bridge