OT 101: OpenPLC (15 pts)

What You Need

Installing OpenPLC Runtime

On your Debian machine, in a Terminal or SSH window, execute these commands, one at a time:
sudo apt update
sudo apt install git -y
git clone https://github.com/thiagoralves/OpenPLC_v3.git
cd OpenPLC_v3
./install.sh linux

sudo ./start_openplc.sh

Installing Sudo

If you are using a minimal Debian install, you may not have sudo. In that case, execute these commands. In the third one, replace username with the name of your normal user account, which may be "debian".
su root
apt install sudo
/sbin/adduser username sudo
exit
exit
OpenPLC starts, and displays various addresses to view the Dashboard, as shown below.

Opening the OpenPLC Dashboard

In a Web browser, go to the last address displayed in your Linux terminal.

Log in with username openplc and password openplc

The Dashboard appears, as shown below.

Adding a Modbus Slave Device

In the OpenPLC dashboard, on the left side, click "Slave Devices".

Click the "Add new device" button.

In the "Add new device" page, make these entries, as shown below.

Click the "Save device" button.

The Slave Device appears in the list, as shown below.
On the lower left, click the "Start PLC" button.

The Runtime Logs show that the server is listening on port 502, as shown below.

Getting qModMaster

qModMaster simulates a Modbus Master.

Your Windows system should already have qModMaster installed. If it does not, follow the steps in the blue box below.

Installing qModMaster

In a Web browser, go to
https://sourceforge.net/projects/qmodmaster/
Download the Windows pre-compiled binary.

Open your Downloads folder.

Right-click the https://sourceforge.net/projects/qmodmaster/ file and click "Extract All...", Extract. Click Extract

Double-click the qModMaster folder to open it.

Double-click the qModMaster.exe file.

qModMaster opens, as shown below.

Connecting to the OpenPLC Slave

In the qModMaster window, click Options, "Modbus TCP...".

Enter the IP address of your Linux server, as shown below.

Click the OK button.

In the qModMaster window, set the Modbus Mode to TCP, outlined in red in the image below.
In the qModMaster window, click the Connect button, outlined in blue in the image above.

Reading Data from the Slave

In the qModMaster window, make these settings: Click the "Read/Write" button, outlined in green in the image below.

The data fills in in the lower pane, showing five zeroes.

Installing Wireshark

Your Windows system should already have Wireshark installed. If it does not, get it from:
https://www.wireshark.org/
Launch Wireshark.

Double-click the adapter that goes to the Internet, which was Ethernet1 on my system, outlined in red in the image below.

Flag OT 101.1: Read Request (15 pts)

In QModMaster, read the five coils from the slave again.

Wireshark shows four packets, as shown below: a Query, an Acknowledgement (ACK), a Response, and another Acknowledgement.

In the top pane, click the Response packet.

In the Details pane, expand the Modbus/TCP container.

The flag is covered by a green rectangle in the image below.

Posted 12-28-23
Updated with sudo install 2-10-24