Skip to content

Commit 23e067f

Browse files
committed
add some doc, fix the version string
1 parent cda1dec commit 23e067f

File tree

5 files changed

+77
-11
lines changed

5 files changed

+77
-11
lines changed

README.md

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,100 @@
11
# modbus-plugin
22

3-
# Requirements
3+
## Requirements
4+
* Ubuntu >= 22.04 or Debian >= 11.0
45
* Python >= 3.9
6+
* pip
57

6-
# Setup (without deb package)
8+
## Build
9+
10+
### Python Wheel
11+
* cd to the source root
12+
* install the build helper via `pip install build` and do a `python -m build`
13+
14+
### Debian package
15+
16+
Make sure to run the following on a build environment that matches the target.
17+
If you are using a WSL container, make sure that the build directory is not on a Windows path (e.g. /mnt/c),
18+
as Windows filesystem won't handle the permissions correctly (sets +x on everything)
19+
20+
* do the Python Wheel build: install the build helper via `pip install build` and do a `python -m build`
21+
* install all dependencies `sudo apt-get install build-essential debhelper devscripts equivs dh-virtualenv`
22+
* cd into the source root folder (the one that includes the debian directory)
23+
* run `dpkg-buildpackage -us -uc -b` In case you are running into problems with virtualenv, try a `sudo pip install virtualenv` first
24+
25+
## Deployment
26+
27+
### As Python script (for dev only)
728
* copy modbus-plugin folder to target device
829
* ssh into device and go to the plugin folder
930
* create the virtualenv with `python -m venv venv`
1031
* activate venv environment with `source ./venv/bin/activate`
1132
* install all dependencies with `python -m pip install -r requirements.txt`
12-
* run the reader with `python c8y_ModbusListener/reader.py -c ./config`
33+
* run the reader with `python modbus_reader/reader.py -c ./config`
34+
35+
### As deb file
36+
Run `sudo dpkg -i te-modbus-plugin-<version>-<arch>.deb`
37+
38+
39+
40+
## Logs and systemd service
41+
Executing the deb installer will place the config files into /etc/tedege/plugins/modbus/.
42+
If systemd is installed, it will run the service as part of the post-installation routine.
43+
44+
Check the status of the systemd service with `sudo systemctl status te-modbus-plugin.service`
45+
When running as a service, the default log output goes to /var/log/te-modbus-plugin/modbus.log.
1346

14-
# Config files
47+
48+
## Config files
1549

1650
All config files are expected to be in the /etc/tedge/plugins/modbus folder.
1751
As alternative the directory can be based with -c or --configdir to the python script like so:
18-
`python c8y_ModbusListener/reader.py --configdir <configfolder>`
52+
`python modbus_reader/reader.py --configdir <configfolder>`
1953

2054

21-
## modbus.toml
55+
### modbus.toml
2256
Includes the basic configuration for the plugin:
2357
* poll rate
2458
* connection to thin-edge (MQTT broker needs to match the one of tedge)
2559

26-
## devices.toml
60+
### devices.toml
2761

2862
Defines the existing child devices and their protocol for polling the Modbus folder.
2963
The structure is based on the Cloud Fieldbus protocols.
64+
Add a `[[device]]` entry for each different IP address
3065

31-
## watchdog
32-
The watchdog will take care of restarting the MQTT and Modbus connection when either
66+
### Updating the config files
67+
A watchdog observer will take care of restarting the MQTT and Modbus connection when either
3368
devices.toml or modbus.toml changes. So there should be no need to manually restart the
34-
python script.
69+
python script / service.
70+
71+
72+
## Cumulocity Integration
73+
### Installation via Software Management
74+
75+
Upload the deb package to the Cumulocity Software Repository. The name **must** be *te-modbus-plugin* and
76+
the version **must** match the version in the *.deb package name (e.g. 1.0.0). The rest of the fields can be set as necessary.
77+
Go to the Software tab of the target device and select the package for installation. After the operation is successfull the plugin will start automatically on the device.
78+
![Image](./doc/sm.png)
79+
### Log file access
80+
81+
82+
For integration with the C8Y log plugin add the following line to the /etc/tedge/c8y/c8y-log-plugin.toml
83+
84+
{ type = "modbus", path = "/var/log/te-modbus-plugin/modbus.log" }
85+
86+
![Image](./doc/log.png)
87+
88+
### Config management
89+
Both config files can either be updated in-place (i.e. simply editing with an editor) or
90+
by using the c8y-configuration plugin. Add the following lines to the c8y-configuration-plugin.toml
91+
to be able to access them from the Cumulocity Configuration UI:
92+
93+
{path = '/etc/tedge/plugins/modbus/modbus.toml', type='modbus'},
94+
{path = '/etc/tedge/plugins/modbus/devices.toml', type='modbus-devices'}
95+
96+
To replace the files with a version from the C8Y Configuration Repository you have to download a copy,
97+
edit it and upload it to the repository. The device type **must** be set to *thin-edge.io* and the config type must match
98+
the definition in your c8y-configuration-plugin.toml. I.e either *modbus* (for modbus.toml) or *modbus-devices* for (devices.toml)
99+
100+
![Image](./doc/cm.png)

debian/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
te-modbus-plugin (0.1) UNRELEASED; urgency=medium
1+
te-modbus-plugin (0.1.0) UNRELEASED; urgency=medium
22

33
* Modbus Plugin for thin-edge. Initial release.
44

doc/cm.png

35.6 KB
Loading

doc/log.png

104 KB
Loading

doc/sm.png

50.7 KB
Loading

0 commit comments

Comments
 (0)