Create a Web Socket pipe to Luos network using Raspberry Pi


#1

If you are using Raspberry on your robot you should have noticed that develop directly in it is boring. You probably don’t have possibility to have any screen and keyboard on your raspberry and you probably already deploy a complexe strategy to link your computer to your Raspberry…

To solve this problem it could be interesting to bypass the raspberry and use directly the gate stream with your computer. To do that you can use a specific program installed with pyluos allowing to translate serial data into web socket called pyluos-usb2ws.

Before using your Raspberry with your Luos boards you have to enable serial :

$ echo "dtoverlay=pi3-disable-bt" | sudo tee --append /boot/config.txt
$ sudo systemctl disable hciuart

Now you can install python, pip and pyluos :

$ sudo apt-get update
$ sudo apt-get install python-dev
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ sudo python get-pip.py
$ sudo pip install pyluos

Now you should be able to connect your Raspberry to your Luos network using pyluos. To run pyluos-usb2ws you can execute :

pyluos-usb2ws --serial-port /dev/ttyAMA0 --ws-port 9342

Now you should be able to connect your computer to your Luos network using pyluos and the IP of your Raspberry.

If you want to start this program at startup of your raspberry you can create a service on your raspberry using this script :

$ sudo tee /etc/systemd/system/pyluos-usb2ws.service > /dev/null <<EOF
[Unit]
Description=pyluos usb to websocket convertion
Wants=network-online.target
After=network.target network-online.target
[Service]
PIDFile=/var/run/pyluos-usb2ws.pid
Environment="PATH=$PATH"
ExecStart=/usr/local/bin/pyluos-usb2ws --serial-port /dev/ttyAMA0 --ws-port 9342
User=pi
Group=pi
Type=simple
[Install]
WantedBy=multi-user.target
EOF
$ sudo systemctl enable pyluos-usb2ws.service

Now after startup of your Raspberry on your robot you should be able to connect to your Luos network directly from your computer.