Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hsainnos/LICSTER
Browse files Browse the repository at this point in the history
  • Loading branch information
mniedermaier committed Nov 26, 2019
2 parents 0e44f45 + df55b39 commit daf6045
Show file tree
Hide file tree
Showing 27 changed files with 789 additions and 17 deletions.
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#ignore the folder called build anywhere, but not files called build
build/
__pycache__/

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.out

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite
*.~lock*

# LaTeX #
######################
*.aux
*.bbl
*.blg
*.dvi
*.ps
*.bib
*.fdb_latexmk
*.fls
*.log
*.nav
*.out
*.synctex.gz
*.toc
*.idx
*.ilg
*.ind
*.snm
*.vrb
*.lof
*.lot
paper/paper.pdf
paper/paper_gray.pdf
paper/paper_blinded.pdf

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
thumbs.db

# Python language #
######################
*.pyc
*.swp
*.pyo

# Ingore build #
################
*.bin
*.hex
*.elf

2 changes: 1 addition & 1 deletion devices/case/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The 3d printed housing for the LICSTER testbed is currently only for **testing** purposes.

<table align="center"><tr><td align="center" width="9999">
<img src="case_v0.1.png" width=70%></img>
<img src="images/case_v0.1.png" width=70%></img>
</td></tr></table>

## Current Printer Settings for Draft Purposes
Expand Down
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
53 changes: 48 additions & 5 deletions devices/hmi/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Low-cost ICS Testbed - HMI

Install unclutter to disable mouse pointer on the HMI.
```zsh
sudo apt install unclutter npm
```

Install dependencies for LICSTER/python3.
```zsh
sudo python3 -m pip install pymodbus
```

Create the folder "gits" in the home path and switch to it.
```zsh
Expand All @@ -9,15 +18,49 @@ cd gits

Clone the git of the low cost testbed.
```zsh
git clone ...
git clone https://github.com/hsainnos/LICSTER.git
```

Install unclutter to disable mouse pointer on the HMI.
Change into the correct folder.
```zsh
sudo apt-get install unclutter
cd ~/gits/LICSTER/devices/hmi
```

Copy the autostart file to its correct place.
```zsh
~/.config/lxsession/LXDE-pi/autostart
```
mkdir -p ~/.config/lxsession/lxde-pi/
cp autostart ~/.config/lxsession/lxde-pi/autostart
```

Install bootstrap and jQuerry.
```zsh
cd ~/gits/LICSTER/devices/hmi/software/static/node_modules
npm install package.json
```

Configure IP Adress of the HMI.
```zsh
sudo nano /etc/network/interfaces
```

The file should look like this at the end.
With this, you will have a static IP and if possible also one from DHCP.
```
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo eth0 eth0:0
iface lo inet loopback
iface eth0 inet dhcp
iface eth0:0 inet static
address 192.168.0.20
netmask 255.255.255.0
```
2 changes: 1 addition & 1 deletion devices/hmi/autostart
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
@xset -dpms
@xset s noblank
@unclutter -idle 0
@/usr/bin/python /home/pi/gits/lowcostICStestbed/devices/hmi/software/app.py
@/usr/bin/python3 /home/pi/gits/LICSTER/devices/hmi/software/app.py
@chromium-browser --incognito --kiosk http://localhost:8080
20 changes: 16 additions & 4 deletions devices/hmi/software/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from plcconnectors.plc import Plc
from plcconnectors.modbusTCP.connector import ModbusTCPPlcConnector

import time

# The flask application instance.
app = Flask(__name__)

Expand Down Expand Up @@ -147,7 +149,17 @@ def index():

# Starting point.
if __name__ == '__main__':
plc = Plc(ModbusTCPPlcConnector, '192.168.0.30')

# Run the webserver.
app.run(host="0.0.0.0", port=8080)
while True:
try:
time.sleep(5)
plc = Plc(ModbusTCPPlcConnector, '192.168.0.30')

# Run the webserver.
app.run(host="0.0.0.0", port=8080)
time.sleep(1)
except KeyboardInterrupt:
time.sleep(1)
sys.exit()
except Exception as e:
print("Error: " + str(e))
time.sleep(1)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion devices/hmi/software/plcconnectors/modbusTCP/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, plc_ip_address):
self.modbus_client.connect()
if not self.modbus_client.is_socket_open():
print("Cannot connect plc connector to {0}".format(plc_ip_address))
sys.exit(2)
raise ValueError('No connection to OpenPLC.')

# Map of motor controls to modbus/TCP bits.
self.motor_controls = {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit daf6045

Please sign in to comment.