[Snek] EV3: network server?

Mikhail Gusarov dottedmag at dottedmag.net
Sat Feb 22 14:20:39 PST 2020


Hi.

I've played with adding support to snekde (faster than mucking with mu, 
this
will come later).

I have tried to run snek over SSH (roughly `ssh ev3 brickrun -r -- 
./snek`), and
this kinda works, but with downsides:

- snek either exits when snekde is disconnected, or stays reading EOF 
from stdin,
   preventing new snek from being executed.

   Brickrun ensures only one command is running at the same time, as it 
takes care
   of stopping motors / cleaning display at exit.

- snekde has to be runnning for snek to run, unless started manually on 
the device.

So, I was thinking of the following instead:

- snek starts with a listening socket,
- when a first client connects to this socket, it becomes stdin/stdout 
of snek program.
- when a second client connects to this socket, first client is 
disconnected.
- when no clients are connected, reading stdin blocks, stdout goes to 
/dev/null.

So it will be quite similar to a serial port.

Any comments? Maybe there is a simpler way to get to the same result?

P.S: EV3 runs Avahi, so I can put a config file there to broadcast EV3 
address via mDNS.
Snekde/mu can get address of EV3 in the network without further 
configuration.


More information about the Snek mailing list