Most recent activity
-
Gordon,
Configuring Espruino to be available over the network is trival (and wildly insecure). I used the following command, as root:
socat TCP4-LISTEN:8888,fork,reuseaddr EXEC:/root/Espruino/espruino
All that is left to do is configure Espruino Web IDE to connect via a socket and not the serial port. :)
Regards
-
My 9 year old son is an avid user of the scratch programming language and we are working on a modest weather station together. We have light, humidity and temperature sensors attached to a Raspberry Pi. The Raspberry Pi is headless which really limits his options for programming the thing. Thanks to Google I wound up here and quickly configured the Raspberry Pi to work with the Web IDE.
On my son's laptop running Chrome I installed the IDE. I made the following two configuration adjustments:
Settings->General->Overwrite JavaScript with Graphical Editor->Check the Box (true)
Settings->Communications->Baud Rate->115200As root (relax, this isn't a mission critical server) I did the following:
cd /root git clone git://git.drogon.net/wiringPi git clone https://github.com/espruino/Espruino.git cd wiringPi ./build cd ../Espruino make
Next I installed the socat program.
apt-get install socat
Then, I determined the TTY device of my serial port
root@weather:~# dmesg | grep tty [ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x10 bcm2708.serial=0x561ae60d smsc95xx.macaddr=B8:27:EB:1A:E6:0D bcm2708_fb.fbswap=1 bcm2708.disk_led_gpio=47 bcm2708.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait [ 0.001749] console [tty1] enabled [ 0.141194] 20201000.uart: ttyAMA0 at MMIO 0x20201000 (irq = 83, base_baud = 0) is a PL011 rev2
In my case the serial device is 'ttyAMAo'
Next I opened /etc/inittab in an editor and ensured that no programs were using /dev/ttyAMAo. Now that I think of it, you may also need to edit the grub config and remove any serial console parameters passed to the kernel. I leave this as an exercise for the reader.
Finally, I added the following to /etc/inittab
T0:23:respawn:socat SYSTEM:/root/Espruino/espruino FILE:/dev/ttyAMA0,b115200,raw
Next I instructed init to re-read the configuration
init q
The Espruino prompt immediately appeared on the IDE. I switched to the graphical editor and it worked too. And just like that my son can explore physical computing on a Raspberry Pi using Espruino.
Time to visit your store and order some boards. I see lots of little creations in his future.
There are implications that anyone attempting the above should be aware of. Chiefly, the above command will spawn a new instance of Espruino on the raspberry pi each time the Web IDE connects. It is unlikely this is desireable, I will work on a technique that attaches an incoming port to an already running Espruino instance. Reattaching to a previous session is what people likely expect.