Skip to content

Running python scripts

OtavioJFOliveira edited this page Aug 26, 2020 · 1 revision

Control model 1

In order for the controllers to work correctly, it is necessary to run a python script suitable for each connection mode.

To make the applications easier to use, two python scripts were developed.

  • One for connection mode via USB port and serial communication
  • One for connection mode via WiFi connection

Within the Server folder, in this project's repository, these two Scripts will be available, which have their own peculiar characteristics. In order for the scripts to run correctly, some steps must be followed.

Cloning the repository and running the scripts

git clone https://github.com/LiquidGalaxyLAB/Arduino-Controller
cd Arduino-Controller/Server

Inside this folder, two python scripts and a README file will be available, with the list of dependencies that need to be installed previously for the scripts to work.

Before running the server script, it is necessary to update the pip:

sudo python -m pip install --upgrade pip

And install these dependencies below:

pip install pynput 1.6.8
pip install python-xlib 0.27
pip install pyuserinput 0.1.11
pip install pyserial 3.4
pip install keyboard 0.13.5

Open the terminal and include the user in the "tty" and "dialout" groups, with the commands:

sudo usermod -a -G tty lg
sudo usermod -a -G dialout lg

Now logout and then log in again. To verify that groups have been added, use the command:

groups

The command output must contain the groups to which we include the user. These commands are necessary to enable the use of the serial port for the controller

For the case of making the connection between the controller and the PC Master Liquid Galaxy use the commands below to allow connection via tcp on the firewall on the master pc: Known issues: If you chose to connect with Liquid Galaxy using WiFi and your computer is not showing any results, check your Firewall rules, to perform the Firewall release you can use the following commands: These commands need administrator permission, using the sudo command on all lines this permission will be granted

sudo iptables -F
sudo iptables -A INPUT -i eth0 -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 8000 -j ACCEPT
sudo iptables -A INPUT -p tcp --syn -j DROP

Running

Run the script inside the server folder

cd Arduino-Controller/Server

If you chose to communicate with Liquid Galaxy using Serial communication you will need to connect the USB cable to one of the Master computer's inputs and then run the Python Script for Serial communication, use the command:

Python SerialServer.py

If you chose to perform the control using WiFi communication, run the command:

Python Socket.py

After typing one of these commands, minimize the terminal and leave only the world on the screen.